Class: ShopifyAPI::Customer

Inherits:
Base show all
Includes:
Metafields
Defined in:
lib/shopify_api/resources/customer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Metafields

#add_metafield, #metafields

Methods inherited from Base

activate_session, #as_json, clear_session, #encode, #headers, init_prefix, init_prefix_explicit, #persisted?

Methods included from Countable

#count

Methods inherited from ActiveResource::Base

delete, headers

Class Method Details

.search(params) ⇒ Object



9
10
11
# File 'lib/shopify_api/resources/customer.rb', line 9

def self.search(params)
  find(:all, from: :search, params: params)
end

Instance Method Details

#account_activation_urlObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/shopify_api/resources/customer.rb', line 13

def 
  resource = post(:account_activation_url, {}, only_id)
  data = ActiveSupport::JSON.decode(resource.body.to_s)
  result = nil

  if data.key?('account_activation_url')
    result = data['account_activation_url']
  end
  result
end

#ordersObject



5
6
7
# File 'lib/shopify_api/resources/customer.rb', line 5

def orders
  Order.find(:all, params: {customer_id: self.id})
end

#send_invite(customer_invite = ShopifyAPI::CustomerInvite.new) ⇒ Object



24
25
26
27
# File 'lib/shopify_api/resources/customer.rb', line 24

def send_invite(customer_invite = ShopifyAPI::CustomerInvite.new)
  resource = post(:send_invite, {}, customer_invite.encode)
  ShopifyAPI::CustomerInvite.new(ShopifyAPI::CustomerInvite.format.decode(resource.body))
end