Class: NewStoreApi::CashDenominationDto

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

Overview

CashDenominationDto 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(value = nil, default_label = SKIP, localized_labels = SKIP) ⇒ CashDenominationDto

Returns a new instance of CashDenominationDto.



49
50
51
52
53
# File 'lib/new_store_api/models/cash_denomination_dto.rb', line 49

def initialize(value = nil, default_label = SKIP, localized_labels = SKIP)
  @default_label = default_label unless default_label == SKIP
  @localized_labels = localized_labels unless localized_labels == SKIP
  @value = value
end

Instance Attribute Details

#default_labelString

Default label of the denomination.

Returns:

  • (String)


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

def default_label
  @default_label
end

#localized_labelsObject

Labels of the denomination for the supported language code(s).

  • Key is a ISO 639-1 language code.
  • Will be set if the given denomination is represented differently in supported languages.

Returns:

  • (Object)


21
22
23
# File 'lib/new_store_api/models/cash_denomination_dto.rb', line 21

def localized_labels
  @localized_labels
end

#valueFloat

Value of the denomination.

Returns:

  • (Float)


25
26
27
# File 'lib/new_store_api/models/cash_denomination_dto.rb', line 25

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/new_store_api/models/cash_denomination_dto.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  value = hash.key?('value') ? hash['value'] : nil
  default_label = hash.key?('default_label') ? hash['default_label'] : SKIP
  localized_labels =
    hash.key?('localized_labels') ? hash['localized_labels'] : SKIP

  # Create object from extracted values.
  CashDenominationDto.new(value,
                          default_label,
                          localized_labels)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/new_store_api/models/cash_denomination_dto.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['default_label'] = 'default_label'
  @_hash['localized_labels'] = 'localized_labels'
  @_hash['value'] = 'value'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    default_label
    localized_labels
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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

#to_sObject

Provides a human-readable string representation of the object.



72
73
74
75
76
# File 'lib/new_store_api/models/cash_denomination_dto.rb', line 72

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