Class: NewStoreApi::SalesOrderCustomer

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

Overview

SalesOrderCustomer Model.

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(email = SKIP, id = SKIP, language = SKIP, name = SKIP) ⇒ SalesOrderCustomer

Returns a new instance of SalesOrderCustomer.



54
55
56
57
58
59
# File 'lib/new_store_api/models/sales_order_customer.rb', line 54

def initialize(email = SKIP, id = SKIP, language = SKIP, name = SKIP)
  @email = email unless email == SKIP
  @id = id unless id == SKIP
  @language = language unless language == SKIP
  @name = name unless name == SKIP
end

Instance Attribute Details

#emailString

The email address of the customer.

Returns:

  • (String)


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

def email
  @email
end

#idString

The identifier of the customer.

Returns:

  • (String)


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

def id
  @id
end

#languageString

The code of the language to be used in communicating with the customer in ISO 639-1 format, e.g. fr, de or en.

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/sales_order_customer.rb', line 23

def language
  @language
end

#nameString

The full name of the customer.

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/sales_order_customer.rb', line 27

def name
  @name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/new_store_api/models/sales_order_customer.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  email = hash.key?('email') ? hash['email'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  language = hash.key?('language') ? hash['language'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP

  # Create object from extracted values.
  SalesOrderCustomer.new(email,
                         id,
                         language,
                         name)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/new_store_api/models/sales_order_customer.rb', line 30

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

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/new_store_api/models/sales_order_customer.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/new_store_api/models/sales_order_customer.rb', line 40

def self.optionals
  %w[
    email
    id
    language
    name
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
# File 'lib/new_store_api/models/sales_order_customer.rb', line 85

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

#to_sObject

Provides a human-readable string representation of the object.



79
80
81
82
# File 'lib/new_store_api/models/sales_order_customer.rb', line 79

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