Reputation: 25
I am using the Shopify API gem in my rails app to access customers and orders.
I can pull down Customer Groups fine like below and all working well.
ShopifyAPI::CustomerGroup.find
I know want to access customers within a customer group, using the API call /admin/customer_groups/#{id}/customers.json
How do I do this in the same format as I do for the groups (i.e. using the Shopify API gem)
Upvotes: 2
Views: 1071
Reputation: 4966
UPDATE: Version 3.0.3 of the shopify_api gem adds a customers
method to CustomerGroup that fetches all customers for that group.
You can now do things like this:
group = ShopifyAPI::CustomerGroup.find(123)
customers = group.customers
--
Right now you have to do this:
Customer.find(:all, :params => {:customer_group_id => customer_group.id})
Where customer_group is the one you retrieved from your earlier call.
HOWEVER. I've just added a pull request to the shopify_api repo that encapsulates this call in a customers
method on the CustomerGroup
resource directly. Once it gets approved you'll be able to call .customers
on any customer group you have and it'll give you all the customers.
Here's the pull request for reference: https://github.com/Shopify/shopify_api/pull/40
Upvotes: 1