Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomerAddress.all doesn't return results #970

Open
agramichael opened this issue Jun 2, 2022 · 7 comments
Open

CustomerAddress.all doesn't return results #970

agramichael opened this issue Jun 2, 2022 · 7 comments

Comments

@agramichael
Copy link

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"
)
  1. Perform ShopifyAPI::CustomerAddress.all(customer_id: x) and receive []
  2. Perform ShopifyAPI::Customer.find(id: x).addresses and confirm the customer actually has an address.

Specifications

  • shopify_api version: 10.1.0
  • Shopify API version used: 2022-04
@agramichael
Copy link
Author

agramichael commented Jun 2, 2022

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
Copy link

Seeng exactly the same issue on both 10.0.3 and 10.1.0

@github-actions
Copy link

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 github-actions bot added the Stale label Sep 27, 2022
@github-actions
Copy link

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
Copy link
Author

This is still unresolved.

@Trimakas
Copy link

Trimakas commented Mar 3, 2023

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

cdmwebs added a commit to cdmwebs/shopify-api-ruby that referenced this issue Aug 8, 2023
Previously, when fetching `all` on CustomerAddress it would return an
empty array. Two issues (Shopify#970, Shopify#1018) were opened outlining the problem.

This PR adds `json_response_body_name` to the CustomerAddress class to
properly fetch the results from the JSON.

Two assertions have been added to the the tests as well.
cdmwebs added a commit to cdmwebs/shopify-api-ruby that referenced this issue Aug 9, 2023
Previously, when fetching `all` on CustomerAddress it would return an
empty array. Two issues (Shopify#970, Shopify#1018) were opened outlining the problem.

Initial attempt was to override `json_response_body_name` which worked
for fetching arrays of results. It doesn't work for fetching individual
results though.

I wound up overriding `create_instances_from_response` for
CustomerAddress. It isn't ideal but it does seem to behave correctly.

Assertions have been added to the the tests as well.
@nelsonwittwer nelsonwittwer reopened this Aug 25, 2023
@github-actions github-actions bot removed the Stale label Aug 26, 2023
@mllemango
Copy link
Contributor

mllemango commented Sep 5, 2023

#1208 should address this

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

cdmwebs added a commit to cdmwebs/shopify-api-ruby that referenced this issue Oct 25, 2023
Previously, when fetching `all` on CustomerAddress it would return an
empty array. Two issues (Shopify#970, Shopify#1018) were opened outlining the problem.

Initial attempt was to override `json_response_body_name` which worked
for fetching arrays of results. It doesn't work for fetching individual
results though.

I wound up overriding `create_instances_from_response` for
CustomerAddress. It isn't ideal but it does seem to behave correctly.

Assertions have been added to the the tests as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants