Using the command line shopify application
include ShopifyAPI
Customer.first(:params => {:query => "email:foo@fizz.com", :fields => "email"})
=> #<ShopifyAPI::Customer:0x00000100b75448 @attributes={"email"=>"poohbear@gmail.com"}, @prefix_options={}, @persisted=true>
I am curious if it is possible to have a query where you provide an email and the result is either empty set (not found) or a record of a customer? I am always getting a customer record back no matter what my query is. That makes it hard to determine if a Customer exists or not from outside the shop.
You’re hitting the wrong endpoint.
Customer.firstqueries the index endpoint (admin/customers.json) whereas you’re trying to do a search (admin/customers/search.json).The index endpoint doesn’t understand the query param, so it ignores it and you get the regular index.
To fix this, you need to specify the endpoint you’re trying to hit. Docs are here, Shopify-specific examples are here. Also here: