如何使用 RubyZoho API 获取所有对象
How to get all objects using RubyZoho API
RubyZoho::Crm::Account.all returns 202 个帐户,还有更多帐户。
同样的 RubyZoho::Crm::Contact.all & RubyZoho::Crm::Products.all.
我该怎么做才能收到所有物品?
提前致谢
根据我所做的一些研究,Zoho Api 中设置了 200 个条目的限制。
我发现使用 RubyZoho 获取所有记录的方式:
def get_zoho_objects module_name
objects = []
first_index = 1
block_size = 200
to_index = block_size
loop do
puts "from index: #{first_index} to index: #{to_index}"
return_objects = RubyZoho.configuration.api.some(module_name, first_index, to_index)
break if return_objects == nil
objects += return_objects
first_index = to_index + 1
to_index += block_size
end
objects
end
用法:
all_accounts = get_zoho_objects "Accounts"
RubyZoho::Crm::Account.all returns 202 个帐户,还有更多帐户。 同样的 RubyZoho::Crm::Contact.all & RubyZoho::Crm::Products.all.
我该怎么做才能收到所有物品?
提前致谢
根据我所做的一些研究,Zoho Api 中设置了 200 个条目的限制。 我发现使用 RubyZoho 获取所有记录的方式:
def get_zoho_objects module_name
objects = []
first_index = 1
block_size = 200
to_index = block_size
loop do
puts "from index: #{first_index} to index: #{to_index}"
return_objects = RubyZoho.configuration.api.some(module_name, first_index, to_index)
break if return_objects == nil
objects += return_objects
first_index = to_index + 1
to_index += block_size
end
objects
end
用法:
all_accounts = get_zoho_objects "Accounts"