Class: NewStoreApi::CashboxConfigEpsonItV1Dto

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

Overview

CashboxConfigEpsonItV1Dto 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(hostname = nil, port = nil, printer_model = nil, name = SKIP) ⇒ CashboxConfigEpsonItV1Dto

Returns a new instance of CashboxConfigEpsonItV1Dto.



50
51
52
53
54
55
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 50

def initialize(hostname = nil, port = nil, printer_model = nil, name = SKIP)
  @hostname = hostname
  @name = name unless name == SKIP
  @port = port
  @printer_model = printer_model
end

Instance Attribute Details

#hostnameString

Hostname or the IP address of the Epson RT fiscal printer.

Returns:

  • (String)


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

def hostname
  @hostname
end

#nameString

Name of the fiscal printer

Returns:

  • (String)


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

def name
  @name
end

#portInteger

Port of the Epson RT fiscal printer.

Returns:

  • (Integer)


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

def port
  @port
end

#printer_modelEpsonPrinterModelEnum

Port of the Epson RT fiscal printer.



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

def printer_model
  @printer_model
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  hostname = hash.key?('hostname') ? hash['hostname'] : nil
  port = hash.key?('port') ? hash['port'] : nil
  printer_model = hash.key?('printer_model') ? hash['printer_model'] : nil
  name = hash.key?('name') ? hash['name'] : SKIP

  # Create object from extracted values.
  CashboxConfigEpsonItV1Dto.new(hostname,
                                port,
                                printer_model,
                                name)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['hostname'] = 'hostname'
  @_hash['name'] = 'name'
  @_hash['port'] = 'port'
  @_hash['printer_model'] = 'printer_model'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 39

def self.optionals
  %w[
    name
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 76

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.hostname,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.port,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.printer_model,
                              ->(val) { EpsonPrinterModelEnum.validate(val) })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['hostname'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['port'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['printer_model'],
                            ->(val) { EpsonPrinterModelEnum.validate(val) })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



108
109
110
111
112
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 108

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

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
# File 'lib/new_store_api/models/cashbox_config_epson_it_v1_dto.rb', line 101

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