Customer.search returns HTTPResponse instead of array of Customer object

Open
#1,361 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
api, backend

Research direction

Start at the ShopifyAPI::Customer.search entry point and trace how its response is returned compared with other resource APIs. Reproduce the query shown in the issue and verify that the result is an array of Customer objects rather than an HttpResponse object.

Written by the indexing model from the issue text.

Description

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the package
    • shopify_api version: 14.8.0
    • Ruby version: 3.4.1
    • Operating system: OS X
  • Set log_level: :debug in my configuration, if applicable
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

When calling ShopifyAPI::Customer.search the result is an ShopifyAPI::Clients::HttpResponse object. This is pretty different than other API's, most (all?) of which seem to return resource objects

Expected behavior

Returned value should be an array of Customer Objects

Actual behavior

It's an HTTPResponse Object

Steps to reproduce the problem

Demonstrating a call:

3.4.1 :049 > ShopifyAPI::Customer.search(query: "email:tim@example.com")
 =>
#<ShopifyAPI::Clients::HttpResponse:0x000000012c452bd0
 @api_call_limit={request_count: 1, bucket_size: 40},
 @body=
  {"customers" =>
    [{"id" => 7209130524768,
      "email" => "tim@example.com",

So as a client I have to do this:

 ShopifyAPI::Customer.search(query: "email:tim@example.com").body["customers"].map { ShopifyAPI::Customer.new(from_hash: it) }

Debug logs

// Paste any relevant logs here
Dominant language
Ruby
Stars
1.1k
Forks
484
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Shopify/shopify-api-ruby

All issues in Shopify/shopify-api-ruby

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.