How do I use since_id on the ShopifyAPI::Checkout when it doesn't return the actual ID?

Marc_Gayle
Shopify Partner
23 2 2

In the Ruby wrapper, `shopify-api`, when I query the ID of a ShopifyAPI::Checkout object it returns the token. For example:

[141] pry(main)> Checkout.last
=> #<ShopifyAPI::Checkout:0x00007fa9664e1fd0
 @attributes=
  {"id"=>20899858677942,
   "token"=>"7133c7aeb0ff3b4b506c2a66e4190ee3",
[140] pry(main)> Checkout.last.id
=> "7133c7aeb0ff3b4b506c2a66e4190ee3"

So, naturally, I can't access an integer for `Checkout.last.id` to pass as a parameter to `since_id`.

When I try to pass the token, I get an bad request error:

[139] pry(main)> Checkout.find(:all, params: { since_id: "7133c7aeb0ff3b4b506c2a66e4190ee3"})
E, [2021-05-17T11:06:36.920571 #82915] ERROR -- : GET https://mystore.myshopify.com:443/admin/api/2021-04/checkouts.json?since_id=7133c7aeb0ff3b4b506c2a66e4190ee3
E, [2021-05-17T11:06:36.920662 #82915] ERROR -- : --> 400 Bad Request 57 (520.0ms)
ActiveResource::BadRequest: Failed.  Response code = 400.  Response message = Bad Request (since_id; expected String to be a Integer).
from /.rvm/gems/ruby-3.0.1@myapp/gems/activeresource-5.1.1/lib/active_resource/connection.rb:141:in `handle_response'

This makes sense, because this is the expected behavior from the gem itself which you can see from the `checkouts_test.rb` here.

So I propose that there should be some way to override the `.id` mapping to `.token` at the very least for the `since_id` parameter, or does someone have an idea about how I can use `since_id` in this case?

0 Likes
GrahamS
Shopify Staff
Shopify Staff
47 8 2

Hey @Marc_Gayle ,

I would encourage you to log this one over on the public repository issues section of the link you provided, if you have not done so already. We have a variety of developers (first and third party) who are active in that repository that may be able to provide some more detailed information regarding the state of the API Gem or take note of feature requests. 

Graham S | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Marc_Gayle
Shopify Partner
23 2 2

I have done so, you can see the issue here.

I look forward to getting a response and getting some sort of resolution. cc @Liam 

0 Likes