Class: Voucherify::Service::Customers

Inherits:
Object
  • Object
show all
Defined in:
lib/voucherify/service/customers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (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



12
13
14
# File 'lib/voucherify/service/customers.rb', line 12

def create(customer)
  @client.post('/customers', customer.to_json)
end

#delete(customer_id) ⇒ Object



24
25
26
# File 'lib/voucherify/service/customers.rb', line 24

def delete(customer_id)
  @client.delete("/customers/#{URI.encode(customer_id)}")
end

#get(customer_id) ⇒ Object



16
17
18
# File 'lib/voucherify/service/customers.rb', line 16

def get(customer_id)
  @client.get("/customers/#{URI.encode(customer_id)}")
end

#update(customer) ⇒ Object



20
21
22
# File 'lib/voucherify/service/customers.rb', line 20

def update(customer)
  @client.put("/customers/#{URI.encode(customer['id'] || customer[:id])}", customer.to_json)
end