Class: FdxV660Api::BusinessCustomerEntity2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/business_customer_entity2.rb

Overview

The business customer information, only used if 'type' is 'BUSINESS'.

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(name: SKIP, registered_agents: SKIP, registered_id: SKIP, industry_code: SKIP, domicile: SKIP, additional_properties: nil) ⇒ BusinessCustomerEntity2

Returns a new instance of BusinessCustomerEntity2.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 60

def initialize(name: SKIP, registered_agents: SKIP, registered_id: SKIP,
               industry_code: SKIP, domicile: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name unless name == SKIP
  @registered_agents = registered_agents unless registered_agents == SKIP
  @registered_id = registered_id unless registered_id == SKIP
  @industry_code = industry_code unless industry_code == SKIP
  @domicile = domicile unless domicile == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#domicileDomicileEntity1

The country and region of the business customer's location

Returns:



31
32
33
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 31

def domicile
  @domicile
end

#industry_codeIndustryCode

Industry code and type

Returns:



27
28
29
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 27

def industry_code
  @industry_code
end

#nameString

Name of business customer

Returns:

  • (String)


14
15
16
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 14

def name
  @name
end

#registered_agentsArray[CustomerNameEntity]

A list of registered agents who act on behalf of the business customer

Returns:



18
19
20
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 18

def registered_agents
  @registered_agents
end

#registered_idString

The registered tax identification number (TIN) or other identifier of business customer

Returns:

  • (String)


23
24
25
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 23

def registered_id
  @registered_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  # Parameter is an array, so we need to iterate through it
  registered_agents = nil
  unless hash['registeredAgents'].nil?
    registered_agents = []
    hash['registeredAgents'].each do |structure|
      registered_agents << (CustomerNameEntity.from_hash(structure) if structure)
    end
  end

  registered_agents = SKIP unless hash.key?('registeredAgents')
  registered_id = hash.key?('registeredId') ? hash['registeredId'] : SKIP
  industry_code = IndustryCode.from_hash(hash['industryCode']) if hash['industryCode']
  domicile = DomicileEntity1.from_hash(hash['domicile']) if hash['domicile']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  BusinessCustomerEntity2.new(name: name,
                              registered_agents: registered_agents,
                              registered_id: registered_id,
                              industry_code: industry_code,
                              domicile: domicile,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['registered_agents'] = 'registeredAgents'
  @_hash['registered_id'] = 'registeredId'
  @_hash['industry_code'] = 'industryCode'
  @_hash['domicile'] = 'domicile'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
53
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 45

def self.optionals
  %w[
    name
    registered_agents
    registered_id
    industry_code
    domicile
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



112
113
114
115
116
117
118
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 112

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
134
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 129

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, registered_agents: #{@registered_agents.inspect},"\
  " registered_id: #{@registered_id.inspect}, industry_code: #{@industry_code.inspect},"\
  " domicile: #{@domicile.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
126
# File 'lib/fdx_v660_api/models/business_customer_entity2.rb', line 121

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, registered_agents: #{@registered_agents}, registered_id:"\
  " #{@registered_id}, industry_code: #{@industry_code}, domicile: #{@domicile},"\
  " additional_properties: #{@additional_properties}>"
end