Class: NewStoreApi::VertexConfigDto

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

Overview

VertexConfigDto 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(company_code = nil, login_type = nil, soap_url = nil, administrative_origin = SKIP, division_code = SKIP, exemption_classes = SKIP, flexible_fields = SKIP, jurisdiction_in_tax_name_enabled = SKIP, password = SKIP, trusted_id = SKIP, use_location_code = false, username = SKIP) ⇒ VertexConfigDto

Returns a new instance of VertexConfigDto.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 127

def initialize(company_code = nil,  = nil, soap_url = nil,
               administrative_origin = SKIP, division_code = SKIP,
               exemption_classes = SKIP, flexible_fields = SKIP,
               jurisdiction_in_tax_name_enabled = SKIP, password = SKIP,
               trusted_id = SKIP, use_location_code = false,
               username = SKIP)
  @administrative_origin = administrative_origin unless administrative_origin == SKIP
  @company_code = company_code
  @division_code = division_code unless division_code == SKIP
  @exemption_classes = exemption_classes unless exemption_classes == SKIP
  @flexible_fields = flexible_fields unless flexible_fields == SKIP
  unless jurisdiction_in_tax_name_enabled == SKIP
    @jurisdiction_in_tax_name_enabled =
      jurisdiction_in_tax_name_enabled
  end
  @login_type = 
  @password = password unless password == SKIP
  @soap_url = soap_url
  @trusted_id = trusted_id unless trusted_id == SKIP
  @use_location_code = use_location_code unless use_location_code == SKIP
  @username = username unless username == SKIP
end

Instance Attribute Details

#administrative_originVertexAdministrativeOriginDto

Administrative origin information of the legal entity. Should be set based on the retailer corporate information.



15
16
17
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 15

def administrative_origin
  @administrative_origin
end

#company_codeString

Vertex taxpayer code of the company.

  • Identifies the top-level legal entity (company).
  • The value should be set to the taxpayer code of the top-level taxpayer (company).

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 22

def company_code
  @company_code
end

#division_codeString

Vertex taxpayer code of the division.

  • Identifies the mid-level legal entity (division) under a top-level legal entity (company).
  • If exists, the value can be set to the taxpayer code of the mid-level taxpayer (division) under a top-level taxpayer (company).

Returns:

  • (String)


30
31
32
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 30

def division_code
  @division_code
end

#exemption_classesArray[VertexExemptionClassItemDto]

A list of mappings between ExemptionClass enum and Vertex class codes.

Returns:



34
35
36
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 34

def exemption_classes
  @exemption_classes
end

#flexible_fieldsArray[VertexFlexibleFieldConfigDto]

The mapping between extended attributes of items in the NewStore platform and flexible fields as defined in Vertex.

Returns:



39
40
41
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 39

def flexible_fields
  @flexible_fields
end

#jurisdiction_in_tax_name_enabledTrueClass | FalseClass

Enable appending the jurisdiction name to the tax line's tax_name field.

  • This can help identify which jurisdiction imposed a given tax line.
  • Example: The tax name Sales And Use Tax - Colorado includes the jurisdiction name Colorado when the given flag is enabled.

Returns:

  • (TrueClass | FalseClass)


46
47
48
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 46

def jurisdiction_in_tax_name_enabled
  @jurisdiction_in_tax_name_enabled
end

#login_typeVertexAuthLoginTypeEnum

Enable appending the jurisdiction name to the tax line's tax_name field.

  • This can help identify which jurisdiction imposed a given tax line.
  • Example: The tax name Sales And Use Tax - Colorado includes the jurisdiction name Colorado when the given flag is enabled.


53
54
55
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 53

def 
  @login_type
end

#passwordString

Password of the Vertex account.

  • Required if login_type is set to user_and_password.

Returns:

  • (String)


58
59
60
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 58

def password
  @password
end

#soap_urlString

SOAP URL of the Vertex CalculateTax endpoint.

Returns:

  • (String)


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

def soap_url
  @soap_url
end

#trusted_idString

Trusted ID of the Vertex account.

  • Required if login_type is set to trusted_id.

Returns:

  • (String)


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

def trusted_id
  @trusted_id
end

#use_location_codeTrueClass | FalseClass

Use Vertex location code instead of address information.

  • When this value is set to true the NewStore platform will use the Store IDs to communicate origin and destination addresses instead of using standard address information (address line 1, postal code, etc.).
  • Store IDs are currently only available for cash & carry orders, all other order scenarios will use the standard address information to communicate origin and destination addresses even with this value set to true.
  • In case the NewStore Store ID length is longer than 20 characters, NewStore will only send the first 20 characters as Vertex field length is capped at that limit.

Returns:

  • (TrueClass | FalseClass)


81
82
83
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 81

def use_location_code
  @use_location_code
end

#usernameString

Username of the Vertex account.

  • Required if login_type is set to user_and_password.

Returns:

  • (String)


86
87
88
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 86

def username
  @username
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 151

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  company_code = hash.key?('company_code') ? hash['company_code'] : nil
   = hash.key?('login_type') ? hash['login_type'] : nil
  soap_url = hash.key?('soap_url') ? hash['soap_url'] : nil
  if hash['administrative_origin']
    administrative_origin = VertexAdministrativeOriginDto.from_hash(hash['administrative_origin'])
  end
  division_code = hash.key?('division_code') ? hash['division_code'] : SKIP
  # Parameter is an array, so we need to iterate through it
  exemption_classes = nil
  unless hash['exemption_classes'].nil?
    exemption_classes = []
    hash['exemption_classes'].each do |structure|
      exemption_classes << (VertexExemptionClassItemDto.from_hash(structure) if structure)
    end
  end

  exemption_classes = SKIP unless hash.key?('exemption_classes')
  # Parameter is an array, so we need to iterate through it
  flexible_fields = nil
  unless hash['flexible_fields'].nil?
    flexible_fields = []
    hash['flexible_fields'].each do |structure|
      flexible_fields << (VertexFlexibleFieldConfigDto.from_hash(structure) if structure)
    end
  end

  flexible_fields = SKIP unless hash.key?('flexible_fields')
  jurisdiction_in_tax_name_enabled =
    hash.key?('jurisdiction_in_tax_name_enabled') ? hash['jurisdiction_in_tax_name_enabled'] : SKIP
  password = hash.key?('password') ? hash['password'] : SKIP
  trusted_id = hash.key?('trusted_id') ? hash['trusted_id'] : SKIP
  use_location_code = hash['use_location_code'] ||= false
  username = hash.key?('username') ? hash['username'] : SKIP

  # Create object from extracted values.
  VertexConfigDto.new(company_code,
                      ,
                      soap_url,
                      administrative_origin,
                      division_code,
                      exemption_classes,
                      flexible_fields,
                      jurisdiction_in_tax_name_enabled,
                      password,
                      trusted_id,
                      use_location_code,
                      username)
end

.namesObject

A mapping from model property names to API property names.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 89

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['administrative_origin'] = 'administrative_origin'
  @_hash['company_code'] = 'company_code'
  @_hash['division_code'] = 'division_code'
  @_hash['exemption_classes'] = 'exemption_classes'
  @_hash['flexible_fields'] = 'flexible_fields'
  @_hash['jurisdiction_in_tax_name_enabled'] =
    'jurisdiction_in_tax_name_enabled'
  @_hash['login_type'] = 'login_type'
  @_hash['password'] = 'password'
  @_hash['soap_url'] = 'soap_url'
  @_hash['trusted_id'] = 'trusted_id'
  @_hash['use_location_code'] = 'use_location_code'
  @_hash['username'] = 'username'
  @_hash
end

.nullablesObject

An array for nullable fields



123
124
125
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 123

def self.nullables
  []
end

.optionalsObject

An array for optional fields



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 108

def self.optionals
  %w[
    administrative_origin
    division_code
    exemption_classes
    flexible_fields
    jurisdiction_in_tax_name_enabled
    password
    trusted_id
    use_location_code
    username
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (VertexConfigDto | Hash)

    value against the validation is performed.



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 206

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.company_code,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.,
                              ->(val) { VertexAuthLoginTypeEnum.validate(val) }) and
        APIHelper.valid_type?(value.soap_url,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['company_code'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['login_type'],
                            ->(val) { VertexAuthLoginTypeEnum.validate(val) }) and
      APIHelper.valid_type?(value['soap_url'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



242
243
244
245
246
247
248
249
250
251
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 242

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} administrative_origin: #{@administrative_origin.inspect}, company_code:"\
  " #{@company_code.inspect}, division_code: #{@division_code.inspect}, exemption_classes:"\
  " #{@exemption_classes.inspect}, flexible_fields: #{@flexible_fields.inspect},"\
  " jurisdiction_in_tax_name_enabled: #{@jurisdiction_in_tax_name_enabled.inspect},"\
  " login_type: #{@login_type.inspect}, password: #{@password.inspect}, soap_url:"\
  " #{@soap_url.inspect}, trusted_id: #{@trusted_id.inspect}, use_location_code:"\
  " #{@use_location_code.inspect}, username: #{@username.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



231
232
233
234
235
236
237
238
239
# File 'lib/new_store_api/models/vertex_config_dto.rb', line 231

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} administrative_origin: #{@administrative_origin}, company_code:"\
  " #{@company_code}, division_code: #{@division_code}, exemption_classes:"\
  " #{@exemption_classes}, flexible_fields: #{@flexible_fields},"\
  " jurisdiction_in_tax_name_enabled: #{@jurisdiction_in_tax_name_enabled}, login_type:"\
  " #{@login_type}, password: #{@password}, soap_url: #{@soap_url}, trusted_id:"\
  " #{@trusted_id}, use_location_code: #{@use_location_code}, username: #{@username}>"
end