gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

rest api #1231

Open unplugged216 opened 2 years ago

unplugged216 commented 2 years ago

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

When following the documented method for querying customer information in a shop, I am expecting to get a single result back.

$req = $shop->api()->rest('GET','/admin/api/customers/search.json', ['query' => 'email:test@email.com'])['body'];

Current Behavior

When running the above query, it is as if the query is not actually run and instead all results are returned. I have confirmed a single customer exists with that email. Yet it returns 50 results not just the single customer.

Failure Information

N/A

Steps to Reproduce

Run the above query using an email you know exists

unplugged216 commented 2 years ago

Well, after firmly planting my face into the keyboard, repeatedly, I determined the issue. An undocumented thingy....

In the Shopify dev docs and here in the wiki, it only assumes a customer search needs one query parameter. Well, thats false it appears. You must include 'limit' of 1.... I am working to confirm this but so far thats what it seems.

Kyon147 commented 2 years ago

Glad you found the solution @unplugged216 - I'm going to close this ticket now.

pramod-praella commented 2 years ago

hey @unplugged216 how you resolved this? as per your conversation i added a limit but still getting all records

unplugged216 commented 2 years ago

hey @unplugged216 how you resolved this? as per your conversation i added a limit but still getting all records

Hey @Pramod-HulkApps!

Here is an example, demonstrating what did not work and what worked for me.

What did not work $shop->api()->rest('GET','/admin/api/2022-10/products.json', [ 'product_type' => 'Demo Type'])['body'];

This seemed to fix my issue $shop->api()->rest('GET','/admin/api/2022-10/products.json', ['limit' => '250', 'product_type' => 'Demo Type'])['body'];

Please not I am also using the latest API. I opted in this call to set the API version manually instead of in ENV as I have noticed the ENV vars are not getting loaded consistently by the package.

unplugged216 commented 2 years ago

Glad you found the solution @unplugged216 - I'm going to close this ticket now.

@Kyon147 ,

I would recommend not closing this as my solution may only work for me. This is a documentation issue in this package. The package provides a wiki demonstration that does not work.... Closing an issue without resolve is unsettling for the project I feel.

Kyon147 commented 2 years ago

Hi @unplugged216

Happy to reopen, that's my misunderstanding reading it as a API issue rather than a package one. I tried a direct api call, and don't see any issues - so there could be a bug in the shopify-basic-api package but would need some more investigation.