paystack_sdk 0.4.1 → 0.5.0

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.
@@ -85,6 +85,23 @@ module PaystackSdk
85
85
  end
86
86
  end
87
87
 
88
+ # Validates a numeric identifier, such as a customer or plan ID. Paystack answers with an empty
89
+ # list and no error when a code (`CUS_...`) is passed where it filters by the numeric ID, so a wrong
90
+ # value would otherwise look like "no results". An Integer, or a string of digits, passes.
91
+ #
92
+ # @param value [Integer, String, nil] The identifier to validate
93
+ # @param name [String] Name of the parameter for error messages
94
+ # @param allow_nil [Boolean] Whether nil is acceptable (default: true)
95
+ # @raise [PaystackSdk::MissingParamError] If value is nil and nil is not allowed
96
+ # @raise [PaystackSdk::InvalidValueError] If value is not a positive whole number
97
+ def validate_numeric_id!(value:, name: "Parameter", allow_nil: true)
98
+ if value.nil?
99
+ raise PaystackSdk::MissingParamError.new(name) unless allow_nil
100
+ elsif !(value.is_a?(Integer) || value.is_a?(String)) || !value.to_s.match?(/\A[1-9]\d*\z/)
101
+ raise PaystackSdk::InvalidValueError.new(name, "must be the numeric ID (for example 123456), not a code or a name")
102
+ end
103
+ end
104
+
88
105
  # Validates a transaction reference format.
89
106
  #
90
107
  # @param reference [String] The reference to validate
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaystackSdk
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -37,15 +37,21 @@ module PaystackSdk
37
37
  # The only addresses Paystack sends webhooks from, for both test and live.
38
38
  IP_ADDRESSES = %w[52.31.139.75 52.49.173.169 52.214.14.220].freeze
39
39
 
40
- # Events Paystack documents. Paystack adds events over time, so an event
41
- # outside this list is still returned by {Webhook.construct_event}.
40
+ # Events Paystack documents, plus ones Paystack was seen sending that its Webhooks page does not list.
41
+ # Paystack adds events over time, so an event outside this list is still returned by
42
+ # {Webhook.construct_event}.
43
+ #
44
+ # Documented on the Webhooks page, except `refund.needs-attention`, which only the Refunds guide
45
+ # names. Seen in the event log of a test integration (Webhook Events API) and not on the Webhooks
46
+ # page: `paymentrequest.draft`, `product.create`, `product.update` and `product.delete`.
42
47
  EVENTS = %w[
43
48
  charge.dispute.create charge.dispute.remind charge.dispute.resolve charge.success
44
49
  customeridentification.failed customeridentification.success
45
50
  dedicatedaccount.assign.failed dedicatedaccount.assign.success
46
51
  invoice.create invoice.payment_failed invoice.update
47
- paymentrequest.pending paymentrequest.success
48
- refund.failed refund.pending refund.processed refund.processing
52
+ paymentrequest.draft paymentrequest.pending paymentrequest.success
53
+ product.create product.delete product.update
54
+ refund.failed refund.needs-attention refund.pending refund.processed refund.processing
49
55
  subscription.create subscription.disable subscription.expiring_cards subscription.not_renew
50
56
  transfer.failed transfer.reversed transfer.success
51
57
  ].freeze
@@ -70,7 +76,7 @@ module PaystackSdk
70
76
  @data = payload.key?("data") ? Response.new(payload["data"]) : nil
71
77
  end
72
78
 
73
- # @return [Boolean] Whether Paystack documents this event name
79
+ # @return [Boolean] Whether this event name is in {EVENTS} (documented, or seen sent by Paystack)
74
80
  def known?
75
81
  EVENTS.include?(event)
76
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paystack_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxwell Nana Forson (theLazyProgrammer)
@@ -149,7 +149,8 @@ description: |
149
149
  such as initiating transactions, verifying payments, managing customers, and more.
150
150
  email:
151
151
  - nanaforsonjnr@gmail.com
152
- executables: []
152
+ executables:
153
+ - paystack_sdk
153
154
  extensions: []
154
155
  extra_rdoc_files: []
155
156
  files:
@@ -161,7 +162,10 @@ files:
161
162
  - LICENSE.txt
162
163
  - README.md
163
164
  - Rakefile
165
+ - exe/paystack_sdk
166
+ - lib/generators/paystack_sdk/skills_generator.rb
164
167
  - lib/paystack_sdk.rb
168
+ - lib/paystack_sdk/cli.rb
165
169
  - lib/paystack_sdk/client.rb
166
170
  - lib/paystack_sdk/middleware/transport_errors.rb
167
171
  - lib/paystack_sdk/request_helpers.rb
@@ -194,7 +198,18 @@ files:
194
198
  - lib/paystack_sdk/resources/transfer_recipients.rb
195
199
  - lib/paystack_sdk/resources/transfers.rb
196
200
  - lib/paystack_sdk/resources/virtual_terminals.rb
201
+ - lib/paystack_sdk/resources/webhook_events.rb
197
202
  - lib/paystack_sdk/response.rb
203
+ - lib/paystack_sdk/skills.rb
204
+ - lib/paystack_sdk/skills/paystack-sdk-charge-statuses/SKILL.md
205
+ - lib/paystack_sdk/skills/paystack-sdk-mobile-money/SKILL.md
206
+ - lib/paystack_sdk/skills/paystack-sdk-money-safety/SKILL.md
207
+ - lib/paystack_sdk/skills/paystack-sdk-overview/SKILL.md
208
+ - lib/paystack_sdk/skills/paystack-sdk-payments/SKILL.md
209
+ - lib/paystack_sdk/skills/paystack-sdk-refunds/SKILL.md
210
+ - lib/paystack_sdk/skills/paystack-sdk-saved-card-renewals/SKILL.md
211
+ - lib/paystack_sdk/skills/paystack-sdk-testing/SKILL.md
212
+ - lib/paystack_sdk/skills/paystack-sdk-webhooks/SKILL.md
198
213
  - lib/paystack_sdk/utils/connection_utils.rb
199
214
  - lib/paystack_sdk/validations.rb
200
215
  - lib/paystack_sdk/version.rb