Class: NewStoreApi::SignatureResponseV1Dto

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

Overview

SignatureResponseV1Dto 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(context = nil, country_code = nil, created_at = nil, id = nil, state = nil, transactions = nil, updated_at = nil, external_order_id = SKIP, fiscal_mode = SKIP, original_created_at = SKIP, reference_order_id = SKIP, signature_strategy_override = SKIP, tax_method = SKIP) ⇒ SignatureResponseV1Dto

Returns a new instance of SignatureResponseV1Dto.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 102

def initialize(context = nil, country_code = nil, created_at = nil,
               id = nil, state = nil, transactions = nil, updated_at = nil,
               external_order_id = SKIP, fiscal_mode = SKIP,
               original_created_at = SKIP, reference_order_id = SKIP,
               signature_strategy_override = SKIP, tax_method = SKIP)
  @context = context
  @country_code = country_code
  @created_at = created_at
  @external_order_id = external_order_id unless external_order_id == SKIP
  @fiscal_mode = fiscal_mode unless fiscal_mode == SKIP
  @id = id
  @original_created_at = original_created_at unless original_created_at == SKIP
  @reference_order_id = reference_order_id unless reference_order_id == SKIP
  unless signature_strategy_override == SKIP
    @signature_strategy_override =
      signature_strategy_override
  end
  @state = state
  @tax_method = tax_method unless tax_method == SKIP
  @transactions = transactions
  @updated_at = updated_at
end

Instance Attribute Details

#contextContextV1Dto

Context.

Returns:



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

def context
  @context
end

#country_codeString

Context.

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 19

def country_code
  @country_code
end

#created_atDateTime

Signature creation timestamp to be used on the receipt.

Returns:

  • (DateTime)


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

def created_at
  @created_at
end

#external_order_idString

Sales order identifier used in external system.

Returns:

  • (String)


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

def external_order_id
  @external_order_id
end

#fiscal_modeFiscalModeEnum

Sales order identifier used in external system.

Returns:



31
32
33
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 31

def fiscal_mode
  @fiscal_mode
end

#idString

ID (idempotency key).

Returns:

  • (String)


35
36
37
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 35

def id
  @id
end

#original_created_atString

Transaction creation timestamp.

  • If set, will override the fiscal transaction timestamp.

Returns:

  • (String)


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

def original_created_at
  @original_created_at
end

#reference_order_idString

ID of a reference order (e.g. referencing an original order).

Returns:

  • (String)


44
45
46
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 44

def reference_order_id
  @reference_order_id
end

#signature_strategy_overrideTransactionSignatureStrategyEnum

ID of a reference order (e.g. referencing an original order).



48
49
50
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 48

def signature_strategy_override
  @signature_strategy_override
end

#stateOrderManagementStateEnum

ID of a reference order (e.g. referencing an original order).



52
53
54
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 52

def state
  @state
end

#tax_methodF11nTaxMethodEnum

ID of a reference order (e.g. referencing an original order).

Returns:



56
57
58
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 56

def tax_method
  @tax_method
end

#transactionsArray[TransactionMinV1Dto]

ID of a reference order (e.g. referencing an original order).

Returns:



60
61
62
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 60

def transactions
  @transactions
end

#updated_atDateTime

Signature update timestamp.

Returns:

  • (DateTime)


64
65
66
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 64

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 126

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  context = ContextV1Dto.from_hash(hash['context']) if hash['context']
  country_code = hash.key?('country_code') ? hash['country_code'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  id = hash.key?('id') ? hash['id'] : nil
  state = hash.key?('state') ? hash['state'] : nil
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (TransactionMinV1Dto.from_hash(structure) if structure)
    end
  end

  transactions = nil unless hash.key?('transactions')
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               end
  external_order_id =
    hash.key?('external_order_id') ? hash['external_order_id'] : SKIP
  fiscal_mode = hash.key?('fiscal_mode') ? hash['fiscal_mode'] : SKIP
  original_created_at =
    hash.key?('original_created_at') ? hash['original_created_at'] : SKIP
  reference_order_id =
    hash.key?('reference_order_id') ? hash['reference_order_id'] : SKIP
  signature_strategy_override =
    hash.key?('signature_strategy_override') ? hash['signature_strategy_override'] : SKIP
  tax_method = hash.key?('tax_method') ? hash['tax_method'] : SKIP

  # Create object from extracted values.
  SignatureResponseV1Dto.new(context,
                             country_code,
                             created_at,
                             id,
                             state,
                             transactions,
                             updated_at,
                             external_order_id,
                             fiscal_mode,
                             original_created_at,
                             reference_order_id,
                             signature_strategy_override,
                             tax_method)
end

.namesObject

A mapping from model property names to API property names.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 67

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['context'] = 'context'
  @_hash['country_code'] = 'country_code'
  @_hash['created_at'] = 'created_at'
  @_hash['external_order_id'] = 'external_order_id'
  @_hash['fiscal_mode'] = 'fiscal_mode'
  @_hash['id'] = 'id'
  @_hash['original_created_at'] = 'original_created_at'
  @_hash['reference_order_id'] = 'reference_order_id'
  @_hash['signature_strategy_override'] = 'signature_strategy_override'
  @_hash['state'] = 'state'
  @_hash['tax_method'] = 'tax_method'
  @_hash['transactions'] = 'transactions'
  @_hash['updated_at'] = 'updated_at'
  @_hash
end

.nullablesObject

An array for nullable fields



98
99
100
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 98

def self.nullables
  []
end

.optionalsObject

An array for optional fields



86
87
88
89
90
91
92
93
94
95
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 86

def self.optionals
  %w[
    external_order_id
    fiscal_mode
    original_created_at
    reference_order_id
    signature_strategy_override
    tax_method
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



197
198
199
200
201
202
203
204
205
206
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 197

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} context: #{@context.inspect}, country_code: #{@country_code.inspect},"\
  " created_at: #{@created_at.inspect}, external_order_id: #{@external_order_id.inspect},"\
  " fiscal_mode: #{@fiscal_mode.inspect}, id: #{@id.inspect}, original_created_at:"\
  " #{@original_created_at.inspect}, reference_order_id: #{@reference_order_id.inspect},"\
  " signature_strategy_override: #{@signature_strategy_override.inspect}, state:"\
  " #{@state.inspect}, tax_method: #{@tax_method.inspect}, transactions:"\
  " #{@transactions.inspect}, updated_at: #{@updated_at.inspect}>"
end

#to_custom_created_atObject



177
178
179
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 177

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



181
182
183
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 181

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



186
187
188
189
190
191
192
193
194
# File 'lib/new_store_api/models/signature_response_v1_dto.rb', line 186

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} context: #{@context}, country_code: #{@country_code}, created_at:"\
  " #{@created_at}, external_order_id: #{@external_order_id}, fiscal_mode: #{@fiscal_mode},"\
  " id: #{@id}, original_created_at: #{@original_created_at}, reference_order_id:"\
  " #{@reference_order_id}, signature_strategy_override: #{@signature_strategy_override},"\
  " state: #{@state}, tax_method: #{@tax_method}, transactions: #{@transactions}, updated_at:"\
  " #{@updated_at}>"
end