treezor_connect 0.12.0 → 0.13.0

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
  SHA256:
3
- metadata.gz: 66b4de75da0fd1fd98886e2a14f80eda6205195ab2dcdd6639a046735eb6db11
4
- data.tar.gz: c3ddf52425ed0843b24f5bdbe5bcea9ffec3916e551e3b850e1e24fe08fb3d46
3
+ metadata.gz: 9e8705aa0d14cb9eb9929d8f1c0b18787cf8098e99e013eeb36babe224009784
4
+ data.tar.gz: e68aaa3d37d5bc6e02de082262104cbccadcdb860504d2152fe32f4c9c253c06
5
5
  SHA512:
6
- metadata.gz: 61d4bc81af7fdc592afa1b1873162108dd3b68fc829941a62c4f4d1414905ec77fb9f7fd4e0f4ca96349467af277c640d49b8bd59ec7c38caa0b90ae2c051614
7
- data.tar.gz: b3de6580ddd099cb1e2f5eda715720e4937bd4de41a312ee64879cf58d20826706f1a18452d39b050a66651f9ea0d2b504d5f79897105f63b5f78240908b735f
6
+ metadata.gz: c809989d08406c0872f23c2c922a758c106961285afdcb1cc9a7ba418413e18cac7000bd1b86be77b5bc7a1abfd102223e3f63392028b68ae58727e85bd8f50e
7
+ data.tar.gz: b811ea9eae971c3f1987f71240e6ab25fe1d2b7e35b06341904e93a3f7561f96ca249ca44e612461363334a0b6d97b824d47f1cbfc492cff98f4dd6fe8b34068
@@ -11,13 +11,13 @@ module TreezorConnect
11
11
  'on its subclasses (Payin, Payout, Transfer ...)'
12
12
  end
13
13
 
14
- def custom_action(http_method, *actions, ignores_id: false)
14
+ def custom_action(http_method, *actions, ignores_id: false, first_letter_upcased: false)
15
15
  actions.each do |action|
16
16
  case http_method
17
17
  when :post
18
- define_method_with_params(http_method, action)
18
+ define_method_with_params(http_method, action, first_letter_upcased)
19
19
  when :put, :patch
20
- define_put_path_methods(http_method, action, ignores_id)
20
+ define_put_path_methods(http_method, action, ignores_id, first_letter_upcased)
21
21
  else
22
22
  raise ArgumentError, "Unsupported HTTP method: #{http_method}"
23
23
  end
@@ -26,42 +26,42 @@ module TreezorConnect
26
26
 
27
27
  private
28
28
 
29
- def define_method_with_params(http_method, action)
29
+ def define_method_with_params(http_method, action, first_letter_upcased)
30
30
  define_singleton_method(action) do |params = {}, access_token = nil|
31
- url = build_url(action)
31
+ url = build_url(action, first_letter_upcased)
32
32
  response = request(http_method, url, params: { body: params }, access_token:)
33
33
  process_response(response)
34
34
  end
35
35
  end
36
36
 
37
- def define_put_path_methods(http_method, action, ignores_id)
37
+ def define_put_path_methods(http_method, action, ignores_id, first_letter_upcased)
38
38
  if ignores_id
39
- define_method_without_id_and_params(http_method, action)
39
+ define_method_without_id_and_params(http_method, action, first_letter_upcased)
40
40
  else
41
- define_method_with_id_and_params(http_method, action)
41
+ define_method_with_id_and_params(http_method, action, first_letter_upcased)
42
42
  end
43
43
  end
44
44
 
45
- def define_method_with_id_and_params(http_method, action)
45
+ def define_method_with_id_and_params(http_method, action, first_letter_upcased)
46
46
  define_singleton_method(action) do |id, params = {}, access_token = nil|
47
- url = build_url(action, id)
47
+ url = build_url(action, first_letter_upcased, id)
48
48
  response = request(http_method, url, params: { body: params }, access_token:)
49
49
  process_response(response)
50
50
  end
51
51
  end
52
52
 
53
- def define_method_without_id_and_params(http_method, action)
53
+ def define_method_without_id_and_params(http_method, action, first_letter_upcased)
54
54
  define_singleton_method(action) do |params = {}, access_token = nil|
55
- url = build_url(action)
55
+ url = build_url(action, first_letter_upcased)
56
56
  response = request(http_method, url, params: { body: params }, access_token:)
57
57
  process_response(response)
58
58
  end
59
59
  end
60
60
 
61
- def build_url(action, id = nil)
61
+ def build_url(action, first_letter_upcased, id = nil)
62
62
  parts = [resource_url]
63
63
  parts << id if id
64
- parts << camelize(action.to_s)
64
+ parts << camelize(action.to_s, capitalize_first_letter: first_letter_upcased)
65
65
  parts.join('/')
66
66
  end
67
67
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TreezorConnect
4
+ class Card < ApiResource
5
+ custom_action :put, :lock_unlock, first_letter_upcased: true
6
+
7
+ OBJECT_NAME = 'card'
8
+ OBJECT_KEY = 'cards'
9
+ OBJECT_PRIMARY_KEY = 'cardId'
10
+
11
+ def self.resource_url
12
+ '/v1/cards'
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'treezor_connect/resources/beneficiary'
4
+ require 'treezor_connect/resources/card'
4
5
  require 'treezor_connect/resources/card_image'
5
6
  require 'treezor_connect/resources/payin'
6
7
  require 'treezor_connect/resources/payout'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: treezor_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stefakins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-11-17 00:00:00.000000000 Z
12
+ date: 2024-11-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A gem for making HTTP calls to Treezor Connect.
15
15
  email: stefan.atkinson69@gmail.com
@@ -29,6 +29,7 @@ files:
29
29
  - lib/treezor_connect/errors.rb
30
30
  - lib/treezor_connect/resources.rb
31
31
  - lib/treezor_connect/resources/beneficiary.rb
32
+ - lib/treezor_connect/resources/card.rb
32
33
  - lib/treezor_connect/resources/card_image.rb
33
34
  - lib/treezor_connect/resources/oauth/token.rb
34
35
  - lib/treezor_connect/resources/payin.rb