Class: NewStoreApi::CashboxConfigNewstoreNoV1Dto

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

Overview

CashboxConfigNewstoreNoV1Dto 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_id = nil, store_address = nil, tax_reg_id = nil, tenant_address = nil, cash_register_id = SKIP) ⇒ CashboxConfigNewstoreNoV1Dto

Returns a new instance of CashboxConfigNewstoreNoV1Dto.



65
66
67
68
69
70
71
72
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 65

def initialize(company_id = nil, store_address = nil, tax_reg_id = nil,
               tenant_address = nil, cash_register_id = SKIP)
  @cash_register_id = cash_register_id unless cash_register_id == SKIP
  @company_id = company_id
  @store_address = store_address
  @tax_reg_id = tax_reg_id
  @tenant_address = tenant_address
end

Instance Attribute Details

#cash_register_idString

Cash register identifier.

  • An auto-generated field, which should not be sent during activations.
  • The identifier is generated by getting combining the first 2 characters of the tenant identifier and the first 15 characters of the cashbox identifier.

Returns:

  • (String)


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

def cash_register_id
  @cash_register_id
end

#company_idString

Identifier of the legal entity.

  • Organization number from The Brønnøysund Register Centre (Brønnøysundregistrene) or other relevant government authority.
  • In case of one person business without organization number, the social security number can be used.

Returns:

  • (String)


26
27
28
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 26

def company_id
  @company_id
end

#store_addressAddressDataNoV1Dto

Address of the store.

Returns:



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

def store_address
  @store_address
end

#tax_reg_idString

VAT (MVA) number of the legal entity.

  • This is the unique number/organization number from The Brønnøysund Register Centre (Brønnøysundregistrene).

Returns:

  • (String)


36
37
38
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 36

def tax_reg_id
  @tax_reg_id
end

#tenant_addressAddressDataNoV1Dto

Address of the legal entity.

Returns:



40
41
42
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 40

def tenant_address
  @tenant_address
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
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  company_id = hash.key?('company_id') ? hash['company_id'] : nil
  store_address = AddressDataNoV1Dto.from_hash(hash['store_address']) if hash['store_address']
  tax_reg_id = hash.key?('tax_reg_id') ? hash['tax_reg_id'] : nil
  tenant_address = AddressDataNoV1Dto.from_hash(hash['tenant_address']) if
    hash['tenant_address']
  cash_register_id =
    hash.key?('cash_register_id') ? hash['cash_register_id'] : SKIP

  # Create object from extracted values.
  CashboxConfigNewstoreNoV1Dto.new(company_id,
                                   store_address,
                                   tax_reg_id,
                                   tenant_address,
                                   cash_register_id)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cash_register_id'] = 'cash_register_id'
  @_hash['company_id'] = 'company_id'
  @_hash['store_address'] = 'store_address'
  @_hash['tax_reg_id'] = 'tax_reg_id'
  @_hash['tenant_address'] = 'tenant_address'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    cash_register_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 97

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.company_id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.store_address,
                              ->(val) { AddressDataNoV1Dto.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.tax_reg_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.tenant_address,
                              ->(val) { AddressDataNoV1Dto.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['company_id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['store_address'],
                            ->(val) { AddressDataNoV1Dto.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['tax_reg_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['tenant_address'],
                            ->(val) { AddressDataNoV1Dto.validate(val) },
                            is_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



138
139
140
141
142
143
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 138

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cash_register_id: #{@cash_register_id.inspect}, company_id:"\
  " #{@company_id.inspect}, store_address: #{@store_address.inspect}, tax_reg_id:"\
  " #{@tax_reg_id.inspect}, tenant_address: #{@tenant_address.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



130
131
132
133
134
135
# File 'lib/new_store_api/models/cashbox_config_newstore_no_v1_dto.rb', line 130

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cash_register_id: #{@cash_register_id}, company_id: #{@company_id},"\
  " store_address: #{@store_address}, tax_reg_id: #{@tax_reg_id}, tenant_address:"\
  " #{@tenant_address}>"
end