Class: WooCommerce::CustomersResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/woo_commerce/resources/customers.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from WooCommerce::Resource

Instance Method Details

#create(email:, **params) ⇒ Object



13
14
15
16
# File 'lib/woo_commerce/resources/customers.rb', line 13

def create(email:, **params)
  attributes = {email: email}
  Customer.new post_request("customers", body: attributes.merge(params)).body
end

#delete(id:) ⇒ Object



22
23
24
25
# File 'lib/woo_commerce/resources/customers.rb', line 22

def delete(id:)
  response = delete_request("customers/#{id}", params: {force: true})
  return true if response.success?
end

#list(**params) ⇒ Object



4
5
6
7
# File 'lib/woo_commerce/resources/customers.rb', line 4

def list(**params)
  response = get_request("customers", params: params)
  Collection.from_response(response, type: Customer)
end

#retrieve(id:) ⇒ Object



9
10
11
# File 'lib/woo_commerce/resources/customers.rb', line 9

def retrieve(id:)
  Customer.new get_request("customers/#{id}").body
end

#update(id:, **params) ⇒ Object



18
19
20
# File 'lib/woo_commerce/resources/customers.rb', line 18

def update(id:, **params)
  Customer.new put_request("customers/#{id}", body: params).body
end