Class: Vhx::Customer

Inherits:
VhxObject show all
Includes:
ApiOperations::Create, ApiOperations::Delete, ApiOperations::List, ApiOperations::Request
Defined in:
lib/vhx/objects/customer.rb

Constant Summary

Constants inherited from VhxObject

VhxObject::ASSOCIATION_WHITELIST

Instance Method Summary collapse

Methods included from ApiOperations::Delete

included

Methods included from ApiOperations::List

included

Methods included from ApiOperations::Request

included

Methods included from ApiOperations::Create

included

Methods inherited from VhxObject

#_embedded, #_links, #href, #initialize, #links, #to_hash, #to_json

Methods included from HelperMethods

#get_hypermedia, #get_klass

Constructor Details

This class inherits a constructor from Vhx::VhxObject

Instance Method Details

#add_product(identifier) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/vhx/objects/customer.rb', line 8

def add_product(identifier)
  response = Vhx.connection.put do |req|
    req.url('/customers/' + self.id.to_s + '/products')
    req.body = { product: get_hypermedia(identifier, 'Product') }
  end

  self.class.new(response.body)
end

#remove_product(identifier) ⇒ Object


17
18
19
20
21
22
23
24
# File 'lib/vhx/objects/customer.rb', line 17

def remove_product(identifier)
  response = Vhx.connection.delete do |req|
    req.url('/customers/' + self.id.to_s + '/products')
    req.body = { product: get_hypermedia(identifier, 'Product') }
  end

  self.class.new(response.body)
end