chargebee / chargebee-ruby

Ruby library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=ruby
MIT License
33 stars 60 forks source link

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

Closed sebastiansibelle closed 9 years ago

sebastiansibelle commented 10 years ago

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

rraman commented 10 years ago

Hello Sebastian,

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

Thanks, Rajaraman

sebastiansibelle commented 10 years ago

Thanks Rajaraman,

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

Cheers,

Sebastian

saravana-cb commented 10 years ago

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

sebastiansibelle commented 10 years ago

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.

vaiporwal commented 9 years ago

Hey Sebastian,

We have released the updated version hence closing this issue.

Shahtaj-Khalid commented 5 years ago

@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.

cb-goutham commented 5 years ago

@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