chargebee / chargebee-ruby

Ruby library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Offset being ignored when calling ChargeBee::Customer.list({:limit => limit, :offset => offset})

sebastiansibelle opened this issue · comments

Hi there,

I've found a bug in Chargebee Gem (1.4.6), where the offset parameter is being ignored when called in the ChargeBee::Customer.list({:limit => limit, :offset => offset}) function. Where limit is an int and offset is returned from a previous call to ChargeBee::Customer.list().

I should be able to pass in an offset returned from the last call, and get the next set of results as per the documentation here: https://apidocs.chargebee.com/docs/api/customers#list_customers
However, I always get the same results regardless of what offset value is supplied.

I've prepared a gist to help illustrate the point here: https://gist.github.com/sebastiansibelle/4a374f1ffa4ebfc40633

I need to use this function very soon, so the quicker you could turn around a fix the better!

Thanks,

Sebastian

commented

Hello Sebastian,

Let me check this at our end and get back to you ASAP.

Thanks,
Rajaraman

Thanks Rajaraman,

Don't hesitate to let me know if you need any more information!

Cheers,

Sebastian

Hello Sebastian,

Thanks for letting us know the issue in our client library. We will soon update the changes to our client library. For now to get around this issue, you can pass the next value as "list.next_offset.to_s" as "offset" value to fetch next set of entries.

For example:
list = ChargeBee::Customer.list({:limit => 2})
// pass the next_offset as string to fetch the next set of entries
list = ChargeBee::Customer.list({:limit => 2, :offset => list.next_offset.to_s})

Regards,
Saravana

Thanks Saravana,

I'll use that workaround for the time being.

Let me know when you release a fix and I will update my gem.

Cheers,

Sebastian.

Hey Sebastian,

We have released the updated version hence closing this issue.

@saravana-cb @sebastiansibelle @vaibhav1510 hi,
I came across an issue while accessing offset to and i'm unable to figure out how the request will look like for accessing next offset. i'm trying something like this (https://sh1testcompany-test.chargebee.com/api/v2/events/offset?next_offset[is]=1550749829000) but it's not working kindly help me out, it will be really appreciated. Thanks.

@Shahtaj-Khalid Hi ,
The request will look like this : https://sh1testcompany-test.chargebee.com/api/v2/events?limit=2&offset=["1551079043000","348000000200"] . You can get the offset value from your previous list request ( list.next_offset.to_s)

Example :

list = ChargeBee::Event.list({
  :limit => 2
  })
list1 = ChargeBee::Event.list({
	:limit => 2,
	:offset => list.next_offset.to_s
})
list1.each do |entry|
  event = entry.event
  puts event.id
 end