ce-storefront 0.15.3 → 0.15.6
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 +15 -2
- package/docs/sdks/auth/README.md +10 -0
- package/docs/sdks/carts/README.md +12 -0
- package/docs/sdks/catalog/README.md +11 -0
- package/docs/sdks/common/README.md +1 -0
- package/docs/sdks/customers/README.md +7 -0
- package/docs/sdks/orders/README.md +7 -0
- package/docs/sdks/pos/README.md +397 -0
- package/docs/sdks/shipping/README.md +1 -0
- package/esm/funcs/posCreatePosCart.d.ts +17 -0
- package/esm/funcs/posCreatePosCart.d.ts.map +1 -0
- package/esm/funcs/posCreatePosCart.js +80 -0
- package/esm/funcs/posCreatePosCart.js.map +1 -0
- package/esm/funcs/posLoginToPosDevice.d.ts +17 -0
- package/esm/funcs/posLoginToPosDevice.d.ts.map +1 -0
- package/esm/funcs/posLoginToPosDevice.js +84 -0
- package/esm/funcs/posLoginToPosDevice.js.map +1 -0
- package/esm/funcs/posPairPosDevice.d.ts +17 -0
- package/esm/funcs/posPairPosDevice.d.ts.map +1 -0
- package/esm/funcs/posPairPosDevice.js +84 -0
- package/esm/funcs/posPairPosDevice.js.map +1 -0
- package/esm/funcs/posRefreshPosAccessToken.d.ts +17 -0
- package/esm/funcs/posRefreshPosAccessToken.d.ts.map +1 -0
- package/esm/funcs/posRefreshPosAccessToken.js +81 -0
- package/esm/funcs/posRefreshPosAccessToken.js.map +1 -0
- package/esm/funcs/posUpdatePosCart.d.ts +17 -0
- package/esm/funcs/posUpdatePosCart.d.ts.map +1 -0
- package/esm/funcs/posUpdatePosCart.js +84 -0
- package/esm/funcs/posUpdatePosCart.js.map +1 -0
- package/esm/lib/base64.d.ts +2 -2
- package/esm/lib/base64.d.ts.map +1 -1
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/encodings.d.ts.map +1 -1
- package/esm/models/components/index.d.ts +1 -0
- package/esm/models/components/index.d.ts.map +1 -1
- package/esm/models/components/index.js +1 -0
- package/esm/models/components/index.js.map +1 -1
- package/esm/models/components/posuser.d.ts +124 -0
- package/esm/models/components/posuser.d.ts.map +1 -0
- package/esm/models/components/posuser.js +139 -0
- package/esm/models/components/posuser.js.map +1 -0
- package/esm/models/operations/createposcart.d.ts +90 -0
- package/esm/models/operations/createposcart.d.ts.map +1 -0
- package/esm/models/operations/createposcart.js +86 -0
- package/esm/models/operations/createposcart.js.map +1 -0
- package/esm/models/operations/index.d.ts +5 -0
- package/esm/models/operations/index.d.ts.map +1 -1
- package/esm/models/operations/index.js +5 -0
- package/esm/models/operations/index.js.map +1 -1
- package/esm/models/operations/logintoposdevice.d.ts +118 -0
- package/esm/models/operations/logintoposdevice.d.ts.map +1 -0
- package/esm/models/operations/logintoposdevice.js +146 -0
- package/esm/models/operations/logintoposdevice.js.map +1 -0
- package/esm/models/operations/pairposdevice.d.ts +115 -0
- package/esm/models/operations/pairposdevice.d.ts.map +1 -0
- package/esm/models/operations/pairposdevice.js +141 -0
- package/esm/models/operations/pairposdevice.js.map +1 -0
- package/esm/models/operations/refreshposaccesstoken.d.ts +88 -0
- package/esm/models/operations/refreshposaccesstoken.d.ts.map +1 -0
- package/esm/models/operations/refreshposaccesstoken.js +106 -0
- package/esm/models/operations/refreshposaccesstoken.js.map +1 -0
- package/esm/models/operations/updateposcart.d.ts +120 -0
- package/esm/models/operations/updateposcart.d.ts.map +1 -0
- package/esm/models/operations/updateposcart.js +122 -0
- package/esm/models/operations/updateposcart.js.map +1 -0
- package/esm/sdk/pos.d.ts +40 -0
- package/esm/sdk/pos.d.ts.map +1 -0
- package/esm/sdk/pos.js +58 -0
- package/esm/sdk/pos.js.map +1 -0
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.d.ts.map +1 -1
- package/esm/sdk/sdk.js +4 -0
- package/esm/sdk/sdk.js.map +1 -1
- package/examples/README.md +5 -0
- package/examples/catalogListProducts.example.ts +2 -0
- package/examples/package-lock.json +6 -7
- package/jsr.json +1 -1
- package/package.json +5 -6
- package/src/funcs/posCreatePosCart.ts +165 -0
- package/src/funcs/posLoginToPosDevice.ts +174 -0
- package/src/funcs/posPairPosDevice.ts +174 -0
- package/src/funcs/posRefreshPosAccessToken.ts +164 -0
- package/src/funcs/posUpdatePosCart.ts +167 -0
- package/src/lib/config.ts +3 -3
- package/src/models/components/index.ts +1 -0
- package/src/models/components/posuser.ts +263 -0
- package/src/models/operations/createposcart.ts +197 -0
- package/src/models/operations/index.ts +5 -0
- package/src/models/operations/logintoposdevice.ts +297 -0
- package/src/models/operations/pairposdevice.ts +286 -0
- package/src/models/operations/refreshposaccesstoken.ts +223 -0
- package/src/models/operations/updateposcart.ts +271 -0
- package/src/sdk/pos.ts +103 -0
- package/src/sdk/sdk.ts +6 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CeStorefrontCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create cart
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Create cart from POS device
|
|
32
|
+
*/
|
|
33
|
+
export function posCreatePosCart(
|
|
34
|
+
client: CeStorefrontCore,
|
|
35
|
+
request?: operations.CreatePosCartRequestBody | undefined,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.CreatePosCartResponseBody,
|
|
40
|
+
| CeStorefrontError
|
|
41
|
+
| ResponseValidationError
|
|
42
|
+
| ConnectionError
|
|
43
|
+
| RequestAbortedError
|
|
44
|
+
| RequestTimeoutError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| UnexpectedClientError
|
|
47
|
+
| SDKValidationError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
request,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: CeStorefrontCore,
|
|
59
|
+
request?: operations.CreatePosCartRequestBody | undefined,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.CreatePosCartResponseBody,
|
|
65
|
+
| CeStorefrontError
|
|
66
|
+
| ResponseValidationError
|
|
67
|
+
| ConnectionError
|
|
68
|
+
| RequestAbortedError
|
|
69
|
+
| RequestTimeoutError
|
|
70
|
+
| InvalidRequestError
|
|
71
|
+
| UnexpectedClientError
|
|
72
|
+
| SDKValidationError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const parsed = safeParse(
|
|
78
|
+
request,
|
|
79
|
+
(value) =>
|
|
80
|
+
operations.CreatePosCartRequestBody$outboundSchema.optional().parse(
|
|
81
|
+
value,
|
|
82
|
+
),
|
|
83
|
+
"Input validation failed",
|
|
84
|
+
);
|
|
85
|
+
if (!parsed.ok) {
|
|
86
|
+
return [parsed, { status: "invalid" }];
|
|
87
|
+
}
|
|
88
|
+
const payload = parsed.value;
|
|
89
|
+
const body = payload === undefined
|
|
90
|
+
? null
|
|
91
|
+
: encodeJSON("body", payload, { explode: true });
|
|
92
|
+
|
|
93
|
+
const path = pathToFunc("/pos/carts")();
|
|
94
|
+
|
|
95
|
+
const headers = new Headers(compactMap({
|
|
96
|
+
"Content-Type": "application/json",
|
|
97
|
+
Accept: "application/json",
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
const secConfig = await extractSecurity(client._options.authorization);
|
|
101
|
+
const securityInput = secConfig == null ? {} : { authorization: secConfig };
|
|
102
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
103
|
+
|
|
104
|
+
const context = {
|
|
105
|
+
options: client._options,
|
|
106
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
107
|
+
operationID: "create-pos-cart",
|
|
108
|
+
oAuth2Scopes: [],
|
|
109
|
+
|
|
110
|
+
resolvedSecurity: requestSecurity,
|
|
111
|
+
|
|
112
|
+
securitySource: client._options.authorization,
|
|
113
|
+
retryConfig: options?.retries
|
|
114
|
+
|| client._options.retryConfig
|
|
115
|
+
|| { strategy: "none" },
|
|
116
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const requestRes = client._createRequest(context, {
|
|
120
|
+
security: requestSecurity,
|
|
121
|
+
method: "POST",
|
|
122
|
+
baseURL: options?.serverURL,
|
|
123
|
+
path: path,
|
|
124
|
+
headers: headers,
|
|
125
|
+
body: body,
|
|
126
|
+
userAgent: client._options.userAgent,
|
|
127
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
128
|
+
}, options);
|
|
129
|
+
if (!requestRes.ok) {
|
|
130
|
+
return [requestRes, { status: "invalid" }];
|
|
131
|
+
}
|
|
132
|
+
const req = requestRes.value;
|
|
133
|
+
|
|
134
|
+
const doResult = await client._do(req, {
|
|
135
|
+
context,
|
|
136
|
+
errorCodes: ["4XX", "5XX"],
|
|
137
|
+
retryConfig: context.retryConfig,
|
|
138
|
+
retryCodes: context.retryCodes,
|
|
139
|
+
});
|
|
140
|
+
if (!doResult.ok) {
|
|
141
|
+
return [doResult, { status: "request-error", request: req }];
|
|
142
|
+
}
|
|
143
|
+
const response = doResult.value;
|
|
144
|
+
|
|
145
|
+
const [result] = await M.match<
|
|
146
|
+
operations.CreatePosCartResponseBody,
|
|
147
|
+
| CeStorefrontError
|
|
148
|
+
| ResponseValidationError
|
|
149
|
+
| ConnectionError
|
|
150
|
+
| RequestAbortedError
|
|
151
|
+
| RequestTimeoutError
|
|
152
|
+
| InvalidRequestError
|
|
153
|
+
| UnexpectedClientError
|
|
154
|
+
| SDKValidationError
|
|
155
|
+
>(
|
|
156
|
+
M.json(200, operations.CreatePosCartResponseBody$inboundSchema),
|
|
157
|
+
M.fail("4XX"),
|
|
158
|
+
M.fail("5XX"),
|
|
159
|
+
)(response, req);
|
|
160
|
+
if (!result.ok) {
|
|
161
|
+
return [result, { status: "complete", request: req, response }];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return [result, { status: "complete", request: req, response }];
|
|
165
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CeStorefrontCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { resolveSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Login to POS device
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Login to POS device
|
|
32
|
+
*/
|
|
33
|
+
export function posLoginToPosDevice(
|
|
34
|
+
client: CeStorefrontCore,
|
|
35
|
+
security: operations.LoginToPosDeviceSecurity,
|
|
36
|
+
request?: operations.LoginToPosDeviceRequestBody | undefined,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
operations.LoginToPosDeviceResponseBody,
|
|
41
|
+
| CeStorefrontError
|
|
42
|
+
| ResponseValidationError
|
|
43
|
+
| ConnectionError
|
|
44
|
+
| RequestAbortedError
|
|
45
|
+
| RequestTimeoutError
|
|
46
|
+
| InvalidRequestError
|
|
47
|
+
| UnexpectedClientError
|
|
48
|
+
| SDKValidationError
|
|
49
|
+
>
|
|
50
|
+
> {
|
|
51
|
+
return new APIPromise($do(
|
|
52
|
+
client,
|
|
53
|
+
security,
|
|
54
|
+
request,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: CeStorefrontCore,
|
|
61
|
+
security: operations.LoginToPosDeviceSecurity,
|
|
62
|
+
request?: operations.LoginToPosDeviceRequestBody | undefined,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
operations.LoginToPosDeviceResponseBody,
|
|
68
|
+
| CeStorefrontError
|
|
69
|
+
| ResponseValidationError
|
|
70
|
+
| ConnectionError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| InvalidRequestError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| SDKValidationError
|
|
76
|
+
>,
|
|
77
|
+
APICall,
|
|
78
|
+
]
|
|
79
|
+
> {
|
|
80
|
+
const parsed = safeParse(
|
|
81
|
+
request,
|
|
82
|
+
(value) =>
|
|
83
|
+
operations.LoginToPosDeviceRequestBody$outboundSchema.optional().parse(
|
|
84
|
+
value,
|
|
85
|
+
),
|
|
86
|
+
"Input validation failed",
|
|
87
|
+
);
|
|
88
|
+
if (!parsed.ok) {
|
|
89
|
+
return [parsed, { status: "invalid" }];
|
|
90
|
+
}
|
|
91
|
+
const payload = parsed.value;
|
|
92
|
+
const body = payload === undefined
|
|
93
|
+
? null
|
|
94
|
+
: encodeJSON("body", payload, { explode: true });
|
|
95
|
+
|
|
96
|
+
const path = pathToFunc("/pos/auth/login")();
|
|
97
|
+
|
|
98
|
+
const headers = new Headers(compactMap({
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
Accept: "application/json",
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
const requestSecurity = resolveSecurity(
|
|
104
|
+
[
|
|
105
|
+
{
|
|
106
|
+
fieldName: "X-Api-Key",
|
|
107
|
+
type: "apiKey:header",
|
|
108
|
+
value: security?.xApiKey,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const context = {
|
|
114
|
+
options: client._options,
|
|
115
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
116
|
+
operationID: "login-to-pos-device",
|
|
117
|
+
oAuth2Scopes: null,
|
|
118
|
+
|
|
119
|
+
resolvedSecurity: requestSecurity,
|
|
120
|
+
|
|
121
|
+
securitySource: security,
|
|
122
|
+
retryConfig: options?.retries
|
|
123
|
+
|| client._options.retryConfig
|
|
124
|
+
|| { strategy: "none" },
|
|
125
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const requestRes = client._createRequest(context, {
|
|
129
|
+
security: requestSecurity,
|
|
130
|
+
method: "POST",
|
|
131
|
+
baseURL: options?.serverURL,
|
|
132
|
+
path: path,
|
|
133
|
+
headers: headers,
|
|
134
|
+
body: body,
|
|
135
|
+
userAgent: client._options.userAgent,
|
|
136
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
137
|
+
}, options);
|
|
138
|
+
if (!requestRes.ok) {
|
|
139
|
+
return [requestRes, { status: "invalid" }];
|
|
140
|
+
}
|
|
141
|
+
const req = requestRes.value;
|
|
142
|
+
|
|
143
|
+
const doResult = await client._do(req, {
|
|
144
|
+
context,
|
|
145
|
+
errorCodes: ["4XX", "5XX"],
|
|
146
|
+
retryConfig: context.retryConfig,
|
|
147
|
+
retryCodes: context.retryCodes,
|
|
148
|
+
});
|
|
149
|
+
if (!doResult.ok) {
|
|
150
|
+
return [doResult, { status: "request-error", request: req }];
|
|
151
|
+
}
|
|
152
|
+
const response = doResult.value;
|
|
153
|
+
|
|
154
|
+
const [result] = await M.match<
|
|
155
|
+
operations.LoginToPosDeviceResponseBody,
|
|
156
|
+
| CeStorefrontError
|
|
157
|
+
| ResponseValidationError
|
|
158
|
+
| ConnectionError
|
|
159
|
+
| RequestAbortedError
|
|
160
|
+
| RequestTimeoutError
|
|
161
|
+
| InvalidRequestError
|
|
162
|
+
| UnexpectedClientError
|
|
163
|
+
| SDKValidationError
|
|
164
|
+
>(
|
|
165
|
+
M.json(200, operations.LoginToPosDeviceResponseBody$inboundSchema),
|
|
166
|
+
M.fail("4XX"),
|
|
167
|
+
M.fail("5XX"),
|
|
168
|
+
)(response, req);
|
|
169
|
+
if (!result.ok) {
|
|
170
|
+
return [result, { status: "complete", request: req, response }];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return [result, { status: "complete", request: req, response }];
|
|
174
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CeStorefrontCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { resolveSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Pair POS device
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Pair POS device
|
|
32
|
+
*/
|
|
33
|
+
export function posPairPosDevice(
|
|
34
|
+
client: CeStorefrontCore,
|
|
35
|
+
security: operations.PairPosDeviceSecurity,
|
|
36
|
+
request?: operations.PairPosDeviceRequestBody | undefined,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
operations.PairPosDeviceResponseBody,
|
|
41
|
+
| CeStorefrontError
|
|
42
|
+
| ResponseValidationError
|
|
43
|
+
| ConnectionError
|
|
44
|
+
| RequestAbortedError
|
|
45
|
+
| RequestTimeoutError
|
|
46
|
+
| InvalidRequestError
|
|
47
|
+
| UnexpectedClientError
|
|
48
|
+
| SDKValidationError
|
|
49
|
+
>
|
|
50
|
+
> {
|
|
51
|
+
return new APIPromise($do(
|
|
52
|
+
client,
|
|
53
|
+
security,
|
|
54
|
+
request,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: CeStorefrontCore,
|
|
61
|
+
security: operations.PairPosDeviceSecurity,
|
|
62
|
+
request?: operations.PairPosDeviceRequestBody | undefined,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
operations.PairPosDeviceResponseBody,
|
|
68
|
+
| CeStorefrontError
|
|
69
|
+
| ResponseValidationError
|
|
70
|
+
| ConnectionError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| InvalidRequestError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| SDKValidationError
|
|
76
|
+
>,
|
|
77
|
+
APICall,
|
|
78
|
+
]
|
|
79
|
+
> {
|
|
80
|
+
const parsed = safeParse(
|
|
81
|
+
request,
|
|
82
|
+
(value) =>
|
|
83
|
+
operations.PairPosDeviceRequestBody$outboundSchema.optional().parse(
|
|
84
|
+
value,
|
|
85
|
+
),
|
|
86
|
+
"Input validation failed",
|
|
87
|
+
);
|
|
88
|
+
if (!parsed.ok) {
|
|
89
|
+
return [parsed, { status: "invalid" }];
|
|
90
|
+
}
|
|
91
|
+
const payload = parsed.value;
|
|
92
|
+
const body = payload === undefined
|
|
93
|
+
? null
|
|
94
|
+
: encodeJSON("body", payload, { explode: true });
|
|
95
|
+
|
|
96
|
+
const path = pathToFunc("/pos/auth/pair-device")();
|
|
97
|
+
|
|
98
|
+
const headers = new Headers(compactMap({
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
Accept: "application/json",
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
const requestSecurity = resolveSecurity(
|
|
104
|
+
[
|
|
105
|
+
{
|
|
106
|
+
fieldName: "X-Api-Key",
|
|
107
|
+
type: "apiKey:header",
|
|
108
|
+
value: security?.xApiKey,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const context = {
|
|
114
|
+
options: client._options,
|
|
115
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
116
|
+
operationID: "pair-pos-device",
|
|
117
|
+
oAuth2Scopes: null,
|
|
118
|
+
|
|
119
|
+
resolvedSecurity: requestSecurity,
|
|
120
|
+
|
|
121
|
+
securitySource: security,
|
|
122
|
+
retryConfig: options?.retries
|
|
123
|
+
|| client._options.retryConfig
|
|
124
|
+
|| { strategy: "none" },
|
|
125
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const requestRes = client._createRequest(context, {
|
|
129
|
+
security: requestSecurity,
|
|
130
|
+
method: "POST",
|
|
131
|
+
baseURL: options?.serverURL,
|
|
132
|
+
path: path,
|
|
133
|
+
headers: headers,
|
|
134
|
+
body: body,
|
|
135
|
+
userAgent: client._options.userAgent,
|
|
136
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
137
|
+
}, options);
|
|
138
|
+
if (!requestRes.ok) {
|
|
139
|
+
return [requestRes, { status: "invalid" }];
|
|
140
|
+
}
|
|
141
|
+
const req = requestRes.value;
|
|
142
|
+
|
|
143
|
+
const doResult = await client._do(req, {
|
|
144
|
+
context,
|
|
145
|
+
errorCodes: ["4XX", "5XX"],
|
|
146
|
+
retryConfig: context.retryConfig,
|
|
147
|
+
retryCodes: context.retryCodes,
|
|
148
|
+
});
|
|
149
|
+
if (!doResult.ok) {
|
|
150
|
+
return [doResult, { status: "request-error", request: req }];
|
|
151
|
+
}
|
|
152
|
+
const response = doResult.value;
|
|
153
|
+
|
|
154
|
+
const [result] = await M.match<
|
|
155
|
+
operations.PairPosDeviceResponseBody,
|
|
156
|
+
| CeStorefrontError
|
|
157
|
+
| ResponseValidationError
|
|
158
|
+
| ConnectionError
|
|
159
|
+
| RequestAbortedError
|
|
160
|
+
| RequestTimeoutError
|
|
161
|
+
| InvalidRequestError
|
|
162
|
+
| UnexpectedClientError
|
|
163
|
+
| SDKValidationError
|
|
164
|
+
>(
|
|
165
|
+
M.json(200, operations.PairPosDeviceResponseBody$inboundSchema),
|
|
166
|
+
M.fail("4XX"),
|
|
167
|
+
M.fail("5XX"),
|
|
168
|
+
)(response, req);
|
|
169
|
+
if (!result.ok) {
|
|
170
|
+
return [result, { status: "complete", request: req, response }];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return [result, { status: "complete", request: req, response }];
|
|
174
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CeStorefrontCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Refresh POS access token
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Refresh POS access token
|
|
32
|
+
*/
|
|
33
|
+
export function posRefreshPosAccessToken(
|
|
34
|
+
client: CeStorefrontCore,
|
|
35
|
+
request?: operations.RefreshPosAccessTokenRequestBody | undefined,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.RefreshPosAccessTokenResponseBody,
|
|
40
|
+
| CeStorefrontError
|
|
41
|
+
| ResponseValidationError
|
|
42
|
+
| ConnectionError
|
|
43
|
+
| RequestAbortedError
|
|
44
|
+
| RequestTimeoutError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| UnexpectedClientError
|
|
47
|
+
| SDKValidationError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
request,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: CeStorefrontCore,
|
|
59
|
+
request?: operations.RefreshPosAccessTokenRequestBody | undefined,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.RefreshPosAccessTokenResponseBody,
|
|
65
|
+
| CeStorefrontError
|
|
66
|
+
| ResponseValidationError
|
|
67
|
+
| ConnectionError
|
|
68
|
+
| RequestAbortedError
|
|
69
|
+
| RequestTimeoutError
|
|
70
|
+
| InvalidRequestError
|
|
71
|
+
| UnexpectedClientError
|
|
72
|
+
| SDKValidationError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const parsed = safeParse(
|
|
78
|
+
request,
|
|
79
|
+
(value) =>
|
|
80
|
+
operations.RefreshPosAccessTokenRequestBody$outboundSchema.optional()
|
|
81
|
+
.parse(value),
|
|
82
|
+
"Input validation failed",
|
|
83
|
+
);
|
|
84
|
+
if (!parsed.ok) {
|
|
85
|
+
return [parsed, { status: "invalid" }];
|
|
86
|
+
}
|
|
87
|
+
const payload = parsed.value;
|
|
88
|
+
const body = payload === undefined
|
|
89
|
+
? null
|
|
90
|
+
: encodeJSON("body", payload, { explode: true });
|
|
91
|
+
|
|
92
|
+
const path = pathToFunc("/pos/auth/refresh-token")();
|
|
93
|
+
|
|
94
|
+
const headers = new Headers(compactMap({
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
Accept: "application/json",
|
|
97
|
+
}));
|
|
98
|
+
|
|
99
|
+
const secConfig = await extractSecurity(client._options.authorization);
|
|
100
|
+
const securityInput = secConfig == null ? {} : { authorization: secConfig };
|
|
101
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
102
|
+
|
|
103
|
+
const context = {
|
|
104
|
+
options: client._options,
|
|
105
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
106
|
+
operationID: "refresh-pos-access-token",
|
|
107
|
+
oAuth2Scopes: [],
|
|
108
|
+
|
|
109
|
+
resolvedSecurity: requestSecurity,
|
|
110
|
+
|
|
111
|
+
securitySource: client._options.authorization,
|
|
112
|
+
retryConfig: options?.retries
|
|
113
|
+
|| client._options.retryConfig
|
|
114
|
+
|| { strategy: "none" },
|
|
115
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const requestRes = client._createRequest(context, {
|
|
119
|
+
security: requestSecurity,
|
|
120
|
+
method: "POST",
|
|
121
|
+
baseURL: options?.serverURL,
|
|
122
|
+
path: path,
|
|
123
|
+
headers: headers,
|
|
124
|
+
body: body,
|
|
125
|
+
userAgent: client._options.userAgent,
|
|
126
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
127
|
+
}, options);
|
|
128
|
+
if (!requestRes.ok) {
|
|
129
|
+
return [requestRes, { status: "invalid" }];
|
|
130
|
+
}
|
|
131
|
+
const req = requestRes.value;
|
|
132
|
+
|
|
133
|
+
const doResult = await client._do(req, {
|
|
134
|
+
context,
|
|
135
|
+
errorCodes: ["4XX", "5XX"],
|
|
136
|
+
retryConfig: context.retryConfig,
|
|
137
|
+
retryCodes: context.retryCodes,
|
|
138
|
+
});
|
|
139
|
+
if (!doResult.ok) {
|
|
140
|
+
return [doResult, { status: "request-error", request: req }];
|
|
141
|
+
}
|
|
142
|
+
const response = doResult.value;
|
|
143
|
+
|
|
144
|
+
const [result] = await M.match<
|
|
145
|
+
operations.RefreshPosAccessTokenResponseBody,
|
|
146
|
+
| CeStorefrontError
|
|
147
|
+
| ResponseValidationError
|
|
148
|
+
| ConnectionError
|
|
149
|
+
| RequestAbortedError
|
|
150
|
+
| RequestTimeoutError
|
|
151
|
+
| InvalidRequestError
|
|
152
|
+
| UnexpectedClientError
|
|
153
|
+
| SDKValidationError
|
|
154
|
+
>(
|
|
155
|
+
M.json(200, operations.RefreshPosAccessTokenResponseBody$inboundSchema),
|
|
156
|
+
M.fail("4XX"),
|
|
157
|
+
M.fail("5XX"),
|
|
158
|
+
)(response, req);
|
|
159
|
+
if (!result.ok) {
|
|
160
|
+
return [result, { status: "complete", request: req, response }];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return [result, { status: "complete", request: req, response }];
|
|
164
|
+
}
|