@nodrel-dev/n8n-nodes-ups 0.3.1 → 0.4.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.
- package/README.md +45 -13
- package/dist/credentials/UpsOAuth2Api.credentials.js +1 -1
- package/dist/credentials/UpsOAuth2Api.credentials.js.map +1 -1
- package/dist/credentials/UpsShipperProfileApi.credentials.d.ts +8 -0
- package/dist/credentials/UpsShipperProfileApi.credentials.js +76 -0
- package/dist/credentials/UpsShipperProfileApi.credentials.js.map +1 -0
- package/dist/nodes/Ups/Ups.node.d.ts +6 -1
- package/dist/nodes/Ups/Ups.node.js +37 -1
- package/dist/nodes/Ups/Ups.node.js.map +1 -1
- package/dist/nodes/Ups/Ups.node.json +2 -2
- package/dist/nodes/Ups/core/buildRateRequest.d.ts +34 -0
- package/dist/nodes/Ups/core/buildRateRequest.js +33 -0
- package/dist/nodes/Ups/core/buildRateRequest.js.map +1 -0
- package/dist/nodes/Ups/core/buildShipmentRequest.d.ts +33 -0
- package/dist/nodes/Ups/core/buildShipmentRequest.js +57 -0
- package/dist/nodes/Ups/core/buildShipmentRequest.js.map +1 -0
- package/dist/nodes/Ups/core/buildShipmentResult.d.ts +18 -0
- package/dist/nodes/Ups/core/buildShipmentResult.js +34 -0
- package/dist/nodes/Ups/core/buildShipmentResult.js.map +1 -0
- package/dist/nodes/Ups/resources/address/validate.operation.js +8 -1
- package/dist/nodes/Ups/resources/address/validate.operation.js.map +1 -1
- package/dist/nodes/Ups/resources/shipping/create.operation.js +150 -202
- package/dist/nodes/Ups/resources/shipping/create.operation.js.map +1 -1
- package/dist/nodes/Ups/resources/shipping/getRates.operation.js +50 -48
- package/dist/nodes/Ups/resources/shipping/getRates.operation.js.map +1 -1
- package/dist/nodes/Ups/resources/shipping/{shared.d.ts → readParties.d.ts} +13 -13
- package/dist/nodes/Ups/resources/shipping/readParties.js +60 -0
- package/dist/nodes/Ups/resources/shipping/readParties.js.map +1 -0
- package/dist/nodes/Ups/resources/shipping/shipperProfile.d.ts +25 -0
- package/dist/nodes/Ups/resources/shipping/shipperProfile.js +40 -0
- package/dist/nodes/Ups/resources/shipping/shipperProfile.js.map +1 -0
- package/dist/nodes/Ups/resources/shipping/shippingFields.d.ts +18 -0
- package/dist/nodes/Ups/resources/shipping/{shared.js → shippingFields.js} +52 -44
- package/dist/nodes/Ups/resources/shipping/shippingFields.js.map +1 -0
- package/dist/package.json +5 -4
- package/package.json +5 -4
- package/dist/nodes/Ups/resources/shipping/shared.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@ Track shipments · validate addresses · quote rates · create labels (with inte
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@nodrel-dev/n8n-nodes-ups)
|
|
10
10
|
[](https://www.npmjs.com/package/@nodrel-dev/n8n-nodes-ups)
|
|
11
|
-
[](https://github.com/nodrel-dev/n8n-ups-node/actions/workflows/ci.yml)
|
|
12
12
|
[](https://www.npmjs.com/package/@nodrel-dev/n8n-nodes-ups)
|
|
13
13
|
[](https://www.npmjs.com/package/@nodrel-dev/n8n-nodes-ups#provenance)
|
|
14
14
|
|
|
15
|
-
[Installation](#installation) · [Operations](#operations) · [Credentials](#credentials) · [Usage](#usage) · [npm](https://www.npmjs.com/package/@nodrel-dev/n8n-nodes-ups) · [UPS Developer Portal](https://developer.ups.com/) · [Report an issue](https://github.com/nodrel-dev/n8n-
|
|
15
|
+
[Installation](#installation) · [Operations](#operations) · [Credentials](#credentials) · [Shipper Profiles](#shipper-profiles) · [Usage](#usage) · [npm](https://www.npmjs.com/package/@nodrel-dev/n8n-nodes-ups) · [UPS Developer Portal](https://developer.ups.com/) · [Report an issue](https://github.com/nodrel-dev/n8n-ups-node/issues)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -57,13 +57,35 @@ flowchart LR
|
|
|
57
57
|
ups -->|"HTTPS + bearer token"| api["UPS REST API<br/>(your account and rates)"]
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
### A typical workflow
|
|
61
|
+
|
|
62
|
+
A common fulfillment pipeline wires the four operations together — clean the address, shop for a rate, buy the label, then hand the label binary to wherever it needs to go. Each step is a normal n8n node, so you can branch, filter, or store results at any point.
|
|
63
|
+
|
|
64
|
+
```mermaid
|
|
65
|
+
flowchart LR
|
|
66
|
+
trigger["Order trigger<br/>(Webhook / Sheets / DB)"] --> validate["UPS · Validate Address"]
|
|
67
|
+
validate --> rates["UPS · Get Rates"]
|
|
68
|
+
rates --> pick["Pick service<br/>(cheapest / fastest)"]
|
|
69
|
+
pick --> create["UPS · Create Shipment"]
|
|
70
|
+
create -->|"label binary"| save["Write Binary File<br/>/ Send Email"]
|
|
71
|
+
create -->|"tracking number"| notify["Notify customer<br/>/ update order"]
|
|
72
|
+
notify -.->|"later"| track["UPS · Track"]
|
|
73
|
+
```
|
|
74
|
+
|
|
60
75
|
## Installation
|
|
61
76
|
|
|
62
77
|
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation. In n8n, go to **Settings → Community Nodes → Install** and enter `@nodrel-dev/n8n-nodes-ups`.
|
|
63
78
|
|
|
64
79
|
## Operations
|
|
65
80
|
|
|
66
|
-
The node exposes three resources
|
|
81
|
+
The node exposes three resources — **Tracking**, **Address**, and **Shipping** — across four operations:
|
|
82
|
+
|
|
83
|
+
| Resource | Operation | UPS endpoint | Returns |
|
|
84
|
+
| --- | --- | --- | --- |
|
|
85
|
+
| 📍 Tracking | **Track** | `GET /track/v1/details/{number}` | Current status + scan history, one inquiry number per item |
|
|
86
|
+
| 🏠 Address | **Validate** | `POST /addressvalidation/v2/3` | Standardized `candidates[]`, `resolution`, residential/commercial `classification` |
|
|
87
|
+
| 📦 Shipping | **Get Rates** | `POST /rating/v2409/Shoptimeintransit` | One item per eligible service — published + negotiated price, transit days, alerts |
|
|
88
|
+
| 📦 Shipping | **Create** | `POST /shipments/v2409/ship` | Tracking number + charges, plus the label as binary (and the customs invoice PDF for international) |
|
|
67
89
|
|
|
68
90
|
```mermaid
|
|
69
91
|
flowchart TD
|
|
@@ -99,8 +121,8 @@ Standardize an address and classify it residential vs commercial (`POST /address
|
|
|
99
121
|
|
|
100
122
|
Quote published and negotiated rates with transit times for every eligible service (`POST /rating/v2409/Shoptimeintransit`).
|
|
101
123
|
|
|
102
|
-
- **Account Number** (required) — your ShipperNumber; also requests negotiated rates.
|
|
103
|
-
- Shipper / Ship To (and optional Ship From) addresses, package weight (+ unit) and optional dimensions (+ unit).
|
|
124
|
+
- **Account Number** (required) — your ShipperNumber; also requests negotiated rates. May instead be supplied by a [Shipper Profile](#shipper-profiles) credential.
|
|
125
|
+
- Shipper / Ship To (and optional Ship From) addresses, package weight (+ unit) and optional dimensions (+ unit). The Shipper block can be filled from a [Shipper Profile](#shipper-profiles).
|
|
104
126
|
- **Customs Value** — required when origin and destination countries differ (international).
|
|
105
127
|
- Emits **one output item per service**, each with published + negotiated price, transit days, and any UPS alerts. If no negotiated rates are returned, a request-level alert is attached to the first item.
|
|
106
128
|
|
|
@@ -108,8 +130,8 @@ Quote published and negotiated rates with transit times for every eligible servi
|
|
|
108
130
|
|
|
109
131
|
Buy a shipment and get a printable label plus tracking number (`POST /shipments/v2409/ship`).
|
|
110
132
|
|
|
111
|
-
- **Account Number** (required), **Service
|
|
112
|
-
- **International** (origin ≠ destination country) additionally requires the
|
|
133
|
+
- **Account Number** (required; or supplied by a [Shipper Profile](#shipper-profiles)), **Service** (dropdown of UPS service codes; Ground/`03` default), Shipper / Ship To (and optional Ship From), package weight/dimensions, **Label Format** (GIF default; ZPL / EPL / SPL — no PDF label). The Shipper block can be filled from a [Shipper Profile](#shipper-profiles).
|
|
134
|
+
- **International** (origin ≠ destination country) additionally requires the **Customs** fields (a collapsible group: reason for export, currency, terms of shipment, invoice number/date), the **Sold To** party, and at least one **Commodities** line.
|
|
113
135
|
- Returns the tracking number and account/published charges, plus the **label** as a binary attachment (`label`); international shipments also return the **commercial invoice** PDF (`customsInvoice`). Label/invoice image data is never embedded as a string in the JSON output.
|
|
114
136
|
|
|
115
137
|
Billing is to the shipper (transportation charges); international duties are billed to the receiver (DDU) in this version.
|
|
@@ -124,13 +146,14 @@ You authenticate with a UPS **Client ID** and **Client Secret** using OAuth2 cli
|
|
|
124
146
|
2. Note its **Client ID** and **Client Secret**. A single UPS OAuth app entitles all four APIs used here (Track, Address Validation, Rating, Ship), so one credential covers every operation.
|
|
125
147
|
3. For Get Rates and Create you also need your UPS **account number** (ShipperNumber).
|
|
126
148
|
|
|
127
|
-
###
|
|
149
|
+
### Credential types
|
|
128
150
|
|
|
129
|
-
The node
|
|
151
|
+
The node authenticates with a single credential, **UPS OAuth2 API**, for all four operations. An optional, non-auth **UPS Shipper Profile API** credential can also be attached to supply reusable Shipper data (see [Shipper Profiles](#shipper-profiles)).
|
|
130
152
|
|
|
131
|
-
| Credential type | Used by |
|
|
132
|
-
| --------------- | ------- |
|
|
133
|
-
| `upsOAuth2Api` | Track, Validate, Get Rates, Create |
|
|
153
|
+
| Credential type | Required | Used by |
|
|
154
|
+
| --------------- | -------- | ------- |
|
|
155
|
+
| `upsOAuth2Api` | Yes | Track, Validate, Get Rates, Create (authenticates every request) |
|
|
156
|
+
| `upsShipperProfileApi` | No | Get Rates, Create (fills the Shipper block; never authenticates) |
|
|
134
157
|
|
|
135
158
|
### Set up a credential in n8n
|
|
136
159
|
|
|
@@ -152,11 +175,20 @@ Grant type is OAuth2 **client credentials** (HTTP Basic, empty scope) — config
|
|
|
152
175
|
|
|
153
176
|
The Customer Integration Environment (CIE) is limited test data — for example, address validation returns street-level results for **US NY/CA** addresses only, and Track returns a canned `DELIVERED` response for any well-formed `1Z` number.
|
|
154
177
|
|
|
178
|
+
### Shipper Profiles
|
|
179
|
+
|
|
180
|
+
Re-entering the same Shipper block on every Get Rates and Create call is the biggest source of form friction — and getting the Shipper country wrong for the account makes UPS reject the call (`111617` Rate / `120120` Ship). An **optional** second credential, **UPS Shipper Profile API**, stores reusable Shipper data so you can swap the whole block (including the account number) by selecting a profile — handy when you ship from more than one registered account (e.g. a Canada-registered and a US account).
|
|
181
|
+
|
|
182
|
+
- **What it holds:** Account Number (ShipperNumber), Shipper Name, Address (lines, city, state/province, postal, country), and Phone. It carries **no secret** and never authenticates a request — `UPS OAuth2 API` is still the only credential that talks to UPS. Keeping the account number here also keeps it out of the workflow JSON.
|
|
183
|
+
- **How to use it:** create a **UPS Shipper Profile API** credential, fill the Shipper fields, then attach it to the UPS node (alongside the OAuth credential). Its **Test** button runs an offline check that the profile is internally usable.
|
|
184
|
+
- **Precedence (per field):** an explicit value typed on the node **always wins**; a field left **blank** inherits from the profile; if neither supplies it, the built-in default applies (Shipper country falls back to `US`). So you can use a profile for most fields and still override one in place.
|
|
185
|
+
- **Caveat:** profile values fill **at run time**, not in the editor — the fields stay blank in the form and are merged when the workflow executes. (Stock n8n has no way for a community node to write sibling editor fields; see [ADR-0005](docs/adr/0005-optional-shipper-profile-credential.md).)
|
|
186
|
+
|
|
155
187
|
## Compatibility
|
|
156
188
|
|
|
157
189
|
- Requires n8n with `n8nNodesApiVersion: 1`.
|
|
158
190
|
- Built and tested against the UPS REST API (Track v1, Address Validation v2, Rating v2409, Ship v2409).
|
|
159
|
-
- The account number is never defaulted or hardcoded — it
|
|
191
|
+
- The account number is never defaulted or hardcoded — it comes from the node field or an optional [Shipper Profile](#shipper-profiles) credential, and your API keys live only in the credential.
|
|
160
192
|
|
|
161
193
|
## Security & dependencies
|
|
162
194
|
|
|
@@ -15,7 +15,7 @@ class UpsOAuth2Api {
|
|
|
15
15
|
this.extends = ['oAuth2Api'];
|
|
16
16
|
this.displayName = 'UPS OAuth2 API';
|
|
17
17
|
this.icon = 'file:ups.svg';
|
|
18
|
-
this.documentationUrl = 'https://github.com/nodrel-dev/n8n-
|
|
18
|
+
this.documentationUrl = 'https://github.com/nodrel-dev/n8n-ups-node?tab=readme-ov-file#credentials';
|
|
19
19
|
this.properties = [
|
|
20
20
|
{
|
|
21
21
|
displayName: 'Environment',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpsOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/UpsOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AASA,MAAM,SAAS,GAAG;IACjB,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,qDAAqD;CACjE,CAAC;AAGF,MAAM,QAAQ,GAAG;IAChB,OAAO,EAAE,wBAAwB;IACjC,UAAU,EAAE,6BAA6B;CACzC,CAAC;AAEF,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QAEtB,YAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QAExB,gBAAW,GAAG,gBAAgB,CAAC;QAE/B,SAAI,GAAS,cAAc,CAAC;QAE5B,qBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"UpsOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/UpsOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AASA,MAAM,SAAS,GAAG;IACjB,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,qDAAqD;CACjE,CAAC;AAGF,MAAM,QAAQ,GAAG;IAChB,OAAO,EAAE,wBAAwB;IACjC,UAAU,EAAE,6BAA6B;CACzC,CAAC;AAEF,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QAEtB,YAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QAExB,gBAAW,GAAG,gBAAgB,CAAC;QAE/B,SAAI,GAAS,cAAc,CAAC;QAE5B,qBAAgB,GAAG,2EAA2E,CAAC;QAE/F,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE;oBACR,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,EAAE;oBAC3C,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;iBAC3C;gBACD,OAAO,EAAE,SAAS;gBAClB,WAAW,EACV,sIAAsI;aACvI;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;aAC5B;YACD;gBAGC,WAAW,EAAE,kBAAkB;gBAC/B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,gDAAgD,SAAS,CAAC,UAAU,QAAQ,SAAS,CAAC,OAAO,MAAM;aAC5G;YACD;gBACC,WAAW,EAAE,2BAA2B;gBACxC,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBAEC,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBAGC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,QAAQ;aACjB;SACD,CAAC;QAWF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,oDAAoD,QAAQ,CAAC,UAAU,QAAQ,QAAQ,CAAC,OAAO,MAAM;gBAC9G,GAAG,EAAE,2CAA2C;gBAChD,MAAM,EAAE,KAAK;gBAKb,OAAO,EAAE;oBACR,OAAO,EAAE,wBAAwB;oBACjC,cAAc,EAAE,eAAe;iBAC/B;aACD;SACD,CAAC;IACH,CAAC;CAAA;AArFD,oCAqFC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Icon, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class UpsShipperProfileApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
icon: Icon;
|
|
6
|
+
documentationUrl: string;
|
|
7
|
+
properties: INodeProperties[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpsShipperProfileApi = void 0;
|
|
4
|
+
class UpsShipperProfileApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'upsShipperProfileApi';
|
|
7
|
+
this.displayName = 'UPS Shipper Profile API';
|
|
8
|
+
this.icon = 'file:ups.svg';
|
|
9
|
+
this.documentationUrl = 'https://github.com/nodrel-dev/n8n-ups-node?tab=readme-ov-file#shipper-profiles';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Account Number',
|
|
13
|
+
name: 'accountNumber',
|
|
14
|
+
type: 'string',
|
|
15
|
+
default: '',
|
|
16
|
+
description: 'UPS account number (ShipperNumber). Must match the country registered for this account, or UPS rejects the call (111617 Rate / 120120 Ship).',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Shipper Name',
|
|
20
|
+
name: 'shipperName',
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: '',
|
|
23
|
+
description: 'Shipper contact/company name',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Address Line 1',
|
|
27
|
+
name: 'addressLine1',
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: '',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
displayName: 'Address Line 2',
|
|
33
|
+
name: 'addressLine2',
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: '',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
displayName: 'City',
|
|
39
|
+
name: 'city',
|
|
40
|
+
type: 'string',
|
|
41
|
+
default: '',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'State / Province Code',
|
|
45
|
+
name: 'stateProvinceCode',
|
|
46
|
+
type: 'string',
|
|
47
|
+
default: '',
|
|
48
|
+
placeholder: 'NY',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Postal Code',
|
|
52
|
+
name: 'postalCode',
|
|
53
|
+
type: 'string',
|
|
54
|
+
default: '',
|
|
55
|
+
placeholder: '10001',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Country Code',
|
|
59
|
+
name: 'countryCode',
|
|
60
|
+
type: 'string',
|
|
61
|
+
default: '',
|
|
62
|
+
placeholder: 'US',
|
|
63
|
+
description: 'Two-letter country code (e.g. US, CA). Must match the account registration.',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
displayName: 'Phone',
|
|
67
|
+
name: 'phone',
|
|
68
|
+
type: 'string',
|
|
69
|
+
default: '',
|
|
70
|
+
description: 'Shipper phone number. UPS may require this for cross-border shipments.',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.UpsShipperProfileApi = UpsShipperProfileApi;
|
|
76
|
+
//# sourceMappingURL=UpsShipperProfileApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpsShipperProfileApi.credentials.js","sourceRoot":"","sources":["../../credentials/UpsShipperProfileApi.credentials.ts"],"names":[],"mappings":";;;AAmBA,MAAa,oBAAoB;IAAjC;QACC,SAAI,GAAG,sBAAsB,CAAC;QAE9B,gBAAW,GAAG,yBAAyB,CAAC;QAExC,SAAI,GAAS,cAAc,CAAC;QAE5B,qBAAgB,GACf,gFAAgF,CAAC;QAElF,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EACV,8IAA8I;aAC/I;YACD;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,8BAA8B;aAC3C;YACD;gBACC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,uBAAuB;gBACpC,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,IAAI;aACjB;YACD;gBACC,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,OAAO;aACpB;YACD;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,IAAI;gBACjB,WAAW,EAAE,6EAA6E;aAC1F;YACD;gBACC,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,wEAAwE;aACrF;SACD,CAAC;IACH,CAAC;CAAA;AA1ED,oDA0EC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { type INodeType, type INodeTypeDescription } from 'n8n-workflow';
|
|
1
|
+
import { type ICredentialsDecrypted, type ICredentialTestFunctions, type INodeCredentialTestResult, type INodeType, type INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
export declare class Ups implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
credentialTest: {
|
|
6
|
+
upsShipperProfileTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
4
9
|
}
|
|
@@ -21,7 +21,10 @@ class Ups {
|
|
|
21
21
|
usableAsTool: true,
|
|
22
22
|
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
23
|
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
24
|
-
credentials: [
|
|
24
|
+
credentials: [
|
|
25
|
+
{ name: 'upsOAuth2Api', required: true },
|
|
26
|
+
{ name: 'upsShipperProfileApi', required: false, testedBy: 'upsShipperProfileTest' },
|
|
27
|
+
],
|
|
25
28
|
requestDefaults: {
|
|
26
29
|
baseURL: '={{ $credentials.environment === "production" ? "https://onlinetools.ups.com/api" : "https://wwwcie.ups.com/api" }}',
|
|
27
30
|
headers: {
|
|
@@ -47,6 +50,39 @@ class Ups {
|
|
|
47
50
|
...shipping_1.shippingDescription,
|
|
48
51
|
],
|
|
49
52
|
};
|
|
53
|
+
this.methods = {
|
|
54
|
+
credentialTest: {
|
|
55
|
+
async upsShipperProfileTest(credential) {
|
|
56
|
+
var _a;
|
|
57
|
+
const data = ((_a = credential.data) !== null && _a !== void 0 ? _a : {});
|
|
58
|
+
const str = (key) => { var _a; return String((_a = data[key]) !== null && _a !== void 0 ? _a : '').trim(); };
|
|
59
|
+
const filled = [
|
|
60
|
+
'accountNumber',
|
|
61
|
+
'shipperName',
|
|
62
|
+
'addressLine1',
|
|
63
|
+
'city',
|
|
64
|
+
'stateProvinceCode',
|
|
65
|
+
'postalCode',
|
|
66
|
+
'countryCode',
|
|
67
|
+
'phone',
|
|
68
|
+
].some((key) => str(key).length > 0);
|
|
69
|
+
if (!filled) {
|
|
70
|
+
return {
|
|
71
|
+
status: 'Error',
|
|
72
|
+
message: 'Shipper profile is empty — fill at least an account number or address.',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const country = str('countryCode');
|
|
76
|
+
if (country.length > 0 && !/^[A-Za-z]{2}$/.test(country)) {
|
|
77
|
+
return {
|
|
78
|
+
status: 'Error',
|
|
79
|
+
message: `Country Code "${country}" must be a two-letter code (e.g. US, CA).`,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { status: 'OK', message: 'Shipper profile looks valid.' };
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
50
86
|
}
|
|
51
87
|
}
|
|
52
88
|
exports.Ups = Ups;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ups.node.js","sourceRoot":"","sources":["../../../nodes/Ups/Ups.node.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"Ups.node.js","sourceRoot":"","sources":["../../../nodes/Ups/Ups.node.ts"],"names":[],"mappings":";;;AAAA,+CAQsB;AACtB,mDAA2D;AAC3D,iDAAyD;AACzD,mDAA2D;AAE3D,MAAa,GAAG;IAAhB;QAMC,gBAAW,GAAyB;YACnC,WAAW,EAAE,KAAK;YAClB,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE;YAC1D,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,qEAAqE;YAClF,QAAQ,EAAE;gBACT,IAAI,EAAE,KAAK;aACX;YACD,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE;gBACZ,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAIxC,EAAE,IAAI,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE;aACpF;YACD,eA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ACjF,CAAC;oBACH,CAAC;oBAED,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC;oBACnC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC1D,OAAO;4BACN,MAAM,EAAE,OAAO;4BACf,OAAO,EAAE,iBAAiB,OAAO,4CAA4C;yBAC7E,CAAC;oBACH,CAAC;oBAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;gBAClE,CAAC;aACD;SACD,CAAC;IACH,CAAC;CAAA;AApGD,kBAoGC"}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"resources": {
|
|
7
7
|
"credentialDocumentation": [
|
|
8
8
|
{
|
|
9
|
-
"url": "https://github.com/nodrel-dev/n8n-
|
|
9
|
+
"url": "https://github.com/nodrel-dev/n8n-ups-node?tab=readme-ov-file#credentials"
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
12
|
"primaryDocumentation": [
|
|
13
13
|
{
|
|
14
|
-
"url": "https://github.com/nodrel-dev/n8n-
|
|
14
|
+
"url": "https://github.com/nodrel-dev/n8n-ups-node?tab=readme-ov-file"
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IDataObject } from 'n8n-workflow';
|
|
2
|
+
import type { NormalizedAddressInput } from './toXavAddress';
|
|
3
|
+
type RateAddress = NormalizedAddressInput & {
|
|
4
|
+
residential?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export interface UpsPackageBody {
|
|
7
|
+
PackageWeight: {
|
|
8
|
+
UnitOfMeasurement: {
|
|
9
|
+
Code: string;
|
|
10
|
+
};
|
|
11
|
+
Weight: string;
|
|
12
|
+
};
|
|
13
|
+
Dimensions?: {
|
|
14
|
+
UnitOfMeasurement: {
|
|
15
|
+
Code: string;
|
|
16
|
+
};
|
|
17
|
+
Length: string;
|
|
18
|
+
Width: string;
|
|
19
|
+
Height: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface RateRequestInput {
|
|
23
|
+
accountNumber: string;
|
|
24
|
+
shipper: RateAddress;
|
|
25
|
+
shipTo: RateAddress;
|
|
26
|
+
effectiveShipFrom: RateAddress;
|
|
27
|
+
package: UpsPackageBody;
|
|
28
|
+
weight: number;
|
|
29
|
+
weightUnit: string;
|
|
30
|
+
customsValue: number;
|
|
31
|
+
currency: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function buildRateRequest(input: RateRequestInput): IDataObject;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildRateRequest = buildRateRequest;
|
|
4
|
+
const toUpsAddress_1 = require("./toUpsAddress");
|
|
5
|
+
function buildRateRequest(input) {
|
|
6
|
+
const shipment = {
|
|
7
|
+
Shipper: { ShipperNumber: input.accountNumber, Address: (0, toUpsAddress_1.toUpsAddress)(input.shipper) },
|
|
8
|
+
ShipTo: { Address: (0, toUpsAddress_1.toUpsAddress)(input.shipTo) },
|
|
9
|
+
ShipFrom: { Address: (0, toUpsAddress_1.toUpsAddress)(input.effectiveShipFrom) },
|
|
10
|
+
PickupType: { Code: '01' },
|
|
11
|
+
DeliveryTimeInformation: { PackageBillType: '03' },
|
|
12
|
+
ShipmentTotalWeight: {
|
|
13
|
+
UnitOfMeasurement: { Code: input.weightUnit, Description: input.weightUnit },
|
|
14
|
+
Weight: String(input.weight),
|
|
15
|
+
},
|
|
16
|
+
ShipmentRatingOptions: { NegotiatedRatesIndicator: '' },
|
|
17
|
+
Package: { PackagingType: { Code: '02' }, ...input.package },
|
|
18
|
+
};
|
|
19
|
+
if (input.customsValue > 0) {
|
|
20
|
+
shipment.InvoiceLineTotal = {
|
|
21
|
+
CurrencyCode: input.currency,
|
|
22
|
+
MonetaryValue: String(input.customsValue),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
RateRequest: {
|
|
27
|
+
Request: { TransactionReference: { CustomerContext: 'n8n-nodes-ups rate' } },
|
|
28
|
+
PickupType: { Code: '01' },
|
|
29
|
+
Shipment: shipment,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=buildRateRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildRateRequest.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/buildRateRequest.ts"],"names":[],"mappings":";;AAqCA,4CAkCC;AArED,iDAA8C;AAmC9C,SAAgB,gBAAgB,CAAC,KAAuB;IACvD,MAAM,QAAQ,GAAgB;QAC7B,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,IAAA,2BAAY,EAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACrF,MAAM,EAAE,EAAE,OAAO,EAAE,IAAA,2BAAY,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC/C,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAA,2BAAY,EAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;QAC5D,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QAK1B,uBAAuB,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;QAClD,mBAAmB,EAAE;YACpB,iBAAiB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,UAAU,EAAE;YAC5E,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;SAC5B;QAED,qBAAqB,EAAE,EAAE,wBAAwB,EAAE,EAAE,EAAE;QACvD,OAAO,EAAE,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE;KAC5D,CAAC;IAEF,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;QAC5B,QAAQ,CAAC,gBAAgB,GAAG;YAC3B,YAAY,EAAE,KAAK,CAAC,QAAQ;YAC5B,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;SACzC,CAAC;IACH,CAAC;IAED,OAAO;QACN,WAAW,EAAE;YACZ,OAAO,EAAE,EAAE,oBAAoB,EAAE,EAAE,eAAe,EAAE,oBAAoB,EAAE,EAAE;YAC5E,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,QAAQ;SAClB;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IDataObject } from 'n8n-workflow';
|
|
2
|
+
import type { NormalizedAddressInput } from './toXavAddress';
|
|
3
|
+
import type { UpsPackageBody } from './buildRateRequest';
|
|
4
|
+
import { type CommodityLineInput } from './buildCommodities';
|
|
5
|
+
import { type CustomsInput } from './buildInternationalForms';
|
|
6
|
+
type ShipAddress = NormalizedAddressInput & {
|
|
7
|
+
residential?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export interface ShipmentRequestInput {
|
|
10
|
+
accountNumber: string;
|
|
11
|
+
service: string;
|
|
12
|
+
labelFormat: string;
|
|
13
|
+
international: boolean;
|
|
14
|
+
shipper: {
|
|
15
|
+
address: ShipAddress;
|
|
16
|
+
name: string;
|
|
17
|
+
phone: string;
|
|
18
|
+
};
|
|
19
|
+
shipTo: {
|
|
20
|
+
address: ShipAddress;
|
|
21
|
+
name: string;
|
|
22
|
+
phone: string;
|
|
23
|
+
};
|
|
24
|
+
shipFrom: {
|
|
25
|
+
address: ShipAddress;
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
package: UpsPackageBody;
|
|
29
|
+
customs: CustomsInput;
|
|
30
|
+
commodities: CommodityLineInput[];
|
|
31
|
+
}
|
|
32
|
+
export declare function buildShipmentRequest(input: ShipmentRequestInput): IDataObject;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildShipmentRequest = buildShipmentRequest;
|
|
4
|
+
const toUpsAddress_1 = require("./toUpsAddress");
|
|
5
|
+
const buildCommodities_1 = require("./buildCommodities");
|
|
6
|
+
const buildInternationalForms_1 = require("./buildInternationalForms");
|
|
7
|
+
function buildShipmentRequest(input) {
|
|
8
|
+
const { accountNumber, shipper, shipTo, shipFrom } = input;
|
|
9
|
+
const shipment = {
|
|
10
|
+
Description: 'Shipment',
|
|
11
|
+
Shipper: {
|
|
12
|
+
Name: shipper.name,
|
|
13
|
+
...(shipper.name ? { AttentionName: shipper.name } : {}),
|
|
14
|
+
ShipperNumber: accountNumber,
|
|
15
|
+
...(shipper.phone ? { Phone: { Number: shipper.phone } } : {}),
|
|
16
|
+
Address: (0, toUpsAddress_1.toUpsAddress)(shipper.address),
|
|
17
|
+
},
|
|
18
|
+
ShipTo: {
|
|
19
|
+
Name: shipTo.name,
|
|
20
|
+
...(shipTo.name ? { AttentionName: shipTo.name } : {}),
|
|
21
|
+
...(shipTo.phone ? { Phone: { Number: shipTo.phone } } : {}),
|
|
22
|
+
Address: (0, toUpsAddress_1.toUpsAddress)(shipTo.address),
|
|
23
|
+
},
|
|
24
|
+
ShipFrom: {
|
|
25
|
+
Name: shipFrom.name,
|
|
26
|
+
...(shipFrom.name ? { AttentionName: shipFrom.name } : {}),
|
|
27
|
+
Address: (0, toUpsAddress_1.toUpsAddress)(shipFrom.address),
|
|
28
|
+
},
|
|
29
|
+
PaymentInformation: {
|
|
30
|
+
ShipmentCharge: { Type: '01', BillShipper: { AccountNumber: accountNumber } },
|
|
31
|
+
},
|
|
32
|
+
ShipmentRatingOptions: { NegotiatedRatesIndicator: '' },
|
|
33
|
+
Service: { Code: input.service },
|
|
34
|
+
Package: {
|
|
35
|
+
Packaging: { Code: '02' },
|
|
36
|
+
...input.package,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
if (input.international) {
|
|
40
|
+
const commodities = (0, buildCommodities_1.buildCommodities)(input.commodities);
|
|
41
|
+
shipment.ShipmentServiceOptions = {
|
|
42
|
+
InternationalForms: (0, buildInternationalForms_1.buildInternationalForms)(input.customs, commodities),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const labelSpecification = { LabelImageFormat: { Code: input.labelFormat } };
|
|
46
|
+
if (input.labelFormat !== 'GIF') {
|
|
47
|
+
labelSpecification.LabelStockSize = { Height: '6', Width: '4' };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ShipmentRequest: {
|
|
51
|
+
Request: { RequestOption: 'nonvalidate' },
|
|
52
|
+
Shipment: shipment,
|
|
53
|
+
LabelSpecification: labelSpecification,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=buildShipmentRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildShipmentRequest.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/buildShipmentRequest.ts"],"names":[],"mappings":";;AA+BA,oDA8DC;AA1FD,iDAA8C;AAC9C,yDAA+E;AAC/E,uEAAuF;AA0BvF,SAAgB,oBAAoB,CAAC,KAA2B;IAC/D,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAK3D,MAAM,QAAQ,GAAgB;QAC7B,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE;YACR,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxD,aAAa,EAAE,aAAa;YAC5B,GAAG,CAAC,OAAO,CAAC,KAAK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AM,WAAW,GAAG,IAAA,mCAAgB,EAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACxD,QAAQ,CAAC,sBAAsB,GAAG;YACjC,kBAAkB,EAAE,IAAA,iDAAuB,EAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC;SACvE,CAAC;IACH,CAAC;IAKD,MAAM,kBAAkB,GAAgB,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;IAC1F,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;QACjC,kBAAkB,CAAC,cAAc,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACjE,CAAC;IAED,OAAO;QACN,eAAe,EAAE;YAChB,OAAO,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE;YACzC,QAAQ,EAAE,QAAQ;YAClB,kBAAkB,EAAE,kBAAkB;SACtC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type LabelFormat } from './extractLabel';
|
|
2
|
+
import { type ExtractedCharges } from './extractCharges';
|
|
3
|
+
export interface BinaryPart {
|
|
4
|
+
key: string;
|
|
5
|
+
base64: string;
|
|
6
|
+
mime: string;
|
|
7
|
+
filename: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ShipmentResult {
|
|
10
|
+
json: {
|
|
11
|
+
shipmentId: string;
|
|
12
|
+
trackingNumbers: string[];
|
|
13
|
+
international: boolean;
|
|
14
|
+
charges: ExtractedCharges;
|
|
15
|
+
};
|
|
16
|
+
binaryParts: BinaryPart[];
|
|
17
|
+
}
|
|
18
|
+
export declare function buildShipmentResult(response: object, format: LabelFormat): ShipmentResult;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildShipmentResult = buildShipmentResult;
|
|
4
|
+
const extractLabel_1 = require("./extractLabel");
|
|
5
|
+
const extractForms_1 = require("./extractForms");
|
|
6
|
+
const extractCharges_1 = require("./extractCharges");
|
|
7
|
+
function buildShipmentResult(response, format) {
|
|
8
|
+
const label = (0, extractLabel_1.extractLabel)(response, format);
|
|
9
|
+
const forms = (0, extractForms_1.extractForms)(response);
|
|
10
|
+
const charges = (0, extractCharges_1.extractCharges)(response);
|
|
11
|
+
const binaryParts = [];
|
|
12
|
+
if (label.labels[0]) {
|
|
13
|
+
const l = label.labels[0];
|
|
14
|
+
binaryParts.push({ key: 'label', base64: l.base64, mime: l.mime, filename: l.filename });
|
|
15
|
+
}
|
|
16
|
+
if (forms[0]) {
|
|
17
|
+
binaryParts.push({
|
|
18
|
+
key: 'customsInvoice',
|
|
19
|
+
base64: forms[0].base64,
|
|
20
|
+
mime: forms[0].mime,
|
|
21
|
+
filename: forms[0].filename,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
json: {
|
|
26
|
+
shipmentId: label.shipmentId,
|
|
27
|
+
trackingNumbers: label.labels.map((x) => x.trackingNumber),
|
|
28
|
+
international: forms.length > 0,
|
|
29
|
+
charges,
|
|
30
|
+
},
|
|
31
|
+
binaryParts,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=buildShipmentResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildShipmentResult.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/buildShipmentResult.ts"],"names":[],"mappings":";;AA8BA,kDA6BC;AA3DD,iDAAgE;AAChE,iDAA8C;AAC9C,qDAAyE;AA4BzE,SAAgB,mBAAmB,CAAC,QAAgB,EAAE,MAAmB;IACxE,MAAM,KAAK,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAA,2BAAY,EAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAA,+BAAc,EAAC,QAAQ,CAAC,CAAC;IAEzC,MAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACd,WAAW,CAAC,IAAI,CAAC;YAChB,GAAG,EAAE,gBAAgB;YACrB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;YACvB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;YACnB,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ;SAC3B,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACN,IAAI,EAAE;YACL,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;YAE1D,aAAa,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;YAC/B,OAAO;SACP;QACD,WAAW;KACX,CAAC;AACH,CAAC"}
|
|
@@ -84,7 +84,14 @@ exports.validateOperationDescription = [
|
|
|
84
84
|
type: 'string',
|
|
85
85
|
default: 'US',
|
|
86
86
|
displayOptions: { show: showOnlyForValidate },
|
|
87
|
-
description: 'Two-letter country code
|
|
87
|
+
description: 'Two-letter country code',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
displayName: 'In the UPS Customer Integration Environment (Sandbox), street-level validation only returns results for US addresses in New York (NY) and California (CA). This limit does not apply in Production.',
|
|
91
|
+
name: 'validateSandboxNotice',
|
|
92
|
+
type: 'notice',
|
|
93
|
+
default: '',
|
|
94
|
+
displayOptions: { show: showOnlyForValidate },
|
|
88
95
|
},
|
|
89
96
|
];
|
|
90
97
|
exports.validateOperationOption = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.operation.js","sourceRoot":"","sources":["../../../../../nodes/Ups/resources/address/validate.operation.ts"],"names":[],"mappings":";;;AAOA,0DAAoF;AACpF,gEAA6D;AAC7D,wDAAqD;AAErD,MAAM,mBAAmB,GAAG;IAC3B,SAAS,EAAE,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,CAAC,SAAS,CAAC;CACrB,CAAC;AAEF,SAAS,WAAW,CAAC,GAA4B;IAChD,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,EAAE,CAAW,CAAC;IACjE,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,EAAE,CAAW,CAAC;IACjE,OAAO;QACN,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;QACpE,IAAI,EAAE,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAW;QAChD,iBAAiB,EAAE,GAAG,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,EAAE,CAAW;QAC1E,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,YAAY,EAAE,EAAE,CAAW;QAC5D,WAAW,EAAE,GAAG,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAW;KAChE,CAAC;AACH,CAAC;AAGD,KAAK,UAAU,eAAe,CAE7B,cAAmC;IAEnC,cAAc,CAAC,IAAI,GAAG;QACrB,UAAU,EA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,EAAE,IAAI;QACjB,cAAc,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE;QAC7C,WAAW,EAAE,gEAAgE;KAC7E;IACD;QACC,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,qBAAqB;QAClC,cAAc,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE;QAC7C,WAAW,EAAE,mEAAmE;KAChF;IACD;QACC,WAAW,EAAE,cAAc;QAC3B,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE;QAC7C,WAAW,EACV,
|
|
1
|
+
{"version":3,"file":"validate.operation.js","sourceRoot":"","sources":["../../../../../nodes/Ups/resources/address/validate.operation.ts"],"names":[],"mappings":";;;AAOA,0DAAoF;AACpF,gEAA6D;AAC7D,wDAAqD;AAErD,MAAM,mBAAmB,GAAG;IAC3B,SAAS,EAAE,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,CAAC,SAAS,CAAC;CACrB,CAAC;AAEF,SAAS,WAAW,CAAC,GAA4B;IAChD,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,EAAE,CAAW,CAAC;IACjE,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,EAAE,CAAW,CAAC;IACjE,OAAO;QACN,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;QACpE,IAAI,EAAE,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAW;QAChD,iBAAiB,EAAE,GAAG,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,E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