zai_payment 2.8.5 → 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: 8598e7bf2a63f176accff321924e733fe29e3c7ed6c1ce8885c128f057ede980
4
- data.tar.gz: b5c3ad4634b980210f7239e8104be6e743834b8e45329bf00b6e52c00d0cc0f8
3
+ metadata.gz: 68b76b84ea2dd83e23dd709f8e3e13f466b6c76288231422450aa51327c53fc8
4
+ data.tar.gz: ff828a44dbc6769aff37a705b184a7868c3610ad7580261806e511f57ffe5c6e
5
5
  SHA512:
6
- metadata.gz: eb5d3e5aa75f0ea46a6e12496c2ea79c6bd0f027aab3ea90d534c8b1d8b7401e0207a8c8b7eb71e02479c9fc67a405252b3a19d450618572e33407f1a3026143
7
- data.tar.gz: dd3084f1c3a00676170401a1083eb9432e654390603cb677aed3545cd066a38501a9fa58ed2817890c7ff815e4196a9f5dc28baf5106cb178edf656292220c4b
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,39 @@
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
+
25
+ ## [2.8.6] - 2025-12-12
26
+
27
+ ### Fixed
28
+ - **Production API Endpoints**: Fixed incorrect production URL configuration 🔧
29
+ - Corrected `core_base` endpoint to use `https://secure.api.promisepay.com` (was incorrectly set to assemblypay.com)
30
+ - Corrected `va_base` endpoint to use `https://au-0000.api.assemblypay.com` (was incorrectly set to promisepay.com)
31
+ - Removed deprecated `webhook_base_endpoint` method from Config class
32
+ - Production environment now uses correct endpoints for core API and virtual accounts
33
+ - Ensures proper routing of production API requests to Zai servers
34
+
35
+ **Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.8.5...v2.8.6
36
+
3
37
  ## [2.8.5] - 2025-12-12
4
38
 
5
39
  ### Fixed
@@ -31,26 +31,13 @@ module ZaiPayment
31
31
  }
32
32
  when :production
33
33
  {
34
- core_base: 'https://au-0000.api.assemblypay.com',
35
- va_base: 'https://secure.api.promisepay.com',
34
+ core_base: 'https://secure.api.promisepay.com',
35
+ va_base: 'https://au-0000.api.assemblypay.com',
36
36
  auth_base: 'https://au-0000.auth.assemblypay.com'
37
37
  }
38
38
  else
39
39
  raise "Unknown environment: #{environment}"
40
40
  end
41
41
  end
42
-
43
- # Returns the appropriate webhook base endpoint based on environment
44
- # Production uses core_base, prelive uses va_base
45
- def webhook_base_endpoint
46
- case environment.to_sym
47
- when :production
48
- :core_base
49
- when :prelive
50
- :va_base
51
- else
52
- raise "Unknown environment: #{environment}"
53
- end
54
- end
55
42
  end
56
43
  end
@@ -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.5'
4
+ VERSION = '2.9.0'
5
5
  end
data/lib/zai_payment.rb CHANGED
@@ -46,7 +46,7 @@ module ZaiPayment
46
46
  # --- Resource accessors ---
47
47
  # @return [ZaiPayment::Resources::Webhook] webhook resource instance
48
48
  def webhooks
49
- @webhooks ||= Resources::Webhook.new(client: Client.new(base_endpoint: config.webhook_base_endpoint))
49
+ @webhooks ||= Resources::Webhook.new(client: Client.new(base_endpoint: :va_base))
50
50
  end
51
51
 
52
52
  # @return [ZaiPayment::Resources::User] user resource instance
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.5
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddy Jaga