class Retentiongrid::Customer
To create a new Retentiongrid::Customer
object:
customer = Retentiongrid::Customer.new(customer_id: 'C123', full_name: 'Chris Tucker').save
To get a order from the API:
customer = Retentiongrid::Customer.find('C123')
Constants
- ATTRIBUTES_NAMES
The set of attributes defined by the API documentation
- BASE_PATH
Public Class Methods
find(customer_id)
click to toggle source
Find a customer with given id @param [Fixnum] customer_id the customer id to be found @return [Customer] if found any
# File lib/retentiongrid/customer.rb, line 29 def self.find(customer_id) begin result = Api.get("#{BASE_PATH}/#{customer_id}") new(result.parsed_response["rg_customer"]) rescue NotFound nil end end
Public Instance Methods
destroy()
click to toggle source
Delete this customer at retention grid @return [Boolean] successfully deleted?
# File lib/retentiongrid/customer.rb, line 48 def destroy Api.delete("#{BASE_PATH}/#{customer_id}") true end
save!()
click to toggle source
Create or update a customer with given id @return [Customer] if successfully created or updated @raise [Httparty::Error] for all sorts of HTTP statuses.
# File lib/retentiongrid/customer.rb, line 41 def save! result = Api.post("#{BASE_PATH}/#{customer_id}", body: attributes.to_json) Customer.new(result.parsed_response["rg_customer"]) end