tap-clutch 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hash.rb +23 -0
- data/lib/models/base.rb +2 -1
- data/lib/models/card.rb +4 -3
- data/lib/models/transaction.rb +10 -10
- data/lib/tap_clutch/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d29a50271fa545a4f78c7fe6ad108486ba8d4bb
|
4
|
+
data.tar.gz: f92a609fb2960cdae03941b859028172e6ea7c0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e767d11450b859de63ab9eb25a650005678565ac7512f7e8f73dba9af305f5e5cc03cc701df0cc9a5e4f7811324461717db71e911cb94df623ada479a250cda3
|
7
|
+
data.tar.gz: ccf2a3463b288e38e2f74e89cb7a26ddea96ce4639d721b5142beb66e33705dc68c73c7a19892a3be7d2a4b41fd3847823daa387c0896f2f391229611d6310ff
|
data/lib/hash.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Adds `deep_transform_keys` method to Ruby hash
|
4
|
+
class Hash
|
5
|
+
def deep_transform_keys(&block)
|
6
|
+
_deep_transform_keys_in_object(self, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def _deep_transform_keys_in_object(object, &block)
|
12
|
+
case object
|
13
|
+
when Hash
|
14
|
+
object.each_with_object({}) do |(key, value), result|
|
15
|
+
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
|
16
|
+
end
|
17
|
+
when Array
|
18
|
+
object.map { |e| _deep_transform_keys_in_object(e, &block) }
|
19
|
+
else
|
20
|
+
object
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/models/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../schema'
|
4
|
+
require_relative '../hash'
|
4
5
|
|
5
6
|
module TapClutch
|
6
7
|
module Models
|
@@ -24,7 +25,7 @@ module TapClutch
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def transform
|
27
|
-
data.
|
28
|
+
data.transform_keys(&:underscore)
|
28
29
|
end
|
29
30
|
|
30
31
|
def base_record
|
data/lib/models/card.rb
CHANGED
@@ -8,7 +8,7 @@ module TapClutch
|
|
8
8
|
# Models a Clutch Card
|
9
9
|
class Card < Base
|
10
10
|
def self.key_property
|
11
|
-
:
|
11
|
+
:card_number
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.stream
|
@@ -16,8 +16,9 @@ module TapClutch
|
|
16
16
|
end
|
17
17
|
|
18
18
|
schema do
|
19
|
-
string :
|
20
|
-
string :
|
19
|
+
string :card_number, :not_null
|
20
|
+
string :card_set_id
|
21
|
+
string :activation_date
|
21
22
|
array :balances
|
22
23
|
end
|
23
24
|
|
data/lib/models/transaction.rb
CHANGED
@@ -8,7 +8,7 @@ module TapClutch
|
|
8
8
|
# Models a Clutch Transaction
|
9
9
|
class Transaction < Base
|
10
10
|
def self.key_property
|
11
|
-
:
|
11
|
+
:transaction_id
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.stream
|
@@ -30,22 +30,22 @@ module TapClutch
|
|
30
30
|
end
|
31
31
|
|
32
32
|
schema do
|
33
|
-
string :
|
34
|
-
string :
|
35
|
-
string :
|
36
|
-
string :
|
37
|
-
boolean :
|
33
|
+
string :transaction_id, :not_null
|
34
|
+
string :card_number, :not_null
|
35
|
+
string :request_ref
|
36
|
+
string :call_type
|
37
|
+
boolean :is_legacy
|
38
38
|
string :location
|
39
|
-
string :
|
40
|
-
array :
|
39
|
+
string :transaction_time
|
40
|
+
array :balance_updates
|
41
41
|
end
|
42
42
|
|
43
43
|
def transform
|
44
44
|
Time.zone = Time.now.zone
|
45
45
|
|
46
46
|
super.tap do |data|
|
47
|
-
data.merge! '
|
48
|
-
Time.zone.at(data['
|
47
|
+
data.merge! 'transaction_time' =>
|
48
|
+
Time.zone.at(data['transaction_time'] / 1000)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/tap_clutch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tap-clutch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Lind
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- README.md
|
98
98
|
- bin/tap-clutch
|
99
99
|
- lib/client.rb
|
100
|
+
- lib/hash.rb
|
100
101
|
- lib/models/base.rb
|
101
102
|
- lib/models/card.rb
|
102
103
|
- lib/models/transaction.rb
|