Class: NewStoreApi::SignaturePtV1Dto

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

Overview

SignaturePtV1Dto 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(date = nil, fiscal_data = nil, location_id = nil, receipt_number = nil, receipt_data = SKIP) ⇒ SignaturePtV1Dto

Returns a new instance of SignaturePtV1Dto.



55
56
57
58
59
60
61
62
# File 'lib/new_store_api/models/signature_pt_v1_dto.rb', line 55

def initialize(date = nil, fiscal_data = nil, location_id = nil,
               receipt_number = nil, receipt_data = SKIP)
  @date = date
  @fiscal_data = fiscal_data
  @location_id = location_id
  @receipt_data = receipt_data unless receipt_data == SKIP
  @receipt_number = receipt_number
end

Instance Attribute Details

#dateString

Fiscalization date.

Returns:

  • (String)


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

def date
  @date
end

#fiscal_dataObject

Fiscalization data.

Returns:

  • (Object)


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

def fiscal_data
  @fiscal_data
end

#location_idString

The store location ID in EFSTA.

Returns:

  • (String)


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

def location_id
  @location_id
end

#receipt_dataString

A base64-encoded string representing the receipt data.

Returns:

  • (String)


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

def receipt_data
  @receipt_data
end

#receipt_numberString

Receipt number.

Returns:

  • (String)


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

def receipt_number
  @receipt_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  date = hash.key?('date') ? hash['date'] : nil
  fiscal_data = hash.key?('fiscal_data') ? hash['fiscal_data'] : nil
  location_id = hash.key?('location_id') ? hash['location_id'] : nil
  receipt_number =
    hash.key?('receipt_number') ? hash['receipt_number'] : nil
  receipt_data = hash.key?('receipt_data') ? hash['receipt_data'] : SKIP

  # Create object from extracted values.
  SignaturePtV1Dto.new(date,
                       fiscal_data,
                       location_id,
                       receipt_number,
                       receipt_data)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['date'] = 'date'
  @_hash['fiscal_data'] = 'fiscal_data'
  @_hash['location_id'] = 'location_id'
  @_hash['receipt_data'] = 'receipt_data'
  @_hash['receipt_number'] = 'receipt_number'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/new_store_api/models/signature_pt_v1_dto.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
# File 'lib/new_store_api/models/signature_pt_v1_dto.rb', line 44

def self.optionals
  %w[
    receipt_data
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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
# File 'lib/new_store_api/models/signature_pt_v1_dto.rb', line 86

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.date,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.fiscal_data,
                              ->(val) { val.instance_of? Object }) and
        APIHelper.valid_type?(value.location_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.receipt_number,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['date'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['fiscal_data'],
                            ->(val) { val.instance_of? Object }) and
      APIHelper.valid_type?(value['location_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['receipt_number'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



122
123
124
125
126
127
# File 'lib/new_store_api/models/signature_pt_v1_dto.rb', line 122

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} date: #{@date.inspect}, fiscal_data: #{@fiscal_data.inspect}, location_id:"\
  " #{@location_id.inspect}, receipt_data: #{@receipt_data.inspect}, receipt_number:"\
  " #{@receipt_number.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



115
116
117
118
119
# File 'lib/new_store_api/models/signature_pt_v1_dto.rb', line 115

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} date: #{@date}, fiscal_data: #{@fiscal_data}, location_id: #{@location_id},"\
  " receipt_data: #{@receipt_data}, receipt_number: #{@receipt_number}>"
end