Class: Voucherify::Service::Customers
- Inherits:
-
Object
- Object
- Voucherify::Service::Customers
- Defined in:
- lib/voucherify/service/customers.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #create(customer) ⇒ Object
- #delete(customer_id) ⇒ Object
- #get(customer_id) ⇒ Object
-
#initialize(client) ⇒ Customers
constructor
A new instance of Customers.
- #list(params = {}) ⇒ Object
- #update(customer) ⇒ Object
- #update_consents(customer_id, consents) ⇒ Object
Constructor Details
#initialize(client) ⇒ Customers
Returns a new instance of Customers.
8 9 10 |
# File 'lib/voucherify/service/customers.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/voucherify/service/customers.rb', line 6 def client @client end |
Instance Method Details
#create(customer) ⇒ Object
16 17 18 |
# File 'lib/voucherify/service/customers.rb', line 16 def create(customer) @client.post('/customers', customer.to_json) end |
#delete(customer_id) ⇒ Object
28 29 30 |
# File 'lib/voucherify/service/customers.rb', line 28 def delete(customer_id) @client.delete("/customers/#{ERB::Util.url_encode(customer_id)}") end |
#get(customer_id) ⇒ Object
20 21 22 |
# File 'lib/voucherify/service/customers.rb', line 20 def get(customer_id) @client.get("/customers/#{ERB::Util.url_encode(customer_id)}") end |
#list(params = {}) ⇒ Object
12 13 14 |
# File 'lib/voucherify/service/customers.rb', line 12 def list(params = {}) @client.get('/customers', params) end |
#update(customer) ⇒ Object
24 25 26 |
# File 'lib/voucherify/service/customers.rb', line 24 def update(customer) @client.put("/customers/#{ERB::Util.url_encode(customer['id'] || customer[:id])}", customer.to_json) end |
#update_consents(customer_id, consents) ⇒ Object
32 33 34 |
# File 'lib/voucherify/service/customers.rb', line 32 def (customer_id, ) @client.put("/customers/#{ERB::Util.url_encode(customer_id)}/consents", .to_json) end |