Class: Batches::HostBreakdownItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/batches/models/host_breakdown_item.rb

Overview

HostBreakdownItem 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(merchant_name: SKIP, reference: SKIP, amount: SKIP, count: SKIP, funding_debit: SKIP, funding_credit: SKIP, additional_properties: nil) ⇒ HostBreakdownItem

Returns a new instance of HostBreakdownItem.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/batches/models/host_breakdown_item.rb', line 67

def initialize(merchant_name: SKIP, reference: SKIP, amount: SKIP,
               count: SKIP, funding_debit: SKIP, funding_credit: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @merchant_name = merchant_name unless merchant_name == SKIP
  @reference = reference unless reference == SKIP
  @amount = amount unless amount == SKIP
  @count = count unless count == SKIP
  @funding_debit = funding_debit unless funding_debit == SKIP
  @funding_credit = funding_credit unless funding_credit == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

The batch amount that is an aggregation of all the transactions' amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:

  • (String)


24
25
26
# File 'lib/batches/models/host_breakdown_item.rb', line 24

def amount
  @amount
end

#countFloat

The number of transactions in the batch.

Returns:

  • (Float)


28
29
30
# File 'lib/batches/models/host_breakdown_item.rb', line 28

def count
  @count
end

#funding_creditFundingCredit5

The number of transactions in the batch.

Returns:



36
37
38
# File 'lib/batches/models/host_breakdown_item.rb', line 36

def funding_credit
  @funding_credit
end

#funding_debitFundingDebit5

The number of transactions in the batch.

Returns:



32
33
34
# File 'lib/batches/models/host_breakdown_item.rb', line 32

def funding_debit
  @funding_debit
end

#merchant_nameString

The merchant name that is associated with the batch.

Returns:

  • (String)


14
15
16
# File 'lib/batches/models/host_breakdown_item.rb', line 14

def merchant_name
  @merchant_name
end

#referenceString

A reference for the batch from the host.

Returns:

  • (String)


18
19
20
# File 'lib/batches/models/host_breakdown_item.rb', line 18

def reference
  @reference
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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/batches/models/host_breakdown_item.rb', line 83

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  merchant_name = hash.key?('merchant_name') ? hash['merchant_name'] : SKIP
  reference = hash.key?('reference') ? hash['reference'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  count = hash.key?('count') ? hash['count'] : SKIP
  funding_debit = FundingDebit5.from_hash(hash['funding_debit']) if hash['funding_debit']
  funding_credit = FundingCredit5.from_hash(hash['funding_credit']) if hash['funding_credit']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  HostBreakdownItem.new(merchant_name: merchant_name,
                        reference: reference,
                        amount: amount,
                        count: count,
                        funding_debit: funding_debit,
                        funding_credit: funding_credit,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/batches/models/host_breakdown_item.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['merchant_name'] = 'merchant_name'
  @_hash['reference'] = 'reference'
  @_hash['amount'] = 'amount'
  @_hash['count'] = 'count'
  @_hash['funding_debit'] = 'funding_debit'
  @_hash['funding_credit'] = 'funding_credit'
  @_hash
end

.nullablesObject

An array for nullable fields



63
64
65
# File 'lib/batches/models/host_breakdown_item.rb', line 63

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
57
58
59
60
# File 'lib/batches/models/host_breakdown_item.rb', line 51

def self.optionals
  %w[
    merchant_name
    reference
    amount
    count
    funding_debit
    funding_credit
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



120
121
122
123
124
125
126
# File 'lib/batches/models/host_breakdown_item.rb', line 120

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} merchant_name: #{@merchant_name.inspect}, reference: #{@reference.inspect},"\
  " amount: #{@amount.inspect}, count: #{@count.inspect}, funding_debit:"\
  " #{@funding_debit.inspect}, funding_credit: #{@funding_credit.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



112
113
114
115
116
117
# File 'lib/batches/models/host_breakdown_item.rb', line 112

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} merchant_name: #{@merchant_name}, reference: #{@reference}, amount:"\
  " #{@amount}, count: #{@count}, funding_debit: #{@funding_debit}, funding_credit:"\
  " #{@funding_credit}, additional_properties: #{@additional_properties}>"
end