pratka 0.1.1 → 0.1.2

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: 5b7fcba8830d7b2a64d6eface4623a15a44f88891a3642ef144fcef3df7af4e9
4
- data.tar.gz: 141e3f04d803fd70e8e1173334b10ce88e1908d8f9c1d711bbd27e02de265547
3
+ metadata.gz: 7940c2073d0fbeec909b2f5f545729474e26f1113c4d9dd154046ae7f8e7780f
4
+ data.tar.gz: 58293d9ab43d5addb4e84208bff655d76db9fd84c14a74acb43d50cd3376c6ba
5
5
  SHA512:
6
- metadata.gz: 90e43c700109947503183ab11b2d8601be0ddeb69c1d9736ae71124e56a2546f8a08ebe43a18647add64412ab39e45b2a6379091af8e2383763ef604457bbe37
7
- data.tar.gz: be018a707f9cc0fe0d7dd665b7dfbe672557ffc9f83cac1a1b46aa53cf741f8428f8024bc8cf2706c4514a476b7b1d99ec9c707dd2d09bce00f6a5eaf08ab809
6
+ metadata.gz: fe7b5484ea064bc9ff8dc3e42b31fe24c6bfcab9231c7f6e35140beba7b7dd2a2c43c85f4087e52af6684167aa80c093ab0f6386f3b167293523ad1b079b1e02
7
+ data.tar.gz: 7e1b7237afd97ef8d001e861953b55b7e6bb6c55888f22f4a285c5db531475b9d3f9103e806c83cb39950e8d9e89ed31da15fcb46fc2d10a532662b0128a4cea
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2026-10-12
4
+
5
+ ### Changed
6
+
7
+ - Invalid params raise `Pratka::Speedy::InvalidParamsError` instead of `ArgumentError`, so `rescue Pratka::Error` covers every failure
8
+
3
9
  ## [0.1.1] - 2026-10-08
4
10
 
5
11
  ### Added
data/README.md CHANGED
@@ -258,7 +258,7 @@ Returns raw PDF or ZPL bytes if the request is successful and the parcel exists
258
258
 
259
259
  If the parcels don't exist in Speedy, `print_label` raises `Pratka::Speedy::Error` with the message `Speedy returned an empty label; check the parcel IDs`
260
260
 
261
- If you send empty parcels, `print_label` raises `ArgumentError` with the message `Missing params: parcels`
261
+ If you send empty parcels, `print_label` raises `Pratka::Speedy::InvalidParamsError` with the message `Missing params: parcels`
262
262
 
263
263
  #### Fetch payment details
264
264
 
@@ -427,7 +427,7 @@ Returns the parsed JSON response with one tracked parcel per matched parcel. A `
427
427
 
428
428
  A parcel Speedy can't find comes back with its own `error` object instead of operations. `track` doesn't raise for it, so check each parcel
429
429
 
430
- Speedy enforces 10 parcels limit per request. If you send more than 10 parcels it raises `ArgumentError` with the message `Speedy tracks at most 10 parcels per call`. Split larger lists into batches, for example with `each_slice(10)`
430
+ Speedy enforces 10 parcels limit per request. If you send more than 10 parcels it raises `Pratka::Speedy::InvalidParamsError` with the message `Speedy tracks at most 10 parcels per call`. Split larger lists into batches, for example with `each_slice(10)`
431
431
 
432
432
  Example response:
433
433
 
@@ -445,18 +445,17 @@ Example response:
445
445
 
446
446
  ### Errors
447
447
 
448
- Every network and API failure raises a subclass of `Pratka::Speedy::Error`, which inherits from `Pratka::Error`
448
+ Every failure raises a subclass of `Pratka::Speedy::Error`, which inherits from `Pratka::Error`, so `rescue Pratka::Error` covers them all
449
449
 
450
450
  | Error | Raised when | Extra attributes |
451
451
  | --- | --- | --- |
452
+ | `Pratka::Speedy::InvalidParamsError` | A param is unknown, missing or over a limit. Raised before any request is sent | |
452
453
  | `Pratka::Speedy::TimeoutError` | The connection or read times out | |
453
454
  | `Pratka::Speedy::ConnectionError` | DNS, socket or SSL failure | |
454
455
  | `Pratka::Speedy::HTTPError` | Speedy returns a non-2xx status | `status`, `body` |
455
456
  | `Pratka::Speedy::APIError` | Speedy returns 2xx with an `error` object in the body | `code`, `context`, `id` |
456
457
  | `Pratka::Speedy::Error` | The response is malformed, has invalid JSON, or has an unexpected format | |
457
458
 
458
- Bad arguments raise `ArgumentError` before any request is sent, for example an unknown option or a missing `site_id`
459
-
460
459
  ```ruby
461
460
  begin
462
461
  client.fetch_streets(site_id: 36124, name: "Алеко")
@@ -191,7 +191,7 @@ module Pratka
191
191
  # Returns one tracked parcel per matched parcel. A ref can match up to 10. Each tracked parcel carries its own error if Speedy can't track it
192
192
  def track(**options)
193
193
  params = map_params(options, TRACK_PARAMS, required: [:parcels])
194
- raise ArgumentError, "Speedy tracks at most #{TRACK_MAX_PARCELS} parcels per call" if params[:parcels].size > TRACK_MAX_PARCELS
194
+ raise InvalidParamsError, "Speedy tracks at most #{TRACK_MAX_PARCELS} parcels per call" if params[:parcels].size > TRACK_MAX_PARCELS
195
195
 
196
196
  call(TRACK_ENDPOINT, params)
197
197
  end
@@ -204,10 +204,10 @@ module Pratka
204
204
 
205
205
  def map_params(options, mapping, required: [])
206
206
  unknown = options.keys - mapping.keys
207
- raise ArgumentError, "Unknown params: #{unknown.join(", ")}" if unknown.any?
207
+ raise InvalidParamsError, "Unknown params: #{unknown.join(", ")}" if unknown.any?
208
208
 
209
209
  missing = required.select { |key| blank?(options[key]) }
210
- raise ArgumentError, "Missing params: #{missing.join(", ")}" if missing.any?
210
+ raise InvalidParamsError, "Missing params: #{missing.join(", ")}" if missing.any?
211
211
 
212
212
  options.transform_keys(mapping)
213
213
  end
@@ -7,6 +7,7 @@ module Pratka
7
7
  class Error < Pratka::Error; end
8
8
  class TimeoutError < Error; end
9
9
  class ConnectionError < Error; end
10
+ class InvalidParamsError < Error; end
10
11
 
11
12
  class HTTPError < Error
12
13
  attr_reader :status, :body
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pratka
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pratka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stilqn Bairski