Class: NewStoreApi::TransactionMinV1Dto

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

Overview

TransactionMinV1Dto 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(country_code = nil, id = nil, state = nil, temporary_signature = nil, transaction_number = nil, type = nil, signature = SKIP, transaction_series = SKIP) ⇒ TransactionMinV1Dto

Returns a new instance of TransactionMinV1Dto.



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 71

def initialize(country_code = nil, id = nil, state = nil,
               temporary_signature = nil, transaction_number = nil,
               type = nil, signature = SKIP, transaction_series = SKIP)
  @country_code = country_code
  @id = id
  @signature = signature unless signature == SKIP
  @state = state
  @temporary_signature = temporary_signature
  @transaction_number = transaction_number
  @transaction_series = transaction_series unless transaction_series == SKIP
  @type = type
end

Instance Attribute Details

#country_codeString

TODO: Write general description for this method

Returns:

  • (String)


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

def country_code
  @country_code
end

#idString

Transaction ID.

Returns:

  • (String)


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

def id
  @id
end

#signatureObject

Transaction signature.

Returns:

  • (Object)


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

def signature
  @signature
end

#stateTransactionStateEnum

Transaction signature.



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

def state
  @state
end

#temporary_signatureObject

Temporary transaction signature.

Returns:

  • (Object)


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

def temporary_signature
  @temporary_signature
end

#transaction_numberInteger

Sequential transaction number.

Returns:

  • (Integer)


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

def transaction_number
  @transaction_number
end

#transaction_seriesString

Transaction series (if defined).

Returns:

  • (String)


38
39
40
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 38

def transaction_series
  @transaction_series
end

#typeF11nTransactionTypeEnum

Transaction series (if defined).



42
43
44
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 42

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  country_code = hash.key?('country_code') ? hash['country_code'] : nil
  id = hash.key?('id') ? hash['id'] : nil
  state = hash.key?('state') ? hash['state'] : nil
  temporary_signature = hash.key?('temporary_signature') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:TransactionMinV1DtoTemporarySignature), hash['temporary_signature']
  ) : nil
  transaction_number =
    hash.key?('transaction_number') ? hash['transaction_number'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  signature = hash.key?('signature') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:TransactionMinV1DtoSignature), hash['signature']
  ) : SKIP
  transaction_series =
    hash.key?('transaction_series') ? hash['transaction_series'] : SKIP

  # Create object from extracted values.
  TransactionMinV1Dto.new(country_code,
                          id,
                          state,
                          temporary_signature,
                          transaction_number,
                          type,
                          signature,
                          transaction_series)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['country_code'] = 'country_code'
  @_hash['id'] = 'id'
  @_hash['signature'] = 'signature'
  @_hash['state'] = 'state'
  @_hash['temporary_signature'] = 'temporary_signature'
  @_hash['transaction_number'] = 'transaction_number'
  @_hash['transaction_series'] = 'transaction_series'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 59

def self.optionals
  %w[
    signature
    transaction_series
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



117
118
119
120
121
122
123
124
125
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
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 117

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.country_code,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.state,
                              ->(val) { TransactionStateEnum.validate(val) }) and
        UnionTypeLookUp.get(:TransactionMinV1DtoTemporarySignature)
                       .validate(value.temporary_signature) and
        APIHelper.valid_type?(value.transaction_number,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.type,
                              ->(val) { F11nTransactionTypeEnum.validate(val) })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['country_code'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['state'],
                            ->(val) { TransactionStateEnum.validate(val) }) and
      UnionTypeLookUp.get(:TransactionMinV1DtoTemporarySignature)
                     .validate(value['temporary_signature']) and
      APIHelper.valid_type?(value['transaction_number'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { F11nTransactionTypeEnum.validate(val) })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



162
163
164
165
166
167
168
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 162

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} country_code: #{@country_code.inspect}, id: #{@id.inspect}, signature:"\
  " #{@signature.inspect}, state: #{@state.inspect}, temporary_signature:"\
  " #{@temporary_signature.inspect}, transaction_number: #{@transaction_number.inspect},"\
  " transaction_series: #{@transaction_series.inspect}, type: #{@type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



154
155
156
157
158
159
# File 'lib/new_store_api/models/transaction_min_v1_dto.rb', line 154

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} country_code: #{@country_code}, id: #{@id}, signature: #{@signature},"\
  " state: #{@state}, temporary_signature: #{@temporary_signature}, transaction_number:"\
  " #{@transaction_number}, transaction_series: #{@transaction_series}, type: #{@type}>"
end