Class: Batches::BrandBreakdownItem

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

Overview

BrandBreakdownItem 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(brand: SKIP, amount: SKIP, count: SKIP, gratuity_amount: SKIP, sales: SKIP, refunds: SKIP, funding_debit: SKIP, funding_credit: SKIP, additional_properties: nil) ⇒ BrandBreakdownItem

Returns a new instance of BrandBreakdownItem.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/batches/models/brand_breakdown_item.rb', line 89

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

  @brand = brand unless brand == SKIP
  @amount = amount unless amount == SKIP
  @count = count unless count == SKIP
  @gratuity_amount = gratuity_amount unless gratuity_amount == SKIP
  @sales = sales unless sales == SKIP
  @refunds = refunds unless refunds == 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 for this brand. It is always represented in the lowest denomination of the related currency.

Returns:

  • (String)


20
21
22
# File 'lib/batches/models/brand_breakdown_item.rb', line 20

def amount
  @amount
end

#brandBrandBatchesBrandBreakdownBrand

Indicates the card brand that this batch summary pertains to.



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

def brand
  @brand
end

#countFloat

The number of transactions in the batch for this brand.

Returns:

  • (Float)


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

def count
  @count
end

#funding_creditFundingCredit1

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

Returns:



54
55
56
# File 'lib/batches/models/brand_breakdown_item.rb', line 54

def funding_credit
  @funding_credit
end

#funding_debitFundingDebit1

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

Returns:



48
49
50
# File 'lib/batches/models/brand_breakdown_item.rb', line 48

def funding_debit
  @funding_debit
end

#gratuity_amountString

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

Returns:

  • (String)


30
31
32
# File 'lib/batches/models/brand_breakdown_item.rb', line 30

def gratuity_amount
  @gratuity_amount
end

#refundsRefunds1

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

Returns:



42
43
44
# File 'lib/batches/models/brand_breakdown_item.rb', line 42

def refunds
  @refunds
end

#salesSales1

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

Returns:



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

def sales
  @sales
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/batches/models/brand_breakdown_item.rb', line 108

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  brand = hash.key?('brand') ? hash['brand'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  count = hash.key?('count') ? hash['count'] : SKIP
  gratuity_amount =
    hash.key?('gratuity_amount') ? hash['gratuity_amount'] : SKIP
  sales = Sales1.from_hash(hash['sales']) if hash['sales']
  refunds = Refunds1.from_hash(hash['refunds']) if hash['refunds']
  funding_debit = FundingDebit1.from_hash(hash['funding_debit']) if hash['funding_debit']
  funding_credit = FundingCredit1.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.
  BrandBreakdownItem.new(brand: brand,
                         amount: amount,
                         count: count,
                         gratuity_amount: gratuity_amount,
                         sales: sales,
                         refunds: refunds,
                         funding_debit: funding_debit,
                         funding_credit: funding_credit,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/batches/models/brand_breakdown_item.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['brand'] = 'brand'
  @_hash['amount'] = 'amount'
  @_hash['count'] = 'count'
  @_hash['gratuity_amount'] = 'gratuity_amount'
  @_hash['sales'] = 'sales'
  @_hash['refunds'] = 'refunds'
  @_hash['funding_debit'] = 'funding_debit'
  @_hash['funding_credit'] = 'funding_credit'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
# File 'lib/batches/models/brand_breakdown_item.rb', line 85

def self.nullables
  []
end

.optionalsObject

An array for optional fields



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/batches/models/brand_breakdown_item.rb', line 71

def self.optionals
  %w[
    brand
    amount
    count
    gratuity_amount
    sales
    refunds
    funding_debit
    funding_credit
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



151
152
153
154
155
156
157
# File 'lib/batches/models/brand_breakdown_item.rb', line 151

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} brand: #{@brand.inspect}, amount: #{@amount.inspect}, count:"\
  " #{@count.inspect}, gratuity_amount: #{@gratuity_amount.inspect}, sales: #{@sales.inspect},"\
  " refunds: #{@refunds.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.



142
143
144
145
146
147
148
# File 'lib/batches/models/brand_breakdown_item.rb', line 142

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