Class: TapClutch::Models::Transaction
- Inherits:
-
Base
- Object
- Struct
- Base
- TapClutch::Models::Transaction
show all
- Defined in:
- lib/models/transaction.rb
Overview
Models a Clutch Transaction
Instance Attribute Summary
Attributes inherited from Base
#client, #data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#base_record, #extra_records, #records, schema, subclasses
Class Method Details
.history(card_number) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/models/transaction.rb', line 18
def self.history(card_number)
response = Clutch.client.post(
'/cardHistory',
limit: 100,
offset: 0,
cardNumber: card_number,
restrictTransactionTypes: %w[ALLOCATE UPDATE_BALANCE]
)
response.transactions.map do |transaction|
new(transaction.merge(card_number: card_number)
.deep_transform_keys(&:underscore))
end
end
|
.key_property ⇒ Object
10
11
12
|
# File 'lib/models/transaction.rb', line 10
def self.key_property
:transaction_id
end
|
.stream ⇒ Object
14
15
16
|
# File 'lib/models/transaction.rb', line 14
def self.stream
'transactions'
end
|
Instance Method Details
44
45
46
47
48
49
50
51
|
# File 'lib/models/transaction.rb', line 44
def transform
Time.zone = Time.now.zone
super.tap do |data|
data.merge! 'transaction_time' =>
Time.zone.at(data['transaction_time'] / 1000)
end
end
|