Class: NewStoreApi::SignatureNoV1Dto

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

Overview

SignatureNoV1Dto 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(cash_register_id = nil, digital_signature = nil, environment = nil, key_version = nil) ⇒ SignatureNoV1Dto

Returns a new instance of SignatureNoV1Dto.



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

def initialize(cash_register_id = nil, digital_signature = nil,
               environment = nil, key_version = nil)
  @cash_register_id = cash_register_id
  @digital_signature = digital_signature
  @environment = environment
  @key_version = key_version
end

Instance Attribute Details

#cash_register_idString

Cash register identifier.

  • The ID of the cash register is an auto-generated field and it should not be sent while creating a store.
  • Following format is used for the auto-generated cash register identifier: {firstTwoCharactersOfTheTenant}-{storeId}

Returns:

  • (String)


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

def cash_register_id
  @cash_register_id
end

#digital_signatureString

Locally generated signature, part of the chain maintained in the e-journal.

Returns:

  • (String)


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

def digital_signature
  @digital_signature
end

#environmentFiscalEnvironmentEnum

Locally generated signature, part of the chain maintained in the e-journal.



28
29
30
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 28

def environment
  @environment
end

#key_versionString

The RSA key version.

Returns:

  • (String)


32
33
34
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 32

def key_version
  @key_version
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  cash_register_id =
    hash.key?('cash_register_id') ? hash['cash_register_id'] : nil
  digital_signature =
    hash.key?('digital_signature') ? hash['digital_signature'] : nil
  environment = hash.key?('environment') ? hash['environment'] : nil
  key_version = hash.key?('key_version') ? hash['key_version'] : nil

  # Create object from extracted values.
  SignatureNoV1Dto.new(cash_register_id,
                       digital_signature,
                       environment,
                       key_version)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cash_register_id'] = 'cash_register_id'
  @_hash['digital_signature'] = 'digital_signature'
  @_hash['environment'] = 'environment'
  @_hash['key_version'] = 'key_version'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 45

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



83
84
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
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 83

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.cash_register_id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.digital_signature,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.environment,
                              ->(val) { FiscalEnvironmentEnum.validate(val) }) and
        APIHelper.valid_type?(value.key_version,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['cash_register_id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['digital_signature'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['environment'],
                            ->(val) { FiscalEnvironmentEnum.validate(val) }) and
      APIHelper.valid_type?(value['key_version'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



119
120
121
122
123
124
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 119

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cash_register_id: #{@cash_register_id.inspect}, digital_signature:"\
  " #{@digital_signature.inspect}, environment: #{@environment.inspect}, key_version:"\
  " #{@key_version.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



112
113
114
115
116
# File 'lib/new_store_api/models/signature_no_v1_dto.rb', line 112

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cash_register_id: #{@cash_register_id}, digital_signature:"\
  " #{@digital_signature}, environment: #{@environment}, key_version: #{@key_version}>"
end