Class: NewStoreApi::SignaturePlV1Dto

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

Overview

SignaturePlV1Dto 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(commands = SKIP, counters = SKIP, serial_number = SKIP) ⇒ SignaturePlV1Dto

Returns a new instance of SignaturePlV1Dto.



47
48
49
50
51
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 47

def initialize(commands = SKIP, counters = SKIP, serial_number = SKIP)
  @commands = commands unless commands == SKIP
  @counters = counters unless counters == SKIP
  @serial_number = serial_number unless serial_number == SKIP
end

Instance Attribute Details

#commandsArray[PosnetOnlineCommandLogV1Dto]

Commands and their responses.

Returns:



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

def commands
  @commands
end

#countersPosnetOnlineCountersV1Dto

Counters after the transaction execution.



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

def counters
  @counters
end

#serial_numberString

Unique serial number of the printer that executed the transaction.

Returns:

  • (String)


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

def serial_number
  @serial_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 54

def self.from_hash(hash)
  return nil unless hash

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

  commands = SKIP unless hash.key?('commands')
  counters = PosnetOnlineCountersV1Dto.from_hash(hash['counters']) if hash['counters']
  serial_number = hash.key?('serial_number') ? hash['serial_number'] : SKIP

  # Create object from extracted values.
  SignaturePlV1Dto.new(commands,
                       counters,
                       serial_number)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['commands'] = 'commands'
  @_hash['counters'] = 'counters'
  @_hash['serial_number'] = 'serial_number'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 34

def self.optionals
  %w[
    commands
    counters
    serial_number
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



79
80
81
82
83
84
85
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 79

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.



95
96
97
98
99
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 95

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} commands: #{@commands.inspect}, counters: #{@counters.inspect},"\
  " serial_number: #{@serial_number.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



88
89
90
91
92
# File 'lib/new_store_api/models/signature_pl_v1_dto.rb', line 88

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} commands: #{@commands}, counters: #{@counters}, serial_number:"\
  " #{@serial_number}>"
end