Class: NewStoreApi::CashDetails

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

Overview

Cash-specific payment details.

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(change_amount = SKIP) ⇒ CashDetails

Returns a new instance of CashDetails.



37
38
39
# File 'lib/new_store_api/models/cash_details.rb', line 37

def initialize(change_amount = SKIP)
  @change_amount = change_amount unless change_amount == SKIP
end

Instance Attribute Details

#change_amountInteger

Change handed back to the customer, in the currency's minor unit.

Returns:

  • (Integer)


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

def change_amount
  @change_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



42
43
44
45
46
47
48
49
50
# File 'lib/new_store_api/models/cash_details.rb', line 42

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  change_amount = hash.key?('change_amount') ? hash['change_amount'] : SKIP

  # Create object from extracted values.
  CashDetails.new(change_amount)
end

.namesObject

A mapping from model property names to API property names.



17
18
19
20
21
# File 'lib/new_store_api/models/cash_details.rb', line 17

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

.nullablesObject

An array for nullable fields



31
32
33
34
35
# File 'lib/new_store_api/models/cash_details.rb', line 31

def self.nullables
  %w[
    change_amount
  ]
end

.optionalsObject

An array for optional fields



24
25
26
27
28
# File 'lib/new_store_api/models/cash_details.rb', line 24

def self.optionals
  %w[
    change_amount
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (CashDetails | Hash)

    value against the validation is performed.



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

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.



69
70
71
72
# File 'lib/new_store_api/models/cash_details.rb', line 69

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} change_amount: #{@change_amount.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



63
64
65
66
# File 'lib/new_store_api/models/cash_details.rb', line 63

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} change_amount: #{@change_amount}>"
end