Class: NewStoreApi::Customer

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/customer.rb

Overview

The customer placing the order.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id = nil, external_id = SKIP) ⇒ Customer

Returns a new instance of Customer.



42
43
44
45
# File 'lib/new_store_api/models/customer.rb', line 42

def initialize(id = nil, external_id = SKIP)
  @external_id = external_id unless external_id == SKIP
  @id = id
end

Instance Attribute Details

#external_idString

A reference to the customer in an external system.

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/customer.rb', line 14

def external_id
  @external_id
end

#idUUID | String

The customer's internal NewStore customer-profile UUID.

Returns:

  • (UUID | String)


18
19
20
# File 'lib/new_store_api/models/customer.rb', line 18

def id
  @id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/new_store_api/models/customer.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  external_id = hash.key?('external_id') ? hash['external_id'] : SKIP

  # Create object from extracted values.
  Customer.new(id,
               external_id)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/new_store_api/models/customer.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['external_id'] = 'external_id'
  @_hash['id'] = 'id'
  @_hash
end

.nullablesObject

An array for nullable fields



36
37
38
39
40
# File 'lib/new_store_api/models/customer.rb', line 36

def self.nullables
  %w[
    external_id
  ]
end

.optionalsObject

An array for optional fields



29
30
31
32
33
# File 'lib/new_store_api/models/customer.rb', line 29

def self.optionals
  %w[
    external_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



67
68
69
70
# File 'lib/new_store_api/models/customer.rb', line 67

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} external_id: #{@external_id.inspect}, id: #{@id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



61
62
63
64
# File 'lib/new_store_api/models/customer.rb', line 61

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} external_id: #{@external_id}, id: #{@id}>"
end