Is there an API on zoho_hub to solve this easily?
If it don't exist, i think create one.
What interface do you think should be?
I think a following interface.
module ZohoHub
class BaseRecord
class << self
def bulk_upsert(arr)
By the way, I wrote the following code and performed a batch update.
class Account < ZohoHub::BaseRecord
attributes(:id, :name)
attribute_translation(
id: :id, # Make lowercase when converting to json.
)
end
accounts = Account.all
# A maximum of 100 records can be inserted/updated per API call.
# https://www.zoho.com/crm/developer/docs/api/upsert-records.html
batch_size = 100
accounts.each_slice(batch_size) { |arr|
ZohoHub.connection.put(
'Accounts',
{data: arr.map(&:to_params), trigger: 'approval'}.to_json)
}
The following code is very slow (because the PUT request is executed 200 times)
Is there an API on zoho_hub to solve this easily? If it don't exist, i think create one.
What interface do you think should be? I think a following interface.
By the way, I wrote the following code and performed a batch update.