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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68d4d41af7f4ebf688d5833e2cae959dd2c2f4f4
4
- data.tar.gz: aaec622b65b60a8a1b54f6263f538a6359441a24
3
+ metadata.gz: 5d29a50271fa545a4f78c7fe6ad108486ba8d4bb
4
+ data.tar.gz: f92a609fb2960cdae03941b859028172e6ea7c0c
5
5
  SHA512:
6
- metadata.gz: a696b2a16bc7da4adee9bc2a77b9240bbdfa16bf7d6e66c84696d13e1c878cb609d2eda2d663085ee3bb9b8c5ecbd9512be7f8fd1a73933d4bf247b8486eb4d0
7
- data.tar.gz: 77b1533054c69646dc637b0f9d0047e5f937836abef78f0bfa9531d1cb22299e9b21fbb27e2d072c53d96ae2e40fd4d98c2a80f31b3a4ae2602e538401b241fd
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.dup
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
- :cardNumber
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 :cardNumber, :not_null
20
- string :cardSetId
19
+ string :card_number, :not_null
20
+ string :card_set_id
21
+ string :activation_date
21
22
  array :balances
22
23
  end
23
24
 
@@ -8,7 +8,7 @@ module TapClutch
8
8
  # Models a Clutch Transaction
9
9
  class Transaction < Base
10
10
  def self.key_property
11
- :transactionId
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 :transactionId, :not_null
34
- string :cardNumber, :not_null
35
- string :requestRef
36
- string :callType
37
- boolean :isLegacy
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 :transactionTime
40
- array :balanceUpdates
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! 'transactionTime' =>
48
- Time.zone.at(data['transactionTime'] / 1000)
47
+ data.merge! 'transaction_time' =>
48
+ Time.zone.at(data['transaction_time'] / 1000)
49
49
  end
50
50
  end
51
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TapClutch
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
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.2
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