@zenglobal/api-client 5.1.0 → 5.1.1
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 +21 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
|
|
22
22
|
// Configure once at startup
|
|
23
23
|
configureZenClient({
|
|
24
|
-
baseUrl: "https://api.zenglobal.au
|
|
25
|
-
username: process.env.ZEN_API_USER
|
|
26
|
-
password: process.env.ZEN_API_PASS
|
|
24
|
+
baseUrl: "https://api.zenglobal.au",
|
|
25
|
+
username: process.env.ZEN_API_USER!,
|
|
26
|
+
password: process.env.ZEN_API_PASS!,
|
|
27
27
|
partner: {
|
|
28
28
|
partnerId: "q74vzg9o",
|
|
29
29
|
name: "my-pos-app",
|
|
@@ -52,7 +52,8 @@ import { ZenApiError, voucherEnquireVoucher } from "@zenglobal/api-client";
|
|
|
52
52
|
|
|
53
53
|
try {
|
|
54
54
|
const { data } = await voucherEnquireVoucher({
|
|
55
|
-
|
|
55
|
+
path: { voucherType: "Gift" },
|
|
56
|
+
body: { voucher: { serialnumber: "999" } },
|
|
56
57
|
});
|
|
57
58
|
} catch (error) {
|
|
58
59
|
if (error instanceof ZenApiError) {
|
|
@@ -93,16 +94,16 @@ Both error classes extend `Error`, so `instanceof Error` works for catch-all han
|
|
|
93
94
|
|
|
94
95
|
## Configuration Options
|
|
95
96
|
|
|
96
|
-
| Option | Type | Default | Description
|
|
97
|
-
| ----------- | ------------ | -------------- |
|
|
98
|
-
| `baseUrl` | `string` | — | Zen API
|
|
99
|
-
| `username` | `string` | — | HTTP Basic Auth username (or use `auth`)
|
|
100
|
-
| `password` | `string` | — | HTTP Basic Auth password (or use `auth`)
|
|
101
|
-
| `auth` | `ZenAuth` | — | OAuth
|
|
102
|
-
| `partner` | `ZenPartner` | — | Partner identification (see below)
|
|
103
|
-
| `companyId` | `string` | — | Target company (`X-COMPANY-ID`); required with `mode: "organisation"`
|
|
104
|
-
| `timeout` | `number` | `30000` | Request timeout in ms
|
|
105
|
-
| `retry` | `object` | `{ limit: 3 }` | Retry configuration
|
|
97
|
+
| Option | Type | Default | Description |
|
|
98
|
+
| ----------- | ------------ | -------------- | --------------------------------------------------------------------- |
|
|
99
|
+
| `baseUrl` | `string` | — | Zen API host, no path (operation paths already carry `/v1`) |
|
|
100
|
+
| `username` | `string` | — | HTTP Basic Auth username (or use `auth`) |
|
|
101
|
+
| `password` | `string` | — | HTTP Basic Auth password (or use `auth`) |
|
|
102
|
+
| `auth` | `ZenAuth` | — | OAuth config — `clientCredentials` or `organisation` (see below) |
|
|
103
|
+
| `partner` | `ZenPartner` | — | Partner identification (see below) |
|
|
104
|
+
| `companyId` | `string` | — | Target company (`X-COMPANY-ID`); required with `mode: "organisation"` |
|
|
105
|
+
| `timeout` | `number` | `30000` | Request timeout in ms |
|
|
106
|
+
| `retry` | `object` | `{ limit: 3 }` | Retry configuration |
|
|
106
107
|
|
|
107
108
|
### OAuth client_credentials
|
|
108
109
|
|
|
@@ -115,12 +116,12 @@ and retries once on a 401.
|
|
|
115
116
|
|
|
116
117
|
```typescript
|
|
117
118
|
configureZenClient({
|
|
118
|
-
baseUrl: "https://api.zenglobal.au
|
|
119
|
+
baseUrl: "https://api.zenglobal.au",
|
|
119
120
|
partner: { partnerId: "q74vzg9o", name: "my-pos-app", version: "1.0.0" },
|
|
120
121
|
auth: {
|
|
121
122
|
mode: "clientCredentials",
|
|
122
|
-
clientId: process.env.ZEN_CLIENT_ID
|
|
123
|
-
clientSecret: process.env.ZEN_CLIENT_SECRET
|
|
123
|
+
clientId: process.env.ZEN_CLIENT_ID!,
|
|
124
|
+
clientSecret: process.env.ZEN_CLIENT_SECRET!,
|
|
124
125
|
// scope: "read write", // optional; space-delimited
|
|
125
126
|
// tokenUrl: "https://auth-dev.zenglobal.au/oauth/token", // override for development
|
|
126
127
|
},
|
|
@@ -153,12 +154,12 @@ build one client per company:
|
|
|
153
154
|
```typescript
|
|
154
155
|
const auth = {
|
|
155
156
|
mode: "organisation",
|
|
156
|
-
clientId: process.env.ZEN_OAUTH_CLIENT_ID
|
|
157
|
-
clientSecret: process.env.ZEN_OAUTH_CLIENT_SECRET
|
|
157
|
+
clientId: process.env.ZEN_OAUTH_CLIENT_ID!,
|
|
158
|
+
clientSecret: process.env.ZEN_OAUTH_CLIENT_SECRET!,
|
|
158
159
|
} as const;
|
|
159
160
|
|
|
160
161
|
const bottlemart = createZenClient({
|
|
161
|
-
baseUrl: "https://api.zenglobal.au
|
|
162
|
+
baseUrl: "https://api.zenglobal.au",
|
|
162
163
|
partner: { partnerId: "q74vzg9o", name: "my-app", version: "1.0.0" },
|
|
163
164
|
auth,
|
|
164
165
|
companyId: "2",
|