Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 472 forks source link

CustomerAddress.all doesn't return results #970

Open agramichael opened 2 years ago

agramichael commented 2 years ago

Issue summary

CustomerAddress.all doesn't return results, using Rest API with a private app.

Expected behavior

Returns list with customer's addresses.

Actual behavior

Returns empty list for a customer with an address.

Steps to reproduce the problem

  1. Create a customer with an address on Shopify.
  2. Initialise gem with private app config:
    ShopifyAPI::Context.setup(
    api_key: "",
    host_name:"",
    scope: "",
    session_storage: ShopifyAPI::Auth::FileSessionStorage.new,
    is_embedded: false,
    is_private: true,
    api_version: Rails.application.credentials.shopify.api_version!,
    api_secret_key: Rails.application.credentials.shopify.password!,
    private_shop: "#{Rails.application.credentials.shopify.shop_name!}.myshopify.com"
    )
  3. Perform ShopifyAPI::CustomerAddress.all(customer_id: x) and receive []
  4. Perform ShopifyAPI::Customer.find(id: x).addresses and confirm the customer actually has an address.

Specifications

agramichael commented 2 years ago

I am pretty confident this happens because create_instances_from_response assumes the class name is the key in the response, but in this case the key is addresses and not customer_addresses.

https://github.com/Shopify/shopify_api/blob/4da50e423bae6083909a179681831cec8daf0e95/lib/shopify_api/rest/base.rb#L203

Edit:

I have confirmed this is the root cause of the issue locally. Copying the content of ShopifyAPI::CustomerAddress but renaming it ShopifyAPI::Address makes the response get returned properly.

ilyabyar commented 2 years ago

Seeng exactly the same issue on both 10.0.3 and 10.1.0

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

github-actions[bot] commented 2 years ago

We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

agramichael commented 1 year ago

This is still unresolved.

Trimakas commented 1 year ago

And so what's the resolution here? I'm having this issue with AssignedFulfillmentOrder

mllemango commented 1 year ago

https://github.com/Shopify/shopify-api-ruby/pull/1208 should address this

@Trimakas I'll look into implementing something similar for AssignedFulfillmentOrder