class Shopify::Customer
- Shopify::Customer
- Shopify::Resource
- Reference
- Object
Overview
https://shopify.dev/api/admin-rest/2022-01/resources/customer
Extended Modules
- Shopify::Resource::ClassMethods
Defined in:
shopify/resources/customer.crConstructors
Class Method Summary
-
.all(domain : String, depth : Int32 = 20, headers : HTTP::Headers = headers) : Array(Shopify::Customer)
Used to return an array of customers.
-
.all(domain : String, next_page_uri : String? = nil, depth : Int32 = 20, headers : HTTP::Headers = headers, &block : self -> )
Used to iterate over all customers.
-
.count(domain : String, headers : HTTP::Headers = headers) : Int64
Used to get a count of all customers.
-
.create(body : String, domain : String, headers : HTTP::Headers = headers) : Shopify::Customer
Used to create one customer.
-
.find(id : Int64, domain : String, headers : HTTP::Headers = headers) : Shopify::Customer
Used to fetch one customer.
-
.search(query : String, domain : String, headers : HTTP::Headers = headers)
Under the covers, this just runs:
plaintext GET /admin/api/2022-01/customers/search.json?query=
- .uri(domain : String, path : String = "") : URI
- .with(store : Store)
Instance Method Summary
- #accepts_marketing : Bool
- #accepts_marketing=(accepts_marketing : Bool)
- #accepts_marketing_updated_at : Time
- #accepts_marketing_updated_at=(accepts_marketing_updated_at : Time)
- #addresses : Array(Shopify::Address)
- #addresses=(addresses : Array(Shopify::Address))
- #admin_graphql_api_id : String
- #admin_graphql_api_id=(admin_graphql_api_id : String)
-
#create_account_activation_url : URI
Under the covers, this just runs:
plaintext POST /admin/api/2022-01/customers/{id}/account_activation_url.json
- #created_at : Time
- #created_at=(created_at : Time)
- #currency : String
- #currency=(currency : String)
- #default_address : Shopify::Address
- #default_address=(default_address : Shopify::Address)
-
#delete
Used to delete one customer.
- #email : String
- #email=(email : String)
- #first_name : String
- #first_name=(first_name : String)
- #id : Int64
- #id=(id : Int64)
- #last_name : String
- #last_name=(last_name : String)
- #last_order_id : Int64?
- #last_order_id=(last_order_id : Int64?)
- #last_order_name : String?
- #last_order_name=(last_order_name : String?)
- #marketing_opt_in_level : String?
- #marketing_opt_in_level=(marketing_opt_in_level : String?)
- #multipass_identifier : String?
- #multipass_identifier=(multipass_identifier : String?)
- #note : String?
- #note=(note : String?)
-
#orders : Array(Shopify::Order)
Under the covers, this just runs:
plaintext GET /admin/api/2022-01/customers/{id}/orders.json
- #orders_count : Int32
- #orders_count=(orders_count : Int32)
- #phone : String?
- #phone=(phone : String?)
-
#send_invite : Shopify::CustomerInvite
Under the covers, this just runs:
plaintext POST /admin/api/2022-01/customers/{id}/send_invite.json
- #sms_marketing_consent : JSON::Any?
- #sms_marketing_consent=(sms_marketing_consent : JSON::Any?)
- #state : String
- #state=(state : String)
- #tags : String
- #tags=(tags : String)
- #tax_exempt : Bool
- #tax_exempt=(tax_exempt : Bool)
- #tax_exemptions : Array(JSON::Any)
- #tax_exemptions=(tax_exemptions : Array(JSON::Any))
- #total_spent : String
- #total_spent=(total_spent : String)
-
#update(body : String) : self
Sample Body from Shopify Docs:
plaintext {"id":207119551,"email":"changed@example.com","note":"Customer is great"}}
- #updated_at : Time
- #updated_at=(updated_at : Time)
- #verified_email : Bool
- #verified_email=(verified_email : Bool)
Instance methods inherited from class Shopify::Resource
store : Store
store,
store=(store : Store)
store=
Constructor methods inherited from class Shopify::Resource
new(pull : JSON::PullParser)
new
Class methods inherited from class Shopify::Resource
headers
headers
Constructor Detail
Class Method Detail
Used to return an array of customers. Uses fibers to fetch pages concurrently.
NOTE It is recommended to use .all(domain, next_page_uri, headers, &block)
directly instead of this method as it is more performant.
Generally, this is used with .with(store)
:
Shopify::Customer.with(store).all #=> Array(Shopify::Customer)
But it can be used stand-alone, too:
Shopify::Customer.all(domain, headers: headers) #=> Array(Shopify::Customer)
This just runs the &block
version of .all(domain, next_page_uri, headers, &block)
to create an array
Used to iterate over all customers. Uses fibers to fetch pages concurrently.
Generally, this is used with .with(store)
:
Shopify::Customer.with(store).all do |customer|
# do something with customer
end
But it can be used stand-alone, too:
Shopify::Customer.all(domain, headers: headers) do |customer|
# do something with customer
end
Under the covers, this just runs:
GET
/admin/api/2022-01/customers.json
and follows every next Response Headers "Link" until there are no more.
Uses NextPreviousParser
to parse the response headers.
Used to get a count of all customers.
Generally, this is used with .with(store)
:
Shopify::Customer.with(store).count #=> Int64
But it can be used stand-alone, too:
Shopify::Customer.count(domain, headers: headers) #=> Int64
Under the covers, this just runs:
GET
/admin/api/2022-01/customers/count.json
Used to create one customer.
Generally, this is used with .with(store)
:
Shopify::Customer.with(store).create(body) #=> Shopify::Customer
But it can be used stand-alone, too:
Shopify::Customer.create(body, domain, headers: headers) #=> Shopify::Customer
A sample body from shopify docs:
{"customer":{"first_name":"Steve","last_name":"Lastnameson","email":"steve.lastnameson@example.com","phone":"+15142546011","verified_email":true,"addresses":[{"address1":"123 Oak St","city":"Ottawa","province":"ON","phone":"555-1212","zip":"123 ABC","last_name":"Lastnameson","first_name":"Mother","country":"CA"}]}}
Under the covers, this just runs:
POST
/admin/api/2022-01/customers.json
Used to fetch one customer.
Generally, this is used with .with(store)
:
Shopify::Customer.with(store).find(id) #=> Shopify::Customer
But it can be used stand-alone, too:
Shopify::Customer.find(id, domain, headers: headers) #=> Shopify::Customer
Under the covers, this just runs:
GET
/admin/api/2022-01/customers/{id}.json
Under the covers, this just runs:
GET
/admin/api/2022-01/customers/search.json?query=
Instance Method Detail
Under the covers, this just runs:
POST
/admin/api/2022-01/customers/{id}/account_activation_url.json
Used to delete one customer.
Under the covers, this just runs:
DELETE
/admin/api/2022-01/customers/{id}.json
Under the covers, this just runs:
GET
/admin/api/2022-01/customers/{id}/orders.json
Under the covers, this just runs:
POST
/admin/api/2022-01/customers/{id}/send_invite.json
Sample Body from Shopify Docs:
{"id":207119551,"email":"changed@example.com","note":"Customer is great"}}
Under the covers, this just runs:
PUT
/admin/api/2022-01/customers/{id}.json