paystack-gateway 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b006328b301fcf8623f6112708bfcc417a3ac526e624b5808fe734b4363f12b5
4
- data.tar.gz: 52b87e2c79a821070b5dd7f742fde3eb73e2f164ea1d9163f8ad9c007299f580
3
+ metadata.gz: 960e45b01e324553500b07374aa199876b404c5926192a96f52247287dde5c68
4
+ data.tar.gz: 191204e218673752ccc91c7ea1e08ad43b085e698eebf487bd77cbbce196f6f2
5
5
  SHA512:
6
- metadata.gz: 1678a9c29c4bcda5ed2440c70979efa7bf3171549baf07f6b086ec0a2bcf309b12ce9a367c324649958dffc1f6e705fb396616db4b67b026eddaf986ad2a5220
7
- data.tar.gz: 1b9fd60c1f84978915cf365e551176f4a93fb63274a675430ead26d3b37bfdd9f36f900f6a4ef8966b44189995353edcd9d5286c863c59487a7b66e4db0b2d8a
6
+ metadata.gz: ab9e8ad8ed05816b07dc34e67099f80109f4ec20ae34b39ab3905c7b1bcb32fb5278913ffa5e6e85ac4486ca8417208849a091fff828e04eeed282227f19e704
7
+ data.tar.gz: 8bb3746cc29c83352555a60567193c1e8a82b99711681e9730325e25279341b4d30e9724b4fdd54bf9e63e300418d1ee4f767474afa5c23c0f68c54492dbb384
data/README.md CHANGED
@@ -6,13 +6,13 @@
6
6
  Install the gem and add to the application's Gemfile by executing:
7
7
 
8
8
  ```bash
9
- $ bundle add PLACEHOLDER_GEM_NAME
9
+ $ bundle add paystack-gateway
10
10
  ```
11
11
 
12
12
  If bundler is not being used to manage dependencies, install the gem by executing:
13
13
 
14
14
  ```bash
15
- $ gem install PLACEHOLDER_GEM_NAME
15
+ $ gem install paystack-gateway
16
16
  ```
17
17
 
18
18
  ## Configuration
@@ -31,7 +31,11 @@ The configuration options are
31
31
  PaystackGateway.configure do |config|
32
32
  config.secret_key = Rails.application.credentials.dig(:paystack, :secret_key)
33
33
  config.logger = Rails.logger
34
- config.log_filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters).method(:filter)
34
+ config.log_filter = lambda { |params|
35
+ next params if !params || !params.respond_to?(:each)
36
+
37
+ ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters).filter(params)
38
+ }
35
39
  end
36
40
  ```
37
41
 
@@ -41,7 +41,15 @@ module PaystackGateway
41
41
  @cancellable = cancellable
42
42
  end
43
43
 
44
- def network_error? = original_error&.class&.in?(CONNECTION_ERROR_CLASSES)
44
+ def network_error?
45
+ return false if !original_error
46
+
47
+ original_error.class.ancestors.any? do |ancestor|
48
+ break if ancestor == Exception
49
+
50
+ CONNECTION_ERROR_CLASSES.include?(ancestor)
51
+ end
52
+ end
45
53
 
46
54
  def method_missing(method_name, *)
47
55
  return super unless method_name.to_s.end_with?('_error?', '_error!')
@@ -14,13 +14,4 @@ module PaystackGateway
14
14
  @log_filter = lambda(&:dup)
15
15
  end
16
16
  end
17
-
18
- class << self
19
- attr_writer :config
20
-
21
- delegate :secret_key, :logger, :logging_options, :log_filter, to: :config
22
-
23
- def config = @config ||= Configuration.new
24
- def configure = yield(config)
25
- end
26
17
  end
@@ -54,12 +54,12 @@ module PaystackGateway
54
54
  end
55
55
  end
56
56
 
57
- # Response from GET /dedicated_account endpoint
57
+ # Response from GET /dedicated_account/requery/:account_number endpoint
58
58
  class RequeryDedicatedAccountResponse < PaystackGateway::Response; end
59
59
 
60
60
  api_method def self.requery_dedicated_account(account_number:, bank:)
61
61
  use_connection do |connection|
62
- connection.get('/dedicated_account', { account_number:, provider_slug: bank })
62
+ connection.get('/dedicated_account/requery', { account_number:, provider_slug: bank })
63
63
  end
64
64
  end
65
65
  end
@@ -54,11 +54,9 @@ module PaystackGateway
54
54
  def api_method(method_name)
55
55
  @api_method_names ||= Set.new
56
56
  @api_method_names << method_name
57
-
58
- decorate_api_methods(method_name)
59
57
  end
60
58
 
61
- def decorate_api_methods(*method_names)
59
+ def decorate_api_methods(method_names = api_methods)
62
60
  singleton_class.class_exec do
63
61
  prepend(Module.new do
64
62
  method_names.flatten.each do |method_name|
@@ -91,7 +89,13 @@ module PaystackGateway
91
89
  request_method: response.dig(:request, :method),
92
90
  request_url: response.dig(:request, :url),
93
91
  request_headers: PaystackGateway.log_filter.call(response.dig(:request, :headers)),
94
- request_body: PaystackGateway.log_filter.call(JSON.parse(response.dig(:request, :body) || '{}')),
92
+ request_body: PaystackGateway.log_filter.call(
93
+ begin
94
+ JSON.parse(response.dig(:request, :body) || '{}')
95
+ rescue JSON::ParserError
96
+ response.dig(:request, :body)
97
+ end,
98
+ ),
95
99
 
96
100
  response_status: response[:status],
97
101
  response_headers: PaystackGateway.log_filter.call(response[:headers]),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaystackGateway
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -22,4 +22,22 @@ require 'paystack_gateway/webhooks'
22
22
 
23
23
  # = PaystackGateway
24
24
  module PaystackGateway
25
+ class << self
26
+ attr_writer :config
27
+
28
+ delegate :secret_key, :logger, :logging_options, :log_filter, to: :config
29
+
30
+ def config = @config ||= Configuration.new
31
+ def configure = yield(config)
32
+
33
+ def api_modules
34
+ constants.filter_map do |const_name|
35
+ const = const_get(const_name)
36
+
37
+ const if const.is_a?(Module) && const.included_modules.include?(RequestModule)
38
+ end
39
+ end
40
+ end
41
+
42
+ api_modules.each { |mod| mod.send(:decorate_api_methods) }
25
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paystack-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - darthrighteous
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2025-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.5.3
118
+ rubygems_version: 3.5.16
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Ruby bindings for Paystack’s API https://paystack.com/docs/api