flexops 1.0.2 → 2.0.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: 46267de883ed8970bdcfc87d77c86edcf9b33a5d1ffe0d312a10961ea43646fb
4
- data.tar.gz: 9c828d5d8fbc74b2b3abee2640b1742de692a800e51fe60f3fd671b728564dc6
3
+ metadata.gz: 99bb604e4e35131d7525633fbfad7103b380170556b47250599192256636eec1
4
+ data.tar.gz: b9fb3ccd224541332bd03fd9e8510937fbed4d093c6ab3443dfd41fee0565229
5
5
  SHA512:
6
- metadata.gz: 439f0b3d74903968585f2d980e80d00798f9784903100851804949a7602c3bc163f0ce3600e5602ebfe6fca0e85d93b64f2bc5b5269abfebd9eb573535db20b5
7
- data.tar.gz: eff6ea869f9cfd93dca01e4bc9bfd794a64fb36f51825743ae7f0bef5783e8698b08324b976048b0a360622d6d49de9c355083fac6072007266080e5461aa874
6
+ metadata.gz: 12823e90e21cd1eeefcf883ab5c7ed9a4e9d008b2e26bd80ac6014a05e3b6e6b57e4054a3757574173886b2c8ed6a08e6c8d3a2863f6034eb592e6e8d03da5c1
7
+ data.tar.gz: fb7a48fb211dfb1af4ddd9a0be588eb58318b8ffd445578a09dcacdef625ff9dc8e3dbc593b59a21da18acf678d67d9ca0bd76aef55a22843be9748bfddcf5fa
data/README.md CHANGED
@@ -40,23 +40,51 @@ rates = client.shipping.get_rates(
40
40
  package: {weight: 16, weightUnit: "oz"}
41
41
  )
42
42
 
43
- # Create a label with the cheapest rate
44
- cheapest = rates["rates"].min_by { |r| r["rate"].to_f }
45
- label = client.shipping.create_label(
46
- carrier: cheapest["carrier"],
47
- service: cheapest["service"],
48
- from_address: {name: "Warehouse", street1: "123 Main St", city: "New York", state: "NY", zip: "10001", country: "US"},
49
- to_address: {name: "Customer", street1: "456 Oak Ave", city: "Los Angeles", state: "CA", zip: "90210", country: "US"},
50
- parcel: {weight: 16, weight_unit: "oz"}
51
- )
52
-
53
- puts "Label URL: #{label["data"]["labelUrl"]}"
54
- puts "Tracking: #{label["data"]["trackingNumber"]}"
43
+ request = {
44
+ carrierCode: "USPS", serviceCode: "GROUND_ADVANTAGE",
45
+ origin: {name: "Warehouse", addressLine1: "123 Main St", city: "New York", stateProvince: "NY", postalCode: "10001", countryCode: "US"},
46
+ destination: {name: "Customer", addressLine1: "456 Oak Ave", city: "Los Angeles", stateProvince: "CA", postalCode: "90210", countryCode: "US"},
47
+ package: {weight: 16, weightUnit: "oz"},
48
+ maximumPostageAmount: 10.25, # Caller-approved ceiling in USD.
49
+ # Required without an orderId. The SDK never fills it in; NONE (0) = not hazardous.
50
+ hazmatClassification: FlexOps::HazmatClassification::NONE
51
+ }
52
+ preview = client.shipping.create_label(request)
53
+ puts preview["quotedPostageAmount"]
54
+
55
+ # Call only after explicit caller approval, within five minutes.
56
+ purchase_approved_label = lambda do |purchase_key|
57
+ client.shipping.create_label(
58
+ request.merge(confirmationToken: preview["confirmationToken"]),
59
+ idempotency_key: purchase_key # Persist per purchase; reuse on retries.
60
+ )
61
+ end
55
62
 
56
63
  # Track a shipment
57
64
  info = client.shipping.track("9400111899223456789012")
58
65
  ```
59
66
 
67
+ ### Live label approval (1.1.0+)
68
+
69
+ The example below requires SDK 1.1.0 or later. Version 1.0.2 does not
70
+ include the per-call idempotency argument.
71
+
72
+ For live domestic single-label requests, `maximumPostageAmount` is required: positive
73
+ USD, at most two decimal places, up to 1,000,000. Missing or invalid values return
74
+ 400 `ApprovalRequired`. Omitting `confirmationToken` returns a raw 200 preview
75
+ (`status`, `quotedPostageAmount`, `maximumPostageAmount`, `currency`, `expiresAt`,
76
+ `confirmationToken`). After explicit approval, resubmit the same shipment and ceiling
77
+ with the token and a unique per-purchase `Idempotency-Key` header. The token expires
78
+ after five minutes. A successful purchase returns the raw 201 label, including
79
+ `labelId`, `trackingNumber`, `carrierCode`, and `labelData`, without a `data` wrapper.
80
+
81
+ Keep the same key and request across retries. An uncertain outcome needs reconciliation;
82
+ do not start another purchase with a new key. An expired approval returns 409
83
+ `ApprovalExpired`; obtain and explicitly approve a fresh preview when no purchase is
84
+ unresolved. The ceiling bounds postage authorization, not later adjustments or separate
85
+ fees. Sandbox execution bypasses approval; batch, return, and raw carrier routes have
86
+ separate contracts. The SDK never automatically confirms a preview.
87
+
60
88
  ## Authentication
61
89
 
62
90
  ### API key (recommended)
@@ -69,7 +97,8 @@ client = FlexOps::Client.new(api_key: "fxk_live_...", workspace_id: "ws_abc123")
69
97
 
70
98
  ```ruby
71
99
  client = FlexOps::Client.new(base_url: "https://gateway.flexops.io")
72
- client.auth.login(email: "user@example.com", password: "password")
100
+ session = client.auth.login(email: "user@example.com", password: "password")
101
+ client.set_access_token(session["data"]["token"])
73
102
  client.workspace_id = "ws_abc123"
74
103
  ```
75
104
 
@@ -81,38 +110,176 @@ Use `fxk_test_...` (instead of `fxk_live_...`) to route to the sandbox environme
81
110
  client = FlexOps::Client.new(api_key: "fxk_test_...", workspace_id: "ws_abc123")
82
111
  ```
83
112
 
84
- ## Direct carrier operations
113
+ ## Carrier-specific calls
114
+
115
+ `client.carriers.usps`, `.ups`, `.fedex` and `.dhl` call carrier routes through the legacy
116
+ `/api/ApiProxy` passthrough, which the Gateway retires on 2027-06-30.
117
+
118
+ - Lookups (GET), such as address checks, tracking and DHL rates, work with an API key or a user
119
+ token.
120
+ - The writes (POST, PUT and DELETE, such as `usps.get_domestic_rates`, `fedex.cancel_shipment`
121
+ or `ups.create_pickup`) are deprecated. They need a user token from `auth.login`: API keys get
122
+ 403 `API_KEY_SCOPE_REQUIRED`, and no API-key scope will be added for them. They stop working when
123
+ the proxy is retired.
124
+ - Label generation through the proxy is closed (410 Gone), so the SDK has no carrier label
125
+ method.
126
+
127
+ Use the native routes instead where they cover the call:
128
+
129
+ | Instead of | Use |
130
+ |---|---|
131
+ | Carrier rate calls | `client.shipping.get_rates` |
132
+ | Carrier labels | `client.shipping.create_label` (`client.returns.generate_label` for returns) |
133
+ | Label cancels | `client.shipping.cancel_label` |
134
+ | Carrier pickups | `client.pickups.schedule`, `list`, `get`, `cancel` |
135
+ | USPS scan forms | `client.scan_forms.create` |
136
+ | Address validation | `client.shipping.validate_address` |
137
+ | Tracking | `client.shipping.track` |
138
+
139
+ ```ruby
140
+ # USPS city and state for a ZIP code (works with an API key)
141
+ place = client.carriers.usps.city_state_lookup("10001")
142
+ ```
143
+
144
+ ## Retries and idempotency
145
+
146
+ The client retries a request up to three times with exponential backoff:
147
+
148
+ - GET: after a dropped connection or timeout, and on 429, 500, 502, 503 and 504.
149
+ - POST, PUT and PATCH: after a dropped connection or timeout, and on 429, 502, 503, 504 and
150
+ 409 `IDEMPOTENCY_CONFLICT` (the first request with that key is still running). Never on 500:
151
+ the Gateway does not replay a 5xx, so a retry could run the write (and charge the wallet)
152
+ again.
153
+ - DELETE: only on 429.
154
+
155
+ A key reused with a different request body gets 422 `IDEMPOTENCY_KEY_REUSED`; it is not retried
156
+ and raises `FlexOps::Error` with that `code`. Error codes are matched exactly, so a label
157
+ purchase's own 409 `IdempotencyConflict` (altered inputs under a used key) is not retried either.
158
+
159
+ Every POST, PUT and PATCH carries an `Idempotency-Key` header. Pass your own to
160
+ `shipping.create_label(request, idempotency_key: ...)`, `insurance.purchase(..., idempotency_key: ...)`
161
+ or `carbon_offsets.purchase(..., idempotency_key: ...)`, and store it so a retry your app makes after
162
+ an error or a timeout reuses it; otherwise the client generates one UUID
163
+ per call and sends it on every retry of that call, so the Gateway replays a write it already
164
+ finished instead of running it twice. A 2xx response with no body returns `nil`.
165
+
166
+ ## Workspace members
167
+
168
+ Roles are the Gateway `WorkspaceRole` numbers (Owner 0, Admin 1, Member 2, Merchant 3). Pass a
169
+ `FlexOps::WorkspaceRole` constant or a name; the SDK sends the number.
170
+
171
+ ```ruby
172
+ client.workspaces.invite_member(email: "ops@example.com", role: :member)
173
+ client.workspaces.update_member_role(user_id, FlexOps::WorkspaceRole::ADMIN)
174
+
175
+ result = client.workspaces.list_members
176
+ members = result["data"]["members"] # also "pendingInvites", "userLimit", "canInviteMore"
177
+ ```
178
+
179
+ ## Recurring shipments, report schedules and email templates
85
180
 
86
- Access carrier-specific endpoints when you need full control:
181
+ Reads work with any API key or a user token. Writes (every POST, PUT and DELETE, including the
182
+ email template preview) need a user token from `auth.login` or an API key granted the
183
+ resource's opt-in scope: `recurring-shipments:write`, `report-schedules:write` or
184
+ `email-templates:write`. Older keys do not have these scopes; a key without one gets 403
185
+ `API_KEY_SCOPE_REQUIRED` with `requiredScopes`. Enums are sent as numbers and ids are GUID
186
+ strings.
87
187
 
88
188
  ```ruby
89
- # USPS domestic label
90
- label = client.carriers.usps.create_domestic_label(
91
- image_type: "PDF",
92
- mail_class: "PRIORITY_MAIL",
93
- weight_in_ounces: 16
189
+ # Recurring shipments (bare JSON). interval: Daily 0, Weekly 1, Biweekly 2, Monthly 3, Custom 4
190
+ schedule = client.recurring_shipments.create(
191
+ name: "Weekly restock", addressId: address_id, presetId: preset_id,
192
+ interval: 1, firstRunUtc: "2026-11-02T14:00:00Z"
94
193
  )
194
+ client.recurring_shipments.pause(schedule["id"]) # nil (204); also resume, delete
195
+ client.recurring_shipments.trigger(schedule["id"], idempotency_key: run_key) # creates an order now
196
+
197
+ # Report schedules ({ success, data, message } envelope).
198
+ # format: Csv 0, Json 1; frequencyType: Daily 0, Weekly 1, Monthly 2
199
+ report = client.report_schedules.create(
200
+ reportType: "shipments", format: 0, frequencyType: 1, dayOfWeek: 1,
201
+ timeOfDayUtc: "08:00:00", recipientEmails: "ops@example.com"
202
+ )["data"]
203
+ client.report_schedules.toggle(report["id"]) # flips isEnabled
204
+
205
+ # Tracking email templates (bare JSON), one per event. eventType: LabelCreated 0, InTransit 1,
206
+ # OutForDelivery 2, Delivered 3, Exception 4, ReturnToSender 5
207
+ client.email_templates.upsert(eventType: 3, subjectTemplate: "Delivered: {{tracking_number}}",
208
+ htmlBodyTemplate: "<p>Your package arrived.</p>")
209
+ client.email_templates.preview(subject_template: "Hi {{recipient_name}}", html_body_template: "<p>{{status}}</p>")
210
+ ```
95
211
 
96
- # FedEx rate quote
97
- rates = client.carriers.fedex.get_rates(...)
212
+ ## Wallet balance
98
213
 
99
- # UPS tracking
100
- info = client.carriers.ups.track(tracking_number: "1Z999AA10123456784")
214
+ ```ruby
215
+ balance = client.wallet.get_balance # {"hasWallet" => true, "balanceCents" => 1250, "balance" => 12.5}
216
+ ```
217
+
218
+ The request carries `X-Workspace-Id` set to the client's `workspace_id`. Funding and
219
+ transaction history are managed in the FlexOps portal.
220
+
221
+ ## Webhook subscriptions
101
222
 
102
- # DHL shipment
103
- shipment = client.carriers.dhl.create_shipment(...)
223
+ ```ruby
224
+ # Leave events out to receive every event.
225
+ webhook = client.webhooks.create(
226
+ url: "https://your-app.com/webhooks/flexops",
227
+ events: [FlexOps::WebhookEventType::LABEL_CREATED,
228
+ FlexOps::WebhookEventType::LABEL_CANCELED,
229
+ FlexOps::WebhookEventType::BATCH_COMPLETED]
230
+ )
231
+ signing_secret = webhook["secret"] # "whsec_...", returned only on create; store it
232
+
233
+ # Change the events (or url, description, status: "Active", "Paused", "Disabled").
234
+ client.webhooks.update(webhook["id"], events: [FlexOps::WebhookEventType::LABEL_CREATED])
104
235
  ```
105
236
 
237
+ `create` returns the subscription itself (`"id"`, `"url"`, `"eventTypes"`, `"status"`, `"secret"`, ...), because the Gateway answers it with the bare subscription. The other webhook methods return the usual `{"success" => true, "data" => ...}` envelope.
238
+
239
+ `events` is sent as the Gateway's comma-separated `eventTypes`. FlexOps sends these events, named exactly as below (`FlexOps::WebhookEventType::ALL` lists them). Names are PascalCase and matched exactly, so a name like `label.created` would never match; `create` and `update` raise `ArgumentError`, before any request, for an unknown name, an empty list or a non-array.
240
+
241
+ | Event | Sent when |
242
+ |---|---|
243
+ | `LabelCreated` | A live label is purchased (sandbox labels send nothing) |
244
+ | `LabelCanceled` | A live label is voided |
245
+ | `BatchCompleted` | A batch label job finishes |
246
+ | `TrackingUpdated` | A USPS tracking scan arrives (USPS push-tracking pilot workspaces only) |
247
+ | `TrackingDelivered` | A USPS package is delivered (USPS push-tracking pilot workspaces only) |
248
+
249
+ You can send a raw `eventTypes:` string (`"*"` or names joined by commas with no spaces) instead of `events:`; it is passed through unchecked, for example to subscribe to an event newer than your SDK version.
250
+
106
251
  ## Webhook verification
107
252
 
253
+ FlexOps signs each delivery with HMAC-SHA256 over `{X-FlexOps-Timestamp}.{raw body}`, keyed with your subscription secret (`whsec_...`, used as-is), and sends it as `X-FlexOps-Signature: sha256=<hex>`. Verify the raw body before you parse it.
254
+
108
255
  ```ruby
109
- valid = FlexOps::Resources::Webhooks.verify_signature(
110
- payload: request.body.read,
111
- signature: request.headers["X-FlexOps-Signature"],
112
- secret: "whsec_..."
113
- )
256
+ # Rails controller action
257
+ def flexops_webhook
258
+ payload = request.raw_post
259
+
260
+ valid = FlexOps::Resources::Webhooks.verify_signature(
261
+ payload: payload,
262
+ signature: request.headers["X-FlexOps-Signature"], # "sha256=..."
263
+ timestamp: request.headers["X-FlexOps-Timestamp"], # Unix seconds
264
+ secret: ENV.fetch("FLEXOPS_WEBHOOK_SECRET") # "whsec_..."
265
+ )
266
+ return head :unauthorized unless valid
267
+
268
+ # The body is the event data itself (no type/data envelope).
269
+ # The event name is in a header; test events send "test".
270
+ data = JSON.parse(payload)
271
+ case request.headers["X-FlexOps-Event"]
272
+ when "test"
273
+ # data: {"type"=>"test", "message"=>"...", "timestamp"=>"...", "subscriptionId"=>"..."}
274
+ when "TrackingUpdated"
275
+ # data["trackingNumber"], data["status"], ...
276
+ end
277
+ head :ok
278
+ end
114
279
  ```
115
280
 
281
+ Deliveries whose timestamp is more than 300 seconds from your clock (either way) are rejected to limit replays; pass `tolerance:` (seconds) to change that. `verify_signature!` takes the same arguments and raises `FlexOps::WebhookSignatureError` instead of returning `false`; its `code` says why (`WEBHOOK_SIGNATURE_MISMATCH`, `WEBHOOK_TIMESTAMP_OUTSIDE_TOLERANCE`, `WEBHOOK_INVALID_TIMESTAMP`, `WEBHOOK_MISSING_SIGNATURE`, `WEBHOOK_MISSING_SECRET`).
282
+
116
283
  ## Curl quickstart
117
284
 
118
285
  Every SDK method is a thin wrapper around the FlexOps REST API. If you want to verify the API before committing to the SDK — or you're integrating from a language we don't ship a SDK for — these curl invocations hit the same endpoints:
@@ -128,24 +295,30 @@ curl -X POST https://gateway.flexops.io/api/shipping/rates \
128
295
  "package": {"weight": 16, "weightUnit": "oz"}
129
296
  }'
130
297
 
131
- # Create a label
132
- curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/labels \
298
+ # Preview a live label; this does not purchase it.
299
+ # hazmatClassification 0 = not hazardous; required when there is no orderId.
300
+ curl -X POST https://gateway.flexops.io/api/shipping/labels \
133
301
  -H "X-API-Key: fxk_live_..." \
134
302
  -H "Content-Type: application/json" \
135
303
  -d '{
136
- "carrier": "USPS",
137
- "service": "PRIORITY_MAIL",
138
- "fromAddress": {"name": "Warehouse", "street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
139
- "toAddress": {"name": "Customer", "street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
140
- "parcel": {"weight": 16, "weightUnit": "oz"}
304
+ "carrierCode": "USPS", "serviceCode": "GROUND_ADVANTAGE",
305
+ "origin": {"name": "Warehouse", "addressLine1": "123 Main St", "city": "New York", "stateProvince": "NY", "postalCode": "10001", "countryCode": "US"},
306
+ "destination": {"name": "Customer", "addressLine1": "456 Oak Ave", "city": "Los Angeles", "stateProvince": "CA", "postalCode": "90210", "countryCode": "US"},
307
+ "package": {"weight": 16, "weightUnit": "oz"},
308
+ "maximumPostageAmount": 10.25,
309
+ "hazmatClassification": 0
141
310
  }'
142
311
 
312
+ # After explicit approval, resend the same body with confirmationToken from
313
+ # the preview and an Idempotency-Key header unique to this purchase.
314
+ # See the SDK example above; retain that key for retries.
315
+
143
316
  # Track a shipment
144
- curl https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/track/9400111899223456789012 \
317
+ curl https://gateway.flexops.io/api/shipping/track/9400111899223456789012 \
145
318
  -H "X-API-Key: fxk_live_..."
146
319
 
147
- # Cancel a label (via the unified carrier-agnostic endpoint)
148
- curl -X DELETE https://gateway.flexops.io/api/v3.0/shipping/Usps/cancel/9400111899223456789012 \
320
+ # Cancel a label
321
+ curl -X DELETE "https://gateway.flexops.io/api/shipping/labels/lbl_123?carrierCode=USPS" \
149
322
  -H "X-API-Key: fxk_live_..."
150
323
  ```
151
324
 
@@ -155,26 +328,27 @@ Use an `fxk_test_...` key instead of `fxk_live_...` to hit the sandbox environme
155
328
 
156
329
  | Resource | Description |
157
330
  |----------|-------------|
158
- | `client.auth` | Login, register, password management |
159
- | `client.workspaces` | Workspace CRUD, membership, branding |
160
- | `client.shipping` | Rate shopping, labels, tracking, batch, cancel |
161
- | `client.carriers` | USPS, UPS, FedEx, DHL direct endpoints |
162
- | `client.webhooks` | Subscription CRUD, signature verification, delivery logs |
163
- | `client.wallet` | Balance, transactions, auto-reload |
164
- | `client.insurance` | Quotes, purchase, claims (first-party + U-PIC) |
165
- | `client.returns` | RMA lifecycle: create, batch, QR codes, photo upload, cost recovery |
166
- | `client.api_keys` | Key creation, rotation, revocation |
167
- | `client.analytics` | Shipments, orders, carrier performance |
168
- | `client.orders` | Order management |
169
- | `client.inventory` | Warehouse inventory |
170
- | `client.pickups` | Carrier pickup scheduling |
331
+ | `client.auth` | Login, token refresh, logout |
332
+ | `client.workspaces` | List and read workspaces; list, invite and remove members, change roles |
333
+ | `client.shipping` | Rate shopping, labels, tracking, address validation, batch, cancel |
334
+ | `client.carriers` | USPS, UPS, FedEx and DHL calls through the legacy proxy; writes are deprecated and need a user token |
335
+ | `client.webhooks` | Subscription create/update/delete, secret rotation, test events, delivery logs, signature verification |
336
+ | `client.wallet` | Workspace balance |
337
+ | `client.insurance` | Providers, quotes, policies, void, claims |
338
+ | `client.returns` | List and read returns; create RMAs, return labels, receive |
339
+ | `client.analytics` | Shipments, orders, carrier performance (legacy proxy reads) |
340
+ | `client.orders` | Order reads (legacy proxy) |
341
+ | `client.inventory` | Inventory reads (legacy proxy) |
342
+ | `client.pickups` | Schedule, list, read and cancel carrier pickups |
171
343
  | `client.scan_forms` | USPS scan forms |
172
- | `client.rules` | Shipping automation rules |
173
- | `client.offsets` | Carbon offset purchases |
174
- | `client.hs_codes` | HS code lookup for international customs |
175
- | `client.recurring_shipments` | Scheduled recurring shipments |
176
- | `client.email_templates` | Branded post-purchase email templates |
177
- | `client.reports` | Report generation and scheduled delivery |
344
+ | `client.rules` | Shipping rules: create, read, update, delete, reorder, test |
345
+ | `client.hs_codes` | HS code search and lookup, landed cost |
346
+ | `client.carbon_offsets` | Carbon offset quotes, purchases, summary and settings |
347
+ | `client.recurring_shipments` | Recurring shipment schedules: create, update, pause, resume, trigger, delete |
348
+ | `client.report_schedules` | Scheduled report emails: create, update, toggle, delete |
349
+ | `client.email_templates` | Tracking email templates: upsert, preview, delete |
350
+
351
+ API keys, workspace settings and account management are managed in the FlexOps portals.
178
352
 
179
353
  ## Configuration
180
354
 
@@ -189,7 +363,7 @@ client = FlexOps::Client.new(
189
363
 
190
364
  ## Requirements
191
365
 
192
- - Ruby 3.0+
366
+ - Ruby 3.1+
193
367
 
194
368
  ## License
195
369
 
@@ -10,9 +10,9 @@ module FlexOps
10
10
  class Client
11
11
  attr_accessor :workspace_id
12
12
  attr_reader :auth, :workspaces, :shipping, :carriers, :webhooks, :wallet,
13
- :insurance, :returns, :api_keys, :analytics, :orders, :inventory,
14
- :pickups, :scan_forms, :rules, :offsets, :hs_codes,
15
- :recurring_shipments, :email_templates, :reports
13
+ :insurance, :returns, :analytics, :orders, :inventory,
14
+ :pickups, :scan_forms, :rules, :hs_codes, :carbon_offsets,
15
+ :recurring_shipments, :report_schedules, :email_templates
16
16
 
17
17
  def initialize(api_key: nil, access_token: nil, base_url: "https://gateway.flexops.io", workspace_id: nil, timeout: 30)
18
18
  @http = HttpClient.new(base_url: base_url, api_key: api_key, access_token: access_token, timeout: timeout)
@@ -28,18 +28,17 @@ module FlexOps
28
28
  @wallet = Resources::Wallet.new(@http, ws_id_proc)
29
29
  @insurance = Resources::Insurance.new(@http, ws_id_proc)
30
30
  @returns = Resources::Returns.new(@http, ws_id_proc)
31
- @api_keys = Resources::ApiKeys.new(@http, ws_id_proc)
32
31
  @analytics = Resources::Analytics.new(@http)
33
32
  @orders = Resources::Orders.new(@http)
34
33
  @inventory = Resources::Inventory.new(@http)
35
34
  @pickups = Resources::Pickups.new(@http, ws_id_proc)
36
35
  @scan_forms = Resources::ScanForms.new(@http, ws_id_proc)
37
36
  @rules = Resources::Rules.new(@http, ws_id_proc)
38
- @offsets = Resources::Offsets.new(@http, ws_id_proc)
39
- @hs_codes = Resources::HsCodes.new(@http, ws_id_proc)
37
+ @hs_codes = Resources::HsCodes.new(@http)
38
+ @carbon_offsets = Resources::CarbonOffsets.new(@http, ws_id_proc)
40
39
  @recurring_shipments = Resources::RecurringShipments.new(@http, ws_id_proc)
40
+ @report_schedules = Resources::ReportSchedules.new(@http, ws_id_proc)
41
41
  @email_templates = Resources::EmailTemplates.new(@http, ws_id_proc)
42
- @reports = Resources::Reports.new(@http, ws_id_proc)
43
42
  end
44
43
 
45
44
  def set_access_token(token)
@@ -32,4 +32,13 @@ module FlexOps
32
32
  @retry_after = retry_after
33
33
  end
34
34
  end
35
+
36
+ # Raised by Resources::Webhooks.verify_signature! when a webhook delivery
37
+ # is not authentic or not fresh. +code+ says why, for example
38
+ # "WEBHOOK_SIGNATURE_MISMATCH" or "WEBHOOK_TIMESTAMP_OUTSIDE_TOLERANCE".
39
+ class WebhookSignatureError < Error
40
+ def initialize(message, code:)
41
+ super(message, code: code)
42
+ end
43
+ end
35
44
  end
@@ -0,0 +1,34 @@
1
+ # ***********************************************************************
2
+ # Package : flexops
3
+ # Author : FlexOps, LLC
4
+ # Created : 2026-10-12
5
+ #
6
+ # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
+ # ***********************************************************************
8
+
9
+ module FlexOps
10
+ # USPS HAZMAT classification, sent as the Gateway HazmatClassification number.
11
+ #
12
+ # There is no default: leave hazmatClassification out when you have no answer, or send
13
+ # HazmatClassification::NONE (0) to declare that the parcel holds no dangerous goods.
14
+ # A label without an orderId must declare one.
15
+ module HazmatClassification
16
+ NONE = 0
17
+ LIMITED_QUANTITY = 1
18
+ LITHIUM_BATTERY_CONTAINED_IN_EQUIPMENT = 2
19
+ LITHIUM_BATTERY_PACKED_WITH_EQUIPMENT = 3
20
+ LITHIUM_BATTERY_STANDALONE = 4
21
+ OTHER_RESTRICTED = 5
22
+ LITHIUM_BATTERY_USED_DEVICE = 6
23
+
24
+ ALL = {
25
+ NONE: NONE,
26
+ LIMITED_QUANTITY: LIMITED_QUANTITY,
27
+ LITHIUM_BATTERY_CONTAINED_IN_EQUIPMENT: LITHIUM_BATTERY_CONTAINED_IN_EQUIPMENT,
28
+ LITHIUM_BATTERY_PACKED_WITH_EQUIPMENT: LITHIUM_BATTERY_PACKED_WITH_EQUIPMENT,
29
+ LITHIUM_BATTERY_STANDALONE: LITHIUM_BATTERY_STANDALONE,
30
+ OTHER_RESTRICTED: OTHER_RESTRICTED,
31
+ LITHIUM_BATTERY_USED_DEVICE: LITHIUM_BATTERY_USED_DEVICE
32
+ }.freeze
33
+ end
34
+ end