zai_payment 2.8.6 → 2.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3943f38962a68cdf4a81db8c65bf7e1662499713e2d8c07509626721c943d3eb
4
- data.tar.gz: 5ecb7d95198390afa550f14f21b85c2204c6ae939f1c8b511fe7526a1022ef31
3
+ metadata.gz: 68b76b84ea2dd83e23dd709f8e3e13f466b6c76288231422450aa51327c53fc8
4
+ data.tar.gz: ff828a44dbc6769aff37a705b184a7868c3610ad7580261806e511f57ffe5c6e
5
5
  SHA512:
6
- metadata.gz: 9057831bdcdecce3c5af891b543116eb3bc85627a56ebc7c29c69a2070699c4a553f74233a6a958843b4c6cf15ff2ef863235697bc059446de118148f7d5dc8a
7
- data.tar.gz: 0b55cf6f3d2559d2042f12ab01023d021110ce29910c3c44928d1b55f8de00bbeb2e4d7f7cbe06a1c3fabe24624a9253d1bc3e0ea78b16acffe666c26943ead1
6
+ metadata.gz: 1857326fecea58e66633a177f6322aa5c6cc7d93b71e51b93d768d30d470c031783ac35a2036dbc19680850554c0ea79b24cb907b16313966a0c199b1811a3f4
7
+ data.tar.gz: 4125e27bc20f280f4f9a02a8b4c8d989acb8df5a7859265ac474d7412c253f80fe466f91aeee19d8a3d69b3f98de2d5c6720cdcd524c2ba34cc32714f097b4cc
data/badges/coverage.json CHANGED
@@ -1 +1 @@
1
- {"schemaVersion": 1, "label": "coverage", "message": "95.51%", "color": "brightgreen"}
1
+ {"schemaVersion": 1, "label": "coverage", "message": "95.57%", "color": "brightgreen"}
data/changelog.md CHANGED
@@ -1,5 +1,27 @@
1
1
  ## [Released]
2
2
 
3
+ ## [2.9.0] - 2025-12-16
4
+
5
+ ### Added
6
+ - **Webhook Jobs API**: Retrieve and monitor webhook delivery jobs 📋
7
+ - `ZaiPayment.webhooks.list_jobs(webhook_id, limit:, offset:, status:, object_id:)` - List jobs associated with a webhook
8
+ - `ZaiPayment.webhooks.show_job(webhook_id, job_id)` - Get details of a specific webhook job
9
+ - Support for pagination with `limit` (1-200) and `offset` parameters
10
+ - Support for filtering by `status` ('success' or 'failed')
11
+ - Support for filtering by `object_id`
12
+ - Job details include: `uuid`, `webhook_uuid`, `object_id`, `payload`, `request_responses`, `created_at`, `updated_at`
13
+ - Request responses include delivery attempts with `response_code`, `message`, and timestamps
14
+ - Validation for status parameter (must be 'success' or 'failed')
15
+ - Full RSpec test suite with 21 test examples
16
+ - Comprehensive YARD documentation with examples
17
+
18
+ ### Enhanced
19
+ - **Response Class**: Added `jobs` to `RESPONSE_DATA_KEYS` for automatic data extraction
20
+ - `response.data` now properly extracts jobs array from list_jobs responses
21
+ - Consistent with other resource response handling
22
+
23
+ **Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.8.6...v2.9.0
24
+
3
25
  ## [2.8.6] - 2025-12-12
4
26
 
5
27
  ### Fixed
@@ -133,6 +133,62 @@ module ZaiPayment
133
133
  client.delete("/webhooks/#{webhook_id}")
134
134
  end
135
135
 
136
+ # List jobs associated with a webhook
137
+ #
138
+ # Retrieves an ordered and paginated list of jobs garnered from a webhook.
139
+ #
140
+ # @param webhook_id [String] the webhook ID (UUID)
141
+ # @param limit [Integer] number of records to retrieve (1-200, default: 10)
142
+ # @param offset [Integer] number of records to skip (default: 0)
143
+ # @param status [String] filter by status ('success', 'failed', or nil for all)
144
+ # @param object_id [String] filter by object_id
145
+ # @return [Response] the API response containing jobs array
146
+ #
147
+ # @example List all jobs for a webhook
148
+ # webhooks = ZaiPayment::Resources::Webhook.new
149
+ # response = webhooks.list_jobs("webhook_uuid")
150
+ # response.data # => [{"id" => "...", "status" => "success", ...}, ...]
151
+ #
152
+ # @example Filter jobs by status
153
+ # response = webhooks.list_jobs("webhook_uuid", status: "failed")
154
+ #
155
+ # @example Paginate through jobs
156
+ # response = webhooks.list_jobs("webhook_uuid", limit: 50, offset: 100)
157
+ #
158
+ # @see https://developer.hellozai.com/reference/getjobs
159
+ def list_jobs(webhook_id, limit: 10, offset: 0, status: nil, object_id: nil)
160
+ validate_id!(webhook_id, 'webhook_id')
161
+ validate_job_status!(status) if status
162
+
163
+ params = {
164
+ limit: limit,
165
+ offset: offset
166
+ }
167
+ params[:status] = status if status
168
+ params[:object_id] = object_id if object_id
169
+
170
+ client.get("/webhooks/#{webhook_id}/jobs", params: params)
171
+ end
172
+
173
+ # Show a specific job associated with a webhook
174
+ #
175
+ # @param webhook_id [String] the webhook ID (UUID)
176
+ # @param job_id [String] the job ID
177
+ # @return [Response] the API response containing job details
178
+ #
179
+ # @example
180
+ # webhooks = ZaiPayment::Resources::Webhook.new
181
+ # response = webhooks.show_job("webhook_uuid", "job_id")
182
+ # response.data # => {"id" => "job_id", "status" => "success", ...}
183
+ #
184
+ # @see https://developer.hellozai.com/reference/getjob
185
+ def show_job(webhook_id, job_id)
186
+ validate_id!(webhook_id, 'webhook_id')
187
+ validate_id!(job_id, 'job_id')
188
+
189
+ client.get("/webhooks/#{webhook_id}/jobs/#{job_id}")
190
+ end
191
+
136
192
  # Create a secret key for webhook signature verification
137
193
  #
138
194
  # @param secret_key [String] the secret key to use for HMAC signature generation
@@ -262,6 +318,14 @@ module ZaiPayment
262
318
  raise Errors::ValidationError, 'secret_key must be at least 32 bytes in size'
263
319
  end
264
320
 
321
+ def validate_job_status!(status)
322
+ valid_statuses = %w[success failed]
323
+ return if valid_statuses.include?(status)
324
+
325
+ raise Errors::ValidationError,
326
+ "status must be one of: #{valid_statuses.join(', ')}"
327
+ end
328
+
265
329
  def parse_signature_header(header)
266
330
  # Format: "t=1257894000,v=signature1,v=signature2"
267
331
  parts = header.split(',').map(&:strip)
@@ -6,7 +6,7 @@ module ZaiPayment
6
6
  attr_reader :status, :body, :headers, :raw_response
7
7
 
8
8
  RESPONSE_DATA_KEYS = %w[
9
- webhooks users items fees transactions
9
+ webhooks users items fees transactions jobs
10
10
  batch_transactions batches bpay_accounts bank_accounts card_accounts
11
11
  wallet_accounts virtual_accounts disbursements pay_ids
12
12
  ].freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZaiPayment
4
- VERSION = '2.8.6'
4
+ VERSION = '2.9.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zai_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.6
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddy Jaga