@sayren/store-sdk 0.1.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/dist/index.d.mts +5338 -0
- package/dist/index.mjs +2300 -0
- package/dist/server.d.mts +59 -0
- package/dist/server.mjs +125 -0
- package/dist/webhook-headers-D6QmPdEJ.d.mts +22 -0
- package/dist/webhook-headers-ap_exsb9.mjs +22 -0
- package/package.json +48 -0
- package/src/base64.ts +28 -0
- package/src/client.ts +877 -0
- package/src/http.ts +194 -0
- package/src/index.ts +35 -0
- package/src/oauth.ts +132 -0
- package/src/schemas/api-client.ts +121 -0
- package/src/schemas/api-log.ts +104 -0
- package/src/schemas/auth.ts +81 -0
- package/src/schemas/category.ts +98 -0
- package/src/schemas/claim.ts +89 -0
- package/src/schemas/common.ts +61 -0
- package/src/schemas/misc.ts +298 -0
- package/src/schemas/order.ts +233 -0
- package/src/schemas/payment.ts +582 -0
- package/src/schemas/product.ts +272 -0
- package/src/schemas/scope.ts +75 -0
- package/src/schemas/store.ts +143 -0
- package/src/schemas/upload.ts +23 -0
- package/src/schemas/webhook-event.ts +145 -0
- package/src/server.ts +24 -0
- package/src/session.ts +249 -0
- package/src/webhook-headers.ts +21 -0
- package/src/webhook-signature.ts +177 -0
package/src/client.ts
ADDED
|
@@ -0,0 +1,877 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { base64Utf8 } from "./base64";
|
|
3
|
+
import { createHttp, path, type Query, resolveToken, type TokenSource, unwrapData } from "./http";
|
|
4
|
+
import {
|
|
5
|
+
type ApiClientListParams,
|
|
6
|
+
apiClientSchema,
|
|
7
|
+
apiClientSecretRotatedSchema,
|
|
8
|
+
type OAuthClientRegistrationRequest,
|
|
9
|
+
oauthClientRegistrationRequestSchema,
|
|
10
|
+
oauthClientRegistrationResponseSchema,
|
|
11
|
+
} from "./schemas/api-client";
|
|
12
|
+
import { type ApiLogListOptions, apiLogPageSchema, apiLogSummarySchema } from "./schemas/api-log";
|
|
13
|
+
import {
|
|
14
|
+
type ApiTokenCreateRequest,
|
|
15
|
+
apiTokenCreatedSchema,
|
|
16
|
+
apiTokenCreateRequestSchema,
|
|
17
|
+
apiTokenSchema,
|
|
18
|
+
clientCredentialsTokenResponseSchema,
|
|
19
|
+
myAccountSchema,
|
|
20
|
+
myStoreSchema,
|
|
21
|
+
} from "./schemas/auth";
|
|
22
|
+
import {
|
|
23
|
+
type CategoryCreateRequest,
|
|
24
|
+
type CategoryDeleteStrategy,
|
|
25
|
+
type CategoryPatchRequest,
|
|
26
|
+
categoryAttributeSchema,
|
|
27
|
+
categoryCreateRequestSchema,
|
|
28
|
+
categoryPatchRequestSchema,
|
|
29
|
+
categorySchema,
|
|
30
|
+
categorySearchResultSchema,
|
|
31
|
+
categoryTreeNodeSchema,
|
|
32
|
+
categoryWithPathSchema,
|
|
33
|
+
} from "./schemas/category";
|
|
34
|
+
import {
|
|
35
|
+
approveClaimResultSchema,
|
|
36
|
+
type ClaimListParams,
|
|
37
|
+
claimSchema,
|
|
38
|
+
claimStatusSchema,
|
|
39
|
+
type RejectClaimRequest,
|
|
40
|
+
rejectClaimRequestSchema,
|
|
41
|
+
} from "./schemas/claim";
|
|
42
|
+
import { bulkResultSchema, type PageParams, pageSchema } from "./schemas/common";
|
|
43
|
+
import {
|
|
44
|
+
type CustomerInquiryCategory,
|
|
45
|
+
inquirySchema,
|
|
46
|
+
type ReviewListParams,
|
|
47
|
+
reviewSchema,
|
|
48
|
+
type SettlementListParams,
|
|
49
|
+
sellerCustomerInquirySchema,
|
|
50
|
+
settlementDetailSchema,
|
|
51
|
+
settlementSummarySchema,
|
|
52
|
+
type WebhookDeliveryListParams,
|
|
53
|
+
type WebhookRequest,
|
|
54
|
+
type WebhookTestRequest,
|
|
55
|
+
webhookCreatedSchema,
|
|
56
|
+
webhookDeliverySchema,
|
|
57
|
+
webhookRedeliverFailedResultSchema,
|
|
58
|
+
webhookRequestSchema,
|
|
59
|
+
webhookSchema,
|
|
60
|
+
webhookSecretRotatedSchema,
|
|
61
|
+
webhookTestRequestSchema,
|
|
62
|
+
webhookTestResultSchema,
|
|
63
|
+
} from "./schemas/misc";
|
|
64
|
+
import {
|
|
65
|
+
type CancelBySellerRequest,
|
|
66
|
+
cancelBySellerRequestSchema,
|
|
67
|
+
carrierSchema,
|
|
68
|
+
type DispatchRequest,
|
|
69
|
+
deliveryInfoSchema,
|
|
70
|
+
dispatchRequestSchema,
|
|
71
|
+
type HoldOrderItemRequest,
|
|
72
|
+
holdOrderItemRequestSchema,
|
|
73
|
+
type OrderItemListParams,
|
|
74
|
+
type OrderListParams,
|
|
75
|
+
orderItemSchema,
|
|
76
|
+
orderSchema,
|
|
77
|
+
orderSummarySchema,
|
|
78
|
+
} from "./schemas/order";
|
|
79
|
+
import {
|
|
80
|
+
type PaymentListParams,
|
|
81
|
+
type PgEnvironment,
|
|
82
|
+
type PgProvider,
|
|
83
|
+
paymentProviderSchema,
|
|
84
|
+
paymentProviderVerificationSchema,
|
|
85
|
+
paymentRecordDetailSchema,
|
|
86
|
+
paymentRecordPageSchema,
|
|
87
|
+
paymentSettingsSchema,
|
|
88
|
+
pgEnvironmentSchema,
|
|
89
|
+
pgProviderSchema,
|
|
90
|
+
type SalesReportParams,
|
|
91
|
+
salesReportQuerySchema,
|
|
92
|
+
salesReportSchema,
|
|
93
|
+
type UpdatePaymentProviderRequest,
|
|
94
|
+
type UpdatePaymentSettingsRequest,
|
|
95
|
+
type UpsertPortOneProviderRequest,
|
|
96
|
+
type UpsertTossPaymentsProviderRequest,
|
|
97
|
+
updatePaymentProviderRequestSchema,
|
|
98
|
+
updatePaymentSettingsRequestSchema,
|
|
99
|
+
upsertPortOneProviderRequestSchema,
|
|
100
|
+
upsertTossPaymentsProviderRequestSchema,
|
|
101
|
+
type VerifyPaymentProviderRequest,
|
|
102
|
+
verifyPaymentProviderRequestSchema,
|
|
103
|
+
} from "./schemas/payment";
|
|
104
|
+
import {
|
|
105
|
+
type DiscountRequest,
|
|
106
|
+
discountRequestSchema,
|
|
107
|
+
discountSchema,
|
|
108
|
+
type OptionModelRequest,
|
|
109
|
+
optionModelRequestSchema,
|
|
110
|
+
optionModelSchema,
|
|
111
|
+
type ProductCreateRequest,
|
|
112
|
+
type ProductListParams,
|
|
113
|
+
type ProductPatchRequest,
|
|
114
|
+
type ProductStatus,
|
|
115
|
+
productCreateRequestSchema,
|
|
116
|
+
productPatchRequestSchema,
|
|
117
|
+
productSchema,
|
|
118
|
+
productStatusSchema,
|
|
119
|
+
productSummarySchema,
|
|
120
|
+
type VariantStockRequest,
|
|
121
|
+
variantStockRequestSchema,
|
|
122
|
+
variantStockSchema,
|
|
123
|
+
} from "./schemas/product";
|
|
124
|
+
import {
|
|
125
|
+
type AddressType,
|
|
126
|
+
invitationSchema,
|
|
127
|
+
type SellerAddressRequest,
|
|
128
|
+
sellerAddressRequestSchema,
|
|
129
|
+
sellerAddressSchema,
|
|
130
|
+
storeMemberSchema,
|
|
131
|
+
storeSchema,
|
|
132
|
+
} from "./schemas/store";
|
|
133
|
+
import { type UploadRequest, uploadRequestSchema, uploadTicketSchema } from "./schemas/upload";
|
|
134
|
+
import type { AuthorizeOptions, StoreSession } from "./session";
|
|
135
|
+
|
|
136
|
+
export interface StoreClientOptions {
|
|
137
|
+
/** ์: https://api.example.com/v1 */
|
|
138
|
+
baseUrl: string;
|
|
139
|
+
/** ์ ์ ํ ํฐ (1๋จ๊ณ). ์ธ์ฆ/์คํ ์ด ๋ชฉ๋ก API์ ์ฌ์ฉ */
|
|
140
|
+
userToken?: TokenSource;
|
|
141
|
+
/** ์คํ ์ด ํ ํฐ (3๋จ๊ณ). ํ
๋ํธ ๋ฆฌ์์ค API์ ์ฌ์ฉ */
|
|
142
|
+
storeToken?: TokenSource;
|
|
143
|
+
/** ํ
๋ํธ storeId โ storeHttp(ํ
๋ํธ ๋ฆฌ์์ค) ์์ฒญ์ X-Store-Id๋ก ์ค๋ฆฐ๋ค(userToken ์ง์ ์ธ๊ฐ). */
|
|
144
|
+
storeId?: TokenSource;
|
|
145
|
+
/**
|
|
146
|
+
* ํ ํฐ ์ฃผ์
๋ชจ๋ โ PAT/storeToken๊ธ(ํ
๋ํธ ๋ฐ์ธ๋ฉ, role ์์)์ storeHttp Bearer๋ก ์ฃ๋๋ค.
|
|
147
|
+
* userToken์ด ์๋๋ค(๋น์ธํฐ๋ํฐ๋ธ M2M/CLI ๊ฒฝ๋ก์ฉ). storeToken๊ณผ ํจ๊ป ์ฃผ๋ฉด storeToken์ด ์ฐ์ ํ๋ค.
|
|
148
|
+
*/
|
|
149
|
+
auth?: { apiToken?: string };
|
|
150
|
+
/**
|
|
151
|
+
* SDK ์ธ์
๋งค๋์ โ ์ ๋ฌํ๋ฉด userToken(Bearer)ยท401 refreshยท๋ณต๊ตฌ๋ถ๊ฐ ์ clear๋ฅผ
|
|
152
|
+
* ์ด ์ธ์
์์ ์๋ ๋ฐฐ์ ํ๋ค. ๊ฐ๋ณ ์ต์
(userToken/refresh/onUnauthorized)์ ๋ช
์ํ๋ฉด ๊ทธ์ชฝ์ด ์ฐ์ ํ๋ค.
|
|
153
|
+
*/
|
|
154
|
+
session?: StoreSession;
|
|
155
|
+
/** 401 ์ ์ธ์
๊ฐฑ์ ์๋ โ true๋ฉด ์์ฒญ์ 1ํ ์ฌ์๋ํ๋ค(refresh ํ ํฐ ํ์ ) */
|
|
156
|
+
refresh?: () => Promise<boolean>;
|
|
157
|
+
/** ๋ณต๊ตฌ ๋ถ๊ฐ๋ฅํ 401(๊ฐฑ์ ์คํจ/์ฌ์๋ ํ์๋ 401) ์ ํธ์ถ โ ์ฌ๋ก๊ทธ์ธ ์ ๋์ฉ */
|
|
158
|
+
onUnauthorized?: () => void;
|
|
159
|
+
fetch?: typeof globalThis.fetch;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function formBody(fields: Record<string, string>): string {
|
|
163
|
+
return new URLSearchParams(fields).toString();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function createStoreClient(options: StoreClientOptions) {
|
|
167
|
+
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
168
|
+
const { session } = options;
|
|
169
|
+
|
|
170
|
+
// session์ด ์์ผ๋ฉด userToken/refresh/onUnauthorized์ ๊ธฐ๋ณธ๊ฐ์ ์ธ์
์์ ๋ฐฐ์ ํ๋ค.
|
|
171
|
+
// ๊ฐ๋ณ ์ต์
์ ๋ช
์ํ๋ฉด ๊ทธ์ชฝ์ด ์ฐ์ (ํ์ํธํ) โ session ๋ฏธ์ ๋ฌ ์ ๊ธฐ์กด ๋์ ๊ทธ๋๋ก.
|
|
172
|
+
const userTokenSource: TokenSource =
|
|
173
|
+
options.userToken ?? (session ? () => session.getToken() : undefined);
|
|
174
|
+
const refresh = options.refresh ?? (session ? () => session.refresh() : undefined);
|
|
175
|
+
const onUnauthorized = options.onUnauthorized ?? (session ? () => session.clear() : undefined);
|
|
176
|
+
// storeToken(๋ช
์ ์ต์
)์ด auth.apiToken(PAT/storeToken๊ธ ์ฃผ์
)๋ณด๋ค ์ฐ์ ํ๋ค.
|
|
177
|
+
const storeTokenSource: TokenSource = options.storeToken ?? options.auth?.apiToken;
|
|
178
|
+
|
|
179
|
+
const userHttp = createHttp({
|
|
180
|
+
baseUrl: options.baseUrl,
|
|
181
|
+
fetch: fetchFn,
|
|
182
|
+
headers: () => {
|
|
183
|
+
const token = resolveToken(userTokenSource);
|
|
184
|
+
return token ? { authorization: `Bearer ${token}` } : ({} as Record<string, string>);
|
|
185
|
+
},
|
|
186
|
+
refresh,
|
|
187
|
+
onUnauthorized,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const storeHttp = createHttp({
|
|
191
|
+
baseUrl: options.baseUrl,
|
|
192
|
+
fetch: fetchFn,
|
|
193
|
+
headers: () => {
|
|
194
|
+
const token = resolveToken(storeTokenSource);
|
|
195
|
+
const storeId = resolveToken(options.storeId);
|
|
196
|
+
return {
|
|
197
|
+
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
198
|
+
...(storeId ? { "x-store-id": storeId } : {}),
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
refresh,
|
|
202
|
+
onUnauthorized,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
/** `PATCH /v1/store/payment-providers/{provider}` ๋จ์ผ ๊ตฌํ โ `updateProvider`ยท`setSandboxMode`๊ฐ ๊ณต์ ํ๋ค */
|
|
206
|
+
function updatePaymentProvider(provider: PgProvider, body: UpdatePaymentProviderRequest) {
|
|
207
|
+
return storeHttp.request(
|
|
208
|
+
"PATCH",
|
|
209
|
+
path`/store/payment-providers/${pgProviderSchema.parse(provider)}`,
|
|
210
|
+
paymentProviderSchema,
|
|
211
|
+
{ body: updatePaymentProviderRequestSchema.parse(body) },
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function idempotency(key?: string): Record<string, string> | undefined {
|
|
216
|
+
return key ? { "idempotency-key": key } : undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function requireSession(): StoreSession {
|
|
220
|
+
if (!session) throw new Error("oauth ์ธ์
์์ โ createStoreSession ํ์");
|
|
221
|
+
return session;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
/** session์ ํ์ฌ userToken (session ๋ฏธ๋ฐฐ์ ์ null โ ๋์ง์ง ์์) */
|
|
226
|
+
get accessToken(): string | null {
|
|
227
|
+
return session ? session.accessToken : null;
|
|
228
|
+
},
|
|
229
|
+
/** session์ ํ์ฌ refresh ํ ํฐ (session ๋ฏธ๋ฐฐ์ ์ null โ ๋์ง์ง ์์) */
|
|
230
|
+
get refreshToken(): string | null {
|
|
231
|
+
return session ? session.refreshToken : null;
|
|
232
|
+
},
|
|
233
|
+
/** session.authorize ํจ์ค์ค๋ฃจ โ session ๋ฏธ๋ฐฐ์ ์ ๋ช
ํํ ์๋ฌ๋ฅผ ๋์ง๋ค */
|
|
234
|
+
authorize: (authorizeOptions: AuthorizeOptions) => requireSession().authorize(authorizeOptions),
|
|
235
|
+
/** session.userinfo ํจ์ค์ค๋ฃจ โ session ๋ฏธ๋ฐฐ์ ์ ๋ช
ํํ ์๋ฌ๋ฅผ ๋์ง๋ค */
|
|
236
|
+
userinfo: () => requireSession().userinfo(),
|
|
237
|
+
|
|
238
|
+
auth: {
|
|
239
|
+
/**
|
|
240
|
+
* ์๋ฒ ๊ฐ ์ฐ๋(M2M) โ client_credentials grant (client_secret_basic).
|
|
241
|
+
* ํด๋ผ์ด์ธํธ๊ฐ ์คํ ์ด์ ๋ฐ์ธ๋ฉ๋์ด ์์ด **storeToken์ด ๊ณง๋ฐ๋ก ๋ฐ๊ธ**๋๋ค.
|
|
242
|
+
* โ client_secret์ ์๋ฒ ํ๊ฒฝ์์๋ง ์ฌ์ฉํ ๊ฒ (๋ธ๋ผ์ฐ์ ๋ฐ์
๊ธ์ง)
|
|
243
|
+
*/
|
|
244
|
+
async issueStoreTokenByClientCredentials(
|
|
245
|
+
clientId: string,
|
|
246
|
+
clientSecret: string,
|
|
247
|
+
scope?: string,
|
|
248
|
+
) {
|
|
249
|
+
// RFC 7617 client_secret_basic โ UTF-8 ๋ฐ์ดํธ๋ฅผ base64๋ก ์ธ์ฝ๋ฉํ๋ค.
|
|
250
|
+
const credentials = base64Utf8(`${clientId}:${clientSecret}`);
|
|
251
|
+
const response = await fetchFn(`${options.baseUrl}/oauth2/token`, {
|
|
252
|
+
method: "POST",
|
|
253
|
+
headers: {
|
|
254
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
255
|
+
authorization: `Basic ${credentials}`,
|
|
256
|
+
},
|
|
257
|
+
body: formBody({ grant_type: "client_credentials", ...(scope ? { scope } : {}) }),
|
|
258
|
+
});
|
|
259
|
+
if (!response.ok) {
|
|
260
|
+
const body = (await response.json().catch(() => null)) as {
|
|
261
|
+
error_description?: string;
|
|
262
|
+
} | null;
|
|
263
|
+
throw new Error(body?.error_description ?? `ํ ํฐ ๋ฐ๊ธ ์คํจ (HTTP ${response.status})`);
|
|
264
|
+
}
|
|
265
|
+
return clientCredentialsTokenResponseSchema.parse(unwrapData(await response.json()));
|
|
266
|
+
},
|
|
267
|
+
/** 2๋จ๊ณ โ ์์ ์คํ ์ด ๋ชฉ๋ก */
|
|
268
|
+
listMyStores: () => userHttp.request("GET", "/me/stores", z.array(myStoreSchema)),
|
|
269
|
+
/** RFC 7009 โ token์ ํ๊ธฐํ๋ค (public client๋ client_id๋ง ๋๋ฐ) */
|
|
270
|
+
async revoke(token: string, clientId: string) {
|
|
271
|
+
await fetchFn(`${options.baseUrl}/oauth2/revoke`, {
|
|
272
|
+
method: "POST",
|
|
273
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
274
|
+
body: formBody({ token, client_id: clientId }),
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
me: () => userHttp.request("GET", "/me", myAccountSchema),
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/** API ํ ํฐ(PAT) ๊ด๋ฆฌ โ OWNER/ADMIN ์ ์ฉ. ๋ฐ๊ธ๋ ํ ํฐ์ storeToken์ฒ๋ผ Bearer๋ก ์ฌ์ฉ */
|
|
281
|
+
apiTokens: {
|
|
282
|
+
create: (body: ApiTokenCreateRequest) =>
|
|
283
|
+
storeHttp.request("POST", "/store/api-tokens", apiTokenCreatedSchema, {
|
|
284
|
+
body: apiTokenCreateRequestSchema.parse(body),
|
|
285
|
+
}),
|
|
286
|
+
list: () => storeHttp.request("GET", "/store/api-tokens", z.array(apiTokenSchema)),
|
|
287
|
+
revoke: (tokenId: string) =>
|
|
288
|
+
storeHttp.requestVoid("DELETE", path`/store/api-tokens/${tokenId}`),
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* ์ฑ(OAuth ํด๋ผ์ด์ธํธ) ๊ด๋ฆฌ โ OWNER/ADMIN storeToken ์ ์ฉ(PATยทM2M ๊ฑฐ๋ถ). auth-spec ยง12, ๋ถ๋ก B-13.
|
|
293
|
+
* ์ํฌ๋ฆฟ ํ๋ฌธ์ registerยทrotateSecret ์๋ต์์๋ง ํ ๋ฒ ๋
ธ์ถ๋๋ค(apiTokens.create์ ๊ฐ์ ์ฑ๊ฒฉ).
|
|
294
|
+
*/
|
|
295
|
+
apiClients: {
|
|
296
|
+
/**
|
|
297
|
+
* DCR ๋ฑ๋ก (RFC 7591) โ `POST /v1/oauth2/register`. OAuth ํ๋กํ ์ฝ ํ๋ฉด์ด๋ผ ์๋ต์ด ํ๋ฉด JSON์ด๋ค.
|
|
298
|
+
* ๋ฑ๋ก ์ค๋ฅ(`invalid_client_metadata`ยท`invalid_redirect_uri`)๋ ApiError(code=error,
|
|
299
|
+
* message=error_description)๋ก, Bearer ์ธ์ฆ ์ค๋ฅ๋ ์๋ฒจ๋กํ ๊ทธ๋๋ก ApiError๋ก ๋์ง๋ค.
|
|
300
|
+
*/
|
|
301
|
+
register: (body: OAuthClientRegistrationRequest) =>
|
|
302
|
+
storeHttp.request("POST", "/oauth2/register", oauthClientRegistrationResponseSchema, {
|
|
303
|
+
body: oauthClientRegistrationRequestSchema.parse(body),
|
|
304
|
+
}),
|
|
305
|
+
list: (params?: ApiClientListParams) =>
|
|
306
|
+
storeHttp.request("GET", "/store/api-clients", z.array(apiClientSchema), {
|
|
307
|
+
query: params as Query,
|
|
308
|
+
}),
|
|
309
|
+
get: (clientId: string) =>
|
|
310
|
+
storeHttp.request("GET", path`/store/api-clients/${clientId}`, apiClientSchema),
|
|
311
|
+
/** confidential ์ ์ฉ. ๊ธฐ์กด ์ํฌ๋ฆฟ์ ์ฆ์ ๋ฌดํจ(์ ์ ์์) */
|
|
312
|
+
rotateSecret: (clientId: string) =>
|
|
313
|
+
storeHttp.request(
|
|
314
|
+
"POST",
|
|
315
|
+
path`/store/api-clients/${clientId}/rotate-secret`,
|
|
316
|
+
apiClientSecretRotatedSchema,
|
|
317
|
+
),
|
|
318
|
+
/** REVOKED๋ก ์ ํ(๋๋๋ฆด ์ ์์). ์ด๋ฏธ ๋นํ์ฑ์ด๋ฉด ํ์ฌ ์ํ๋ฅผ ๊ทธ๋๋ก ๋๋ ค์ค๋ค */
|
|
319
|
+
deactivate: (clientId: string) =>
|
|
320
|
+
storeHttp.request("POST", path`/store/api-clients/${clientId}/deactivate`, apiClientSchema),
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* ๋ฏธ๋์ด ์
๋ก๋ โ ์๋ฆฌ๋ฅผ ๋ฐ์(`POST /uploads`) ํ์ผ ๋ฐ์ดํธ๋ ํธ์ถ์๊ฐ
|
|
325
|
+
* `uploadUrl`๋ก ์ง์ PUTํ๋ค. ์
๋ก๋๊ฐ ๋๋๋ฉด `url`์ด ๊ณต๊ฐ ์ฃผ์๊ฐ ๋๋ค.
|
|
326
|
+
*/
|
|
327
|
+
uploads: {
|
|
328
|
+
create: (body: UploadRequest) =>
|
|
329
|
+
storeHttp.request("POST", "/uploads", uploadTicketSchema, {
|
|
330
|
+
body: uploadRequestSchema.parse(body),
|
|
331
|
+
}),
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
products: {
|
|
335
|
+
list: (params?: ProductListParams) =>
|
|
336
|
+
storeHttp.request("GET", "/products", pageSchema(productSummarySchema), {
|
|
337
|
+
query: params as Query,
|
|
338
|
+
}),
|
|
339
|
+
get: (productId: string) =>
|
|
340
|
+
storeHttp.request("GET", path`/products/${productId}`, productSchema),
|
|
341
|
+
create: (body: ProductCreateRequest, idempotencyKey?: string) =>
|
|
342
|
+
storeHttp.request("POST", "/products", productSchema, {
|
|
343
|
+
body: productCreateRequestSchema.parse(body),
|
|
344
|
+
headers: idempotency(idempotencyKey),
|
|
345
|
+
}),
|
|
346
|
+
update: (productId: string, body: ProductCreateRequest) =>
|
|
347
|
+
storeHttp.request("PUT", path`/products/${productId}`, productSchema, {
|
|
348
|
+
body: productCreateRequestSchema.parse(body),
|
|
349
|
+
}),
|
|
350
|
+
patch: (productId: string, body: ProductPatchRequest) =>
|
|
351
|
+
storeHttp.requestVoid("PATCH", path`/products/${productId}`, {
|
|
352
|
+
body: productPatchRequestSchema.parse(body),
|
|
353
|
+
}),
|
|
354
|
+
remove: (productId: string) => storeHttp.requestVoid("DELETE", path`/products/${productId}`),
|
|
355
|
+
bulkUpdateStatus: (productIds: string[], status: ProductStatus, idempotencyKey?: string) =>
|
|
356
|
+
storeHttp.request("POST", "/products/bulk/status", bulkResultSchema, {
|
|
357
|
+
body: { productIds, status: productStatusSchema.parse(status) },
|
|
358
|
+
headers: idempotency(idempotencyKey),
|
|
359
|
+
}),
|
|
360
|
+
/** ์ต์
์ถ(๊ทธ๋ฃน) ร ๊ฐ โ variant ๋ชจ๋ธ ์กฐํ */
|
|
361
|
+
getOptionModel: (productId: string) =>
|
|
362
|
+
storeHttp.request("GET", path`/products/${productId}/options`, optionModelSchema),
|
|
363
|
+
/**
|
|
364
|
+
* ์ต์
๋ชจ๋ธ ์ ์ฒด ๊ต์ฒด โ variants๋ valueNames๋ก ์ถ ๊ฐ์ ์ง๋ชฉํ๋ค.
|
|
365
|
+
* ์๋ต์ผ๋ก ์๋ฒ๊ฐ ๋ฐฐ์ ํ groupIdยทvalueIdยท์ ๊ท variantId๊ฐ ์ค๋ฆฐ ๊ต์ฒด ๊ฒฐ๊ณผ๋ฅผ ๋๋ ค์ค๋ค.
|
|
366
|
+
*/
|
|
367
|
+
replaceOptionModel: (productId: string, body: OptionModelRequest) =>
|
|
368
|
+
storeHttp.request("PUT", path`/products/${productId}/options`, optionModelSchema, {
|
|
369
|
+
body: optionModelRequestSchema.parse(body),
|
|
370
|
+
}),
|
|
371
|
+
/** ์ฌ๊ณ ๋ณ๊ฒฝ โ stockQuantity(์ ๋๊ฐ) ๋๋ adjustment(์ฆ๊ฐ) ํ๋๋ง ์ ๋ฌํ๋ค */
|
|
372
|
+
updateVariantStock: (productId: string, variantId: string, body: VariantStockRequest) =>
|
|
373
|
+
storeHttp.request(
|
|
374
|
+
"PATCH",
|
|
375
|
+
path`/products/${productId}/variants/${variantId}/stock`,
|
|
376
|
+
variantStockSchema,
|
|
377
|
+
{ body: variantStockRequestSchema.parse(body) },
|
|
378
|
+
),
|
|
379
|
+
getDiscount: (productId: string) =>
|
|
380
|
+
storeHttp.request("GET", path`/products/${productId}/discount`, discountSchema),
|
|
381
|
+
setDiscount: (productId: string, body: DiscountRequest) =>
|
|
382
|
+
storeHttp.request("PUT", path`/products/${productId}/discount`, discountSchema, {
|
|
383
|
+
body: discountRequestSchema.parse(body),
|
|
384
|
+
}),
|
|
385
|
+
removeDiscount: (productId: string) =>
|
|
386
|
+
storeHttp.requestVoid("DELETE", path`/products/${productId}/discount`),
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
categories: {
|
|
390
|
+
list: (params?: { parentId?: string; flat?: boolean }) =>
|
|
391
|
+
storeHttp.request("GET", "/categories", z.array(categorySchema), {
|
|
392
|
+
query: params as Query,
|
|
393
|
+
}),
|
|
394
|
+
tree: () =>
|
|
395
|
+
storeHttp.request("GET", "/categories", z.array(categoryTreeNodeSchema), {
|
|
396
|
+
query: { tree: true } as Query,
|
|
397
|
+
}),
|
|
398
|
+
search: (q: string) =>
|
|
399
|
+
storeHttp.request("GET", "/categories", z.array(categorySearchResultSchema), {
|
|
400
|
+
query: { q } as Query,
|
|
401
|
+
}),
|
|
402
|
+
get: (categoryId: string) =>
|
|
403
|
+
storeHttp.request("GET", path`/categories/${categoryId}`, categoryWithPathSchema),
|
|
404
|
+
listAttributes: (categoryId: string) =>
|
|
405
|
+
storeHttp.request(
|
|
406
|
+
"GET",
|
|
407
|
+
path`/categories/${categoryId}/attributes`,
|
|
408
|
+
z.array(categoryAttributeSchema),
|
|
409
|
+
),
|
|
410
|
+
create: (body: CategoryCreateRequest, idempotencyKey?: string) =>
|
|
411
|
+
storeHttp.request("POST", "/categories", categorySchema, {
|
|
412
|
+
body: categoryCreateRequestSchema.parse(body),
|
|
413
|
+
headers: idempotency(idempotencyKey),
|
|
414
|
+
}),
|
|
415
|
+
update: (categoryId: string, body: CategoryPatchRequest) =>
|
|
416
|
+
storeHttp.request("PATCH", path`/categories/${categoryId}`, categorySchema, {
|
|
417
|
+
body: categoryPatchRequestSchema.parse(body),
|
|
418
|
+
}),
|
|
419
|
+
remove: (categoryId: string, opts?: { strategy?: CategoryDeleteStrategy }) =>
|
|
420
|
+
storeHttp.requestVoid("DELETE", path`/categories/${categoryId}`, {
|
|
421
|
+
query: (opts?.strategy ? { strategy: opts.strategy } : {}) as Query,
|
|
422
|
+
}),
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
orders: {
|
|
426
|
+
/**
|
|
427
|
+
* `GET /v1/orders`. `testPayment: "true"`๋ ํ
์คํธ ๊ฒฐ์ (์๋๋ฐ์ค) ์ฃผ๋ฌธ๋ง, `"false"`๋ ์ค๊ฒฐ์ ์ฃผ๋ฌธ๋ง, ์๋ตํ๋ฉด ์ ๋ถ๋ค.
|
|
428
|
+
* ๊ทธ ๋ฐ์ ๊ฐ์ 400 `INVALID_PARAMETER`. ํ๋ง๋ค `testPayment`๊ฐ ๋ถ๋๋ค.
|
|
429
|
+
*/
|
|
430
|
+
list: (params: OrderListParams) =>
|
|
431
|
+
storeHttp.request("GET", "/orders", pageSchema(orderSummarySchema), {
|
|
432
|
+
query: params as unknown as Query,
|
|
433
|
+
}),
|
|
434
|
+
get: (orderId: string) => storeHttp.request("GET", path`/orders/${orderId}`, orderSchema),
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
orderItems: {
|
|
438
|
+
/** `GET /v1/order-items`. `testPayment` ํํฐ๋ `orders.list`์ ๊ฐ๋ค */
|
|
439
|
+
listChanged: (params: OrderItemListParams) =>
|
|
440
|
+
storeHttp.request("GET", "/order-items", pageSchema(orderItemSchema), {
|
|
441
|
+
query: params as unknown as Query,
|
|
442
|
+
}),
|
|
443
|
+
confirm: (orderItemId: string, idempotencyKey?: string) =>
|
|
444
|
+
storeHttp.requestVoid("POST", path`/order-items/${orderItemId}/confirm`, {
|
|
445
|
+
headers: idempotency(idempotencyKey),
|
|
446
|
+
}),
|
|
447
|
+
confirmBulk: (orderItemIds: string[], idempotencyKey?: string) =>
|
|
448
|
+
storeHttp.request("POST", "/order-items/confirm", bulkResultSchema, {
|
|
449
|
+
body: { orderItemIds },
|
|
450
|
+
headers: idempotency(idempotencyKey),
|
|
451
|
+
}),
|
|
452
|
+
hold: (orderItemId: string, body: HoldOrderItemRequest) =>
|
|
453
|
+
storeHttp.requestVoid("POST", path`/order-items/${orderItemId}/hold`, {
|
|
454
|
+
body: holdOrderItemRequestSchema.parse(body),
|
|
455
|
+
}),
|
|
456
|
+
releaseHold: (orderItemId: string) =>
|
|
457
|
+
storeHttp.requestVoid("DELETE", path`/order-items/${orderItemId}/hold`),
|
|
458
|
+
cancelBySeller: (orderItemId: string, body: CancelBySellerRequest, idempotencyKey?: string) =>
|
|
459
|
+
storeHttp.request(
|
|
460
|
+
"POST",
|
|
461
|
+
path`/order-items/${orderItemId}/cancel`,
|
|
462
|
+
z.object({
|
|
463
|
+
orderItemId: z.string(),
|
|
464
|
+
refundAmount: z.number().int(),
|
|
465
|
+
refundedAt: z.string(),
|
|
466
|
+
}),
|
|
467
|
+
{ body: cancelBySellerRequestSchema.parse(body), headers: idempotency(idempotencyKey) },
|
|
468
|
+
),
|
|
469
|
+
updateMemo: (orderItemId: string, memo: string) =>
|
|
470
|
+
storeHttp.requestVoid("PUT", path`/order-items/${orderItemId}/memo`, { body: { memo } }),
|
|
471
|
+
requestPurchaseDecision: (orderItemId: string) =>
|
|
472
|
+
storeHttp.requestVoid("POST", path`/order-items/${orderItemId}/purchase-decision/request`),
|
|
473
|
+
extendPurchaseDecision: (orderItemId: string) =>
|
|
474
|
+
storeHttp.request(
|
|
475
|
+
"POST",
|
|
476
|
+
path`/order-items/${orderItemId}/purchase-decision/extend`,
|
|
477
|
+
z.object({
|
|
478
|
+
orderItemId: z.string(),
|
|
479
|
+
autoDecisionDate: z.string(),
|
|
480
|
+
extendCount: z.number().int().max(2),
|
|
481
|
+
}),
|
|
482
|
+
),
|
|
483
|
+
dispatch: (orderItemId: string, body: DispatchRequest, idempotencyKey?: string) =>
|
|
484
|
+
storeHttp.request("POST", path`/order-items/${orderItemId}/dispatch`, deliveryInfoSchema, {
|
|
485
|
+
body: dispatchRequestSchema.parse(body),
|
|
486
|
+
headers: idempotency(idempotencyKey),
|
|
487
|
+
}),
|
|
488
|
+
dispatchBulk: (
|
|
489
|
+
dispatches: Array<{ orderItemId: string } & DispatchRequest>,
|
|
490
|
+
idempotencyKey?: string,
|
|
491
|
+
) =>
|
|
492
|
+
storeHttp.request("POST", "/order-items/dispatch", bulkResultSchema, {
|
|
493
|
+
body: { dispatches },
|
|
494
|
+
headers: idempotency(idempotencyKey),
|
|
495
|
+
}),
|
|
496
|
+
updateTracking: (orderItemId: string, carrierCode: string, trackingNumber: string) =>
|
|
497
|
+
storeHttp.requestVoid("PUT", path`/order-items/${orderItemId}/dispatch/tracking`, {
|
|
498
|
+
body: { carrierCode, trackingNumber },
|
|
499
|
+
}),
|
|
500
|
+
getDelivery: (orderItemId: string) =>
|
|
501
|
+
storeHttp.request(
|
|
502
|
+
"GET",
|
|
503
|
+
path`/order-items/${orderItemId}/delivery`,
|
|
504
|
+
deliveryInfoSchema.extend({
|
|
505
|
+
trackingEvents: z
|
|
506
|
+
.array(z.object({ status: z.string(), location: z.string(), occurredAt: z.string() }))
|
|
507
|
+
.optional(),
|
|
508
|
+
}),
|
|
509
|
+
),
|
|
510
|
+
},
|
|
511
|
+
|
|
512
|
+
carriers: {
|
|
513
|
+
list: () => storeHttp.request("GET", "/carriers", z.array(carrierSchema)),
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
claims: {
|
|
517
|
+
list: (params?: ClaimListParams) =>
|
|
518
|
+
storeHttp.request("GET", "/claims", pageSchema(claimSchema), { query: params as Query }),
|
|
519
|
+
get: (claimId: string) =>
|
|
520
|
+
storeHttp.request(
|
|
521
|
+
"GET",
|
|
522
|
+
path`/claims/${claimId}`,
|
|
523
|
+
claimSchema.extend({
|
|
524
|
+
histories: z
|
|
525
|
+
.array(
|
|
526
|
+
z.object({
|
|
527
|
+
status: claimStatusSchema,
|
|
528
|
+
actor: z.enum(["BUYER", "SELLER", "SYSTEM"]),
|
|
529
|
+
occurredAt: z.string(),
|
|
530
|
+
}),
|
|
531
|
+
)
|
|
532
|
+
.optional(),
|
|
533
|
+
}),
|
|
534
|
+
),
|
|
535
|
+
approve: (claimId: string, deductAmount?: number, idempotencyKey?: string) =>
|
|
536
|
+
storeHttp.request("POST", path`/claims/${claimId}/approve`, approveClaimResultSchema, {
|
|
537
|
+
body: deductAmount !== undefined ? { deductAmount } : {},
|
|
538
|
+
headers: idempotency(idempotencyKey),
|
|
539
|
+
}),
|
|
540
|
+
reject: (claimId: string, body: RejectClaimRequest) =>
|
|
541
|
+
storeHttp.requestVoid("POST", path`/claims/${claimId}/reject`, {
|
|
542
|
+
body: rejectClaimRequestSchema.parse(body),
|
|
543
|
+
}),
|
|
544
|
+
registerCollect: (
|
|
545
|
+
claimId: string,
|
|
546
|
+
body: { collectMethod: "SELLER_PICKUP" | "BUYER_SEND"; carrierCode?: string },
|
|
547
|
+
) => storeHttp.requestVoid("POST", path`/claims/${claimId}/collect`, { body }),
|
|
548
|
+
completeCollect: (claimId: string) =>
|
|
549
|
+
storeHttp.requestVoid("POST", path`/claims/${claimId}/collect/complete`),
|
|
550
|
+
registerRedelivery: (claimId: string, carrierCode: string, trackingNumber: string) =>
|
|
551
|
+
storeHttp.requestVoid("POST", path`/claims/${claimId}/redelivery`, {
|
|
552
|
+
body: { carrierCode, trackingNumber },
|
|
553
|
+
}),
|
|
554
|
+
hold: (claimId: string, reason: string) =>
|
|
555
|
+
storeHttp.request(
|
|
556
|
+
"POST",
|
|
557
|
+
path`/claims/${claimId}/hold`,
|
|
558
|
+
z.object({ claimId: z.string(), holdExpiresAt: z.string() }),
|
|
559
|
+
{ body: { reason } },
|
|
560
|
+
),
|
|
561
|
+
releaseHold: (claimId: string) =>
|
|
562
|
+
storeHttp.requestVoid("DELETE", path`/claims/${claimId}/hold`),
|
|
563
|
+
},
|
|
564
|
+
|
|
565
|
+
inquiries: {
|
|
566
|
+
list: (params?: PageParams & { answered?: boolean; productId?: string; from?: string }) =>
|
|
567
|
+
storeHttp.request("GET", "/inquiries", pageSchema(inquirySchema), {
|
|
568
|
+
query: params as Query,
|
|
569
|
+
}),
|
|
570
|
+
get: (inquiryId: string) =>
|
|
571
|
+
storeHttp.request("GET", path`/inquiries/${inquiryId}`, inquirySchema),
|
|
572
|
+
answer: (inquiryId: string, content: string) =>
|
|
573
|
+
storeHttp.requestVoid("POST", path`/inquiries/${inquiryId}/answer`, { body: { content } }),
|
|
574
|
+
updateAnswer: (inquiryId: string, content: string) =>
|
|
575
|
+
storeHttp.requestVoid("PUT", path`/inquiries/${inquiryId}/answer`, { body: { content } }),
|
|
576
|
+
},
|
|
577
|
+
|
|
578
|
+
customerInquiries: {
|
|
579
|
+
list: (
|
|
580
|
+
params?: PageParams & {
|
|
581
|
+
answered?: boolean;
|
|
582
|
+
category?: CustomerInquiryCategory;
|
|
583
|
+
from?: string;
|
|
584
|
+
},
|
|
585
|
+
) =>
|
|
586
|
+
storeHttp.request("GET", "/customer-inquiries", pageSchema(sellerCustomerInquirySchema), {
|
|
587
|
+
query: params as Query,
|
|
588
|
+
}),
|
|
589
|
+
get: (inquiryId: string) =>
|
|
590
|
+
storeHttp.request(
|
|
591
|
+
"GET",
|
|
592
|
+
path`/customer-inquiries/${inquiryId}`,
|
|
593
|
+
sellerCustomerInquirySchema,
|
|
594
|
+
),
|
|
595
|
+
answer: (inquiryId: string, content: string) =>
|
|
596
|
+
storeHttp.requestVoid("POST", path`/customer-inquiries/${inquiryId}/answer`, {
|
|
597
|
+
body: { content },
|
|
598
|
+
}),
|
|
599
|
+
updateAnswer: (inquiryId: string, content: string) =>
|
|
600
|
+
storeHttp.requestVoid("PUT", path`/customer-inquiries/${inquiryId}/answer`, {
|
|
601
|
+
body: { content },
|
|
602
|
+
}),
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* @deprecated ์ ์ฐ API๋ ํ๊ธฐ ์์ ์ด๋ค. ์ ์ ์ฐ ๋ ์ฝ๋๋ ๋ ์ด์ ๋ง๋ค์ด์ง์ง ์๊ณ ๊ธฐ์กด ๋ ์ฝ๋ ์กฐํ๋ง
|
|
607
|
+
* ์ ์ง๋๋ค(์๋ฒ ์๋ต ํค๋ `Deprecation: true`). ๋์ฒด๋ {@link salesReport}(`GET /v1/sales-report`)๋ค.
|
|
608
|
+
*/
|
|
609
|
+
settlements: {
|
|
610
|
+
/** @deprecated `salesReport.get`์ ์ด๋ค. ๊ธฐ์กด ์ ์ฐ ๋ ์ฝ๋ ์กฐํ๋ง ์ ์ง๋๋ค */
|
|
611
|
+
list: (params: SettlementListParams) =>
|
|
612
|
+
storeHttp.request("GET", "/settlements", pageSchema(settlementSummarySchema), {
|
|
613
|
+
query: params as unknown as Query,
|
|
614
|
+
}),
|
|
615
|
+
/** @deprecated `salesReport.get`์ ์ด๋ค. ๊ธฐ์กด ์ ์ฐ ๋ ์ฝ๋ ์กฐํ๋ง ์ ์ง๋๋ค */
|
|
616
|
+
get: (settlementId: string, params?: PageParams) =>
|
|
617
|
+
storeHttp.request(
|
|
618
|
+
"GET",
|
|
619
|
+
path`/settlements/${settlementId}`,
|
|
620
|
+
settlementSummarySchema.extend({ details: z.array(settlementDetailSchema).optional() }),
|
|
621
|
+
{ query: params as Query },
|
|
622
|
+
),
|
|
623
|
+
},
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* ๋งค์ถ ๋ฆฌํฌํธ (์ ์ฐ API ๋์ฒด) โ ์ค์ฝํ `settlement:r`. PG ์น์ธ ์๊ฐ ๊ธฐ์ค ๊ฒฐ์ , PG ์ทจ์ ์๋ฃ ์๊ฐ ๊ธฐ์ค
|
|
627
|
+
* ํ๋ถ์ Asia/Seoul ๋ ์ง๋ก ์ง๊ณํ๋ค. `rows`๋ ํ๋ ์๋ ๋ ์งยทPGยท๊ฒฐ์ ์๋จ์ ์๋ตํ๋ฏ๋ก ์ฐจํธ๋ ๋น ๊ตฌ๊ฐ์ 0์ผ๋ก ์ฑ์ด๋ค.
|
|
628
|
+
*/
|
|
629
|
+
salesReport: {
|
|
630
|
+
/**
|
|
631
|
+
* `GET /v1/sales-report`. fromยทto๋ ์๋ ํฌํจ, ์ต๋ 92์ผ. ํ
์คํธ ๊ฒฐ์ (์๋๋ฐ์ค)์ ์น์ธยทํ๋ถ์ ๊ธฐ๋ณธ ์ ์ธ์ด๊ณ
|
|
632
|
+
* `includeTest: "true"`๋ฉด ํฌํจํ๋ค(์๋ต `includeTest`์ ์ ์ฉ ๊ฐ). 400 `VALIDATION_FAILED`(ํ์),
|
|
633
|
+
* 400 `INVALID_PARAMETER`(์๋ ๋ ์งยทto<from), 400 `RANGE_TOO_WIDE`(๊ธฐ๊ฐ ์ด๊ณผ)
|
|
634
|
+
*/
|
|
635
|
+
get: (params: SalesReportParams) =>
|
|
636
|
+
storeHttp.request("GET", "/sales-report", salesReportSchema, {
|
|
637
|
+
query: salesReportQuerySchema.parse(params),
|
|
638
|
+
}),
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* ๊ฒฐ์ ๋ด์ญ โ ์ค์ฝํ `settlement:r`. ๊ฒฐ์ ๊ฑด(์ธ์
) ๋จ์์ด๊ณ ์ฃผ๋ฌธ ๋ชฉ๋ก๊ณผ ๋ค๋ฅด๋ค. ์ฃผ๋ฌธ์ด ๋ง๋ค์ด์ง์ง ์์
|
|
643
|
+
* ๊ฒฐ์ (์นด๋ ๊ฑฐ์ ยท๊ฒฐ์ ์ฐฝ ์ดํยท์น์ธ ๊ฒฐ๊ณผ ํ์ธ ์ค)๋ ๊ทธ๋๋ก ๋์จ๋ค.
|
|
644
|
+
*/
|
|
645
|
+
payments: {
|
|
646
|
+
/**
|
|
647
|
+
* `GET /v1/payments`. ๊ธฐ๊ฐ ๊ธฐ์ค์ ๊ฒฐ์ ์์ ์๊ฐ, ์ต๋ 92์ผ์ด๊ณ ์๋ตํ๋ฉด ์ต๊ทผ 30์ผ์ด๋ค. ํ
์คํธ ๊ฒฐ์ ๋
|
|
648
|
+
* `includeTest: true`์ผ ๋๋ง ํฌํจํ๋ค. 400 `INVALID_PARAMETER`(์๊ฐ ํ์ยทto<from), 400 `RANGE_TOO_WIDE`
|
|
649
|
+
*/
|
|
650
|
+
list: (params: PaymentListParams = {}) =>
|
|
651
|
+
storeHttp.request("GET", "/payments", paymentRecordPageSchema, {
|
|
652
|
+
query: params as unknown as Query,
|
|
653
|
+
}),
|
|
654
|
+
/** `GET /v1/payments/{paymentId}` โ ์๋ยทํ๋ถ ์ด๋ ฅ ํฌํจ. 404 `PAYMENT_NOT_FOUND` */
|
|
655
|
+
get: (paymentId: string) =>
|
|
656
|
+
storeHttp.request("GET", path`/payments/${paymentId}`, paymentRecordDetailSchema),
|
|
657
|
+
},
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* ๊ฒฐ์ (PG) ์ค์ โ **์ฝ์ OWNER ์ ์ฉ**. ADMINยทSTAFFยทPATยทM2Mยท3rd-party ์ฑ ํ ํฐ์ ์ค์ฝํ๊ฐ ์์ด๋
|
|
661
|
+
* 403 `INSUFFICIENT_ROLE`์ด๋ค(์กฐํ ํฌํจ). OWNER ์ฌ๋ถ๋ ์์ฒญ ์์ ์ ์คํ ์ด ๋ฉค๋ฒ์ญ์ผ๋ก ๋ค์ ํ์ธํ๋ฏ๋ก
|
|
662
|
+
* ์๋ยท๊ฐ๋ฑ ์งํ์ ์ storeToken๋ 403์ด๋ค(ํ ํฐ์ ์ฌ๋ฐ๊ธ๋ฐ๋๋ค). ๋น๋ฐ ๊ฐ(์ํฌ๋ฆฟ ํคยทAPI Secretยท์นํ
์ํฌ๋ฆฟ)์ ์์ฒญ์ผ๋ก๋ง ๋ณด๋ด๊ณ
|
|
663
|
+
* ์๋ต์๋ `secrets[].masked`(์ 4์๋ฆฌ ๋ง์คํน)๋ง ๋์จ๋ค.
|
|
664
|
+
*/
|
|
665
|
+
paymentSettings: {
|
|
666
|
+
/** `GET /v1/store/payment-settings` โ ๋ผ์ฐํ
๋ชจ๋์ ์ง์ PG ์ ๋ถ(์ฐ๊ฒฐ๋ ๊ฒ์ ์ฐ์ ์์์) */
|
|
667
|
+
get: () => storeHttp.request("GET", "/store/payment-settings", paymentSettingsSchema),
|
|
668
|
+
/**
|
|
669
|
+
* `PUT /v1/store/payment-settings` โ `priority`์๋ ์ฐ๊ฒฐ๋ PG๋ฅผ ๊ฐ์์ ๋ฌด๊ดํ๊ฒ ๋ชจ๋ ํ ๋ฒ์ฉ ๋์ดํ๋ค
|
|
670
|
+
* (๋น ์ง๊ฑฐ๋ ์ค๋ณต๋๋ฉด 400 `INVALID_PRIORITY`). ์งํ ์ค์ธ ๊ฒฐ์ ์๋ ์ ์ฉ๋์ง ์๋๋ค.
|
|
671
|
+
*/
|
|
672
|
+
update: (body: UpdatePaymentSettingsRequest) =>
|
|
673
|
+
storeHttp.request("PUT", "/store/payment-settings", paymentSettingsSchema, {
|
|
674
|
+
body: updatePaymentSettingsRequestSchema.parse(body),
|
|
675
|
+
}),
|
|
676
|
+
/**
|
|
677
|
+
* `PUT /v1/store/payment-providers/tosspayments` โ ์๊ฒฉ ์ฆ๋ช
์ธํธ ์ ์ฅ. `environment`๋ **์ ์ฅํ ์ธํธ**(`TEST`ยท`LIVE`)์ด๊ณ
|
|
678
|
+
* ๊ฒฐ์ ์ ์ฐ๋ ์ธํธ๋ ์๋๋ฐ์ค ์ค์์น(`setSandboxMode`)๊ฐ ์ ํ๋ค. ์ฒ์ ์ฐ๊ฒฐํ๋ฉด `enabled: false`ยท`sandboxMode: true`๋ก ๋ง๋ค์ด์ง๋ค.
|
|
679
|
+
* ๊ฐ์ ๊ฐ๋งน์ (`clientKey`)์ด๋ฉด ๊ทธ ์ธํธ๋ฅผ ๊ฐฑ์ ํ๊ณ , ๊ฐ๋งน์ ์ด ๋ฐ๋๋ฉด ์ ์ธํธ๋ฅผ ๋ง๋ค๊ณ ์ด์ ์ธํธ๋ ๋ณด๊ดํ๋ค
|
|
680
|
+
* (`retiredCredentialCount` +1, ์ด๋ฏธ ๋ฐ์ ๊ฒฐ์ ์ ํ๋ถยท๋์ฌ์ ๊ณ์ ์ฐ์ธ๋ค). `secretKey`ยท`webhookSecret`์ ์๋ตํ๋ฉด
|
|
681
|
+
* ํ์ฌ ์ธํธ์ ๊ฐ์ ์ด์ด๋ฐ๊ณ `webhookSecret: null`์ ์ญ์ ๋ค. ์ ์ฅํ๋ฉด ๊ทธ ์ธํธ์ `lastVerification`์ด ์ด๊ธฐํ๋๋ค.
|
|
682
|
+
*
|
|
683
|
+
* ์๋ฌ: 400 `PAYMENT_PROVIDER_INCOMPLETE`(์ํฌ๋ฆฟ ํค ์์) ยท 400 `INVALID_CREDENTIALS`(ํ์ยทํ๊ฒฝ ๋ถ์ผ์น) ยท
|
|
684
|
+
* 409 `PAYMENT_PROVIDER_VERIFICATION_FAILED`(๋ผ์ด๋ธ ์ฌ์ฉ ์ค์ธ PG์ LIVE ์ธํธ ๊ฐ๋งน์ ์ ๋ฐ๊พธ๋ ค๋๋ฐ ์ ์ฅ ์ ์ฐ๊ฒฐ ํ
์คํธ ์คํจ.
|
|
685
|
+
* ์ ์ฅ๋์ง ์๋๋ค. ๊ฐ์ ๊ฐ๋งน์ ์ ๋น๋ฐ ๊ฐ ๊ต์ฒด๋ ๊ฒ์ฌํ์ง ์๋๋ค)
|
|
686
|
+
*/
|
|
687
|
+
upsertTossPayments: (body: UpsertTossPaymentsProviderRequest) =>
|
|
688
|
+
storeHttp.request("PUT", "/store/payment-providers/tosspayments", paymentProviderSchema, {
|
|
689
|
+
body: upsertTossPaymentsProviderRequestSchema.parse(body),
|
|
690
|
+
}),
|
|
691
|
+
/**
|
|
692
|
+
* `PUT /v1/store/payment-providers/portone` โ ์๊ฒฉ ์ฆ๋ช
์ธํธ ์ ์ฅ. ๊ท์นยท์๋ฌ๋ `upsertTossPayments`์ ๊ฐ๋ค
|
|
693
|
+
* (๊ฐ๋งน์ ์๋ณ์๋ `storeId`, ๋น๋ฐ ํ๋๋ `apiSecret`ยท`webhookSecret`). 400 `INVALID_CREDENTIALS`์๋ ์ฑ๋ ํค ์ค๋ณต์ด ํฌํจ๋๋ค.
|
|
694
|
+
*/
|
|
695
|
+
upsertPortOne: (body: UpsertPortOneProviderRequest) =>
|
|
696
|
+
storeHttp.request("PUT", "/store/payment-providers/portone", paymentProviderSchema, {
|
|
697
|
+
body: upsertPortOneProviderRequestSchema.parse(body),
|
|
698
|
+
}),
|
|
699
|
+
/**
|
|
700
|
+
* `PATCH /v1/store/payment-providers/{provider}` โ ์ฌ์ฉ ์ฌ๋ถ(`enabled`)ยท์๋๋ฐ์ค ์ค์์น(`sandboxMode`) ๋ณ๊ฒฝ.
|
|
701
|
+
* ํ๋ ์ด์ ๋ณด๋ด์ผ ํ๋ค(์๋๋ฉด ์์ฒญ ์ ์ ZodError). ๊ฒ์ฆ์ ๋ชจ๋ ํต๊ณผํด์ผ ํ ๋ฒ์ ์ ์ฉ๋๋ค(๋ถ๋ถ ์ ์ฉ ์์).
|
|
702
|
+
* ๋ PG๋ก ์น์ธ๋ ๊ฒฐ์ ์ ํ๋ถ์ ๊ณ์ ๊ทธ PG๋ก ๊ฐ๋ค.
|
|
703
|
+
*
|
|
704
|
+
* ์๋ฌ
|
|
705
|
+
* - 404 `PAYMENT_PROVIDER_NOT_FOUND`: ์ฐ๊ฒฐ๋์ง ์์ PG
|
|
706
|
+
* - 409 `PAYMENT_PROVIDER_INCOMPLETE`: ์ผ๋ ค๋๋ฐ ํ์ฑ ํ๊ฒฝ(์๋๋ฐ์ค๋ฉด TEST, ์๋๋ฉด LIVE) ์ธํธ๊ฐ ์๊ฑฐ๋ ๋ถ์์
|
|
707
|
+
* - 409 `LIVE_GATE_NOT_MET`: `sandboxMode: false`(๋ผ์ด๋ธ ์ ํ)์ธ๋ฐ ๊ฐ๋ฐฉ ์กฐ๊ฑด ๋ฏธ์ถฉ์กฑ. `ApiError.details`๊ฐ
|
|
708
|
+
* `{ conditions: LiveGateCondition[] }`(์กฐ๊ฑด๋ณ `met`)์ด๋ค. `liveGateErrorDetailsSchema`๋ก ํ์ฑํ๋ค
|
|
709
|
+
* - 409 `LIVE_PAYMENTS_DISABLED`: ํ๋ซํผ ์ค๊ฒฐ์ ์ค์์น๋ง ๋ฏธ์ถฉ์กฑ. `details`๋ ์์ ๊ฐ๋ค
|
|
710
|
+
*
|
|
711
|
+
* `sandboxMode: true`๋ ํญ์ ํ์ฉ๋๊ณ ์ฆ์ ์ค๊ฒฐ์ ๊ฐ ๋ฉ์ถ๋ค.
|
|
712
|
+
*/
|
|
713
|
+
updateProvider: updatePaymentProvider,
|
|
714
|
+
/**
|
|
715
|
+
* ์๋๋ฐ์ค ์ค์์น๋ง ๋ฐ๊พผ๋ค โ `updateProvider(provider, { sandboxMode })`์ ๊ฐ๋ค.
|
|
716
|
+
* `false`(๋ผ์ด๋ธ ์ ํ)๋ 409 `LIVE_GATE_NOT_MET`ยท`LIVE_PAYMENTS_DISABLED`(๋ ๋ค `ApiError.details.conditions`)๊ฐ ๋ ์ ์๋ค.
|
|
717
|
+
*/
|
|
718
|
+
setSandboxMode: (provider: PgProvider, sandboxMode: boolean) =>
|
|
719
|
+
updatePaymentProvider(provider, { sandboxMode }),
|
|
720
|
+
/**
|
|
721
|
+
* `DELETE /v1/store/payment-providers/{provider}` (204) โ ์ฐ๊ฒฐ ํด์ . ๊ฒฐ์ ์ด๋ ฅ๊ณผ ๋ฌด๊ดํ๊ฒ ํ์ฉ๋๋ค.
|
|
722
|
+
* ๋ชจ๋ ์ธํธ๋ ๋ณด๊ด๋๊ณ PG ์ค์ ์์ ์ฌ๋ผ์ง๋ค. ์ด๋ฏธ ๋ฐ์ ๊ฒฐ์ ์ ์ทจ์ยทํ๋ถยท๋์ฌ๋ ๋ณด๊ด๋ ์๊ฒฉ ์ฆ๋ช
์ผ๋ก ๊ณ์ ์ฒ๋ฆฌ๋๋ค.
|
|
723
|
+
* 404 `PAYMENT_PROVIDER_NOT_FOUND`.
|
|
724
|
+
*/
|
|
725
|
+
disconnect: (provider: PgProvider) =>
|
|
726
|
+
storeHttp.requestVoid(
|
|
727
|
+
"DELETE",
|
|
728
|
+
path`/store/payment-providers/${pgProviderSchema.parse(provider)}`,
|
|
729
|
+
),
|
|
730
|
+
/**
|
|
731
|
+
* `DELETE /v1/store/payment-providers/{provider}/credentials/{TEST|LIVE}` (200) โ ํ์ฑ ํ๊ฒฝ์ด ์๋ ์ธํธ ํ๋๋ฅผ ๋ณด๊ด ์ฒ๋ฆฌํ๊ณ
|
|
732
|
+
* ๊ฐฑ์ ๋ `PaymentProvider`๋ฅผ ๋๋ ค์ค๋ค. ๋ณด๊ด๋ ์ธํธ๋ ๊ทธ ์ธํธ๋ก ๋ฐ์ ๊ฒฐ์ ์ ํ๋ถ์ ๊ณ์ ์ฐ์ธ๋ค.
|
|
733
|
+
*
|
|
734
|
+
* ์๋ฌ: 404 `PAYMENT_PROVIDER_NOT_FOUND`(๋ฏธ์ฐ๊ฒฐ PG) ยท 404 `PAYMENT_CREDENTIAL_NOT_FOUND`(๋ฑ๋ก๋์ง ์์ ์ธํธ) ยท
|
|
735
|
+
* 409 `PAYMENT_CREDENTIAL_ACTIVE`(์ง๊ธ ๊ฒฐ์ ์ ์ฐ๋ ์ธํธ. ๋จผ์ `setSandboxMode`๋ก ์ค์์น๋ฅผ ๋ฐ๊พผ๋ค)
|
|
736
|
+
*/
|
|
737
|
+
removeCredentialSet: (provider: PgProvider, environment: PgEnvironment) =>
|
|
738
|
+
storeHttp.request(
|
|
739
|
+
"DELETE",
|
|
740
|
+
path`/store/payment-providers/${pgProviderSchema.parse(provider)}/credentials/${pgEnvironmentSchema.parse(environment)}`,
|
|
741
|
+
paymentProviderSchema,
|
|
742
|
+
),
|
|
743
|
+
/**
|
|
744
|
+
* `POST /v1/store/payment-providers/{provider}/verify` โ ์ ์ฅ๋ ์ธํธ๋ก ์ฐ๊ฒฐ ํ
์คํธํ๊ณ ๊ฒฐ๊ณผ๋ฅผ ๊ทธ ์ธํธ์ ์ ์ฅํ๋ค.
|
|
745
|
+
* `environment`๋ฅผ ์๋ตํ๋ฉด ํ์ฑ ํ๊ฒฝ ์ธํธ๋ฅผ ํ
์คํธํ๋ค. ์คํจํด๋ 200์ด๊ณ `result: "FAILED"`์ `message`์ ์ฌ์ ๊ฐ ์จ๋ค.
|
|
746
|
+
* ๋ผ์ด๋ธ ๊ฐ๋ฐฉ ์กฐ๊ฑด `TEST_CONNECTION`ยท`LIVE_CONNECTION`์ ์ด ๊ฒฐ๊ณผ๋ก ํ์ ํ๋ค. 404 `PAYMENT_PROVIDER_NOT_FOUND`.
|
|
747
|
+
*/
|
|
748
|
+
verify: (provider: PgProvider, body?: VerifyPaymentProviderRequest) =>
|
|
749
|
+
storeHttp.request(
|
|
750
|
+
"POST",
|
|
751
|
+
path`/store/payment-providers/${pgProviderSchema.parse(provider)}/verify`,
|
|
752
|
+
paymentProviderVerificationSchema,
|
|
753
|
+
{ body: verifyPaymentProviderRequestSchema.parse(body ?? {}) },
|
|
754
|
+
),
|
|
755
|
+
},
|
|
756
|
+
|
|
757
|
+
webhooks: {
|
|
758
|
+
list: () => storeHttp.request("GET", "/webhooks", z.array(webhookSchema)),
|
|
759
|
+
/** ์๋ช
์ํฌ๋ฆฟ ํ๋ฌธ์ ์ด ์๋ต์์๋ง ๋
ธ์ถ๋๋ค */
|
|
760
|
+
create: (body: WebhookRequest) =>
|
|
761
|
+
storeHttp.request("POST", "/webhooks", webhookCreatedSchema, {
|
|
762
|
+
body: webhookRequestSchema.parse(body),
|
|
763
|
+
}),
|
|
764
|
+
get: (webhookId: string) =>
|
|
765
|
+
storeHttp.request("GET", path`/webhooks/${webhookId}`, webhookSchema),
|
|
766
|
+
/** SUSPENDED ๊ตฌ๋
์ ์์ ํ๋ฉด ACTIVE๋ก ๋์๊ฐ๋ค. ์์ ๋ ๊ตฌ๋
์ ๋๋ ค์ค๋ค */
|
|
767
|
+
update: (webhookId: string, body: WebhookRequest) =>
|
|
768
|
+
storeHttp.request("PUT", path`/webhooks/${webhookId}`, webhookSchema, {
|
|
769
|
+
body: webhookRequestSchema.parse(body),
|
|
770
|
+
}),
|
|
771
|
+
remove: (webhookId: string) => storeHttp.requestVoid("DELETE", path`/webhooks/${webhookId}`),
|
|
772
|
+
rotateSecret: (webhookId: string) =>
|
|
773
|
+
storeHttp.request(
|
|
774
|
+
"POST",
|
|
775
|
+
path`/webhooks/${webhookId}/rotate-secret`,
|
|
776
|
+
webhookSecretRotatedSchema,
|
|
777
|
+
),
|
|
778
|
+
/** SUSPENDED ๊ตฌ๋
์ ACTIVE๋ก ์ฌ๊ฐํ๊ณ ์ฐ์ ์คํจ ๊ธฐ๋ก์ ์ด๊ธฐํํ๋ค. ์ด๋ฏธ ACTIVE๋ฉด ๊ทธ๋๋ก ๋๋ ค์ค๋ค(๋ฉฑ๋ฑ) */
|
|
779
|
+
resume: (webhookId: string) =>
|
|
780
|
+
storeHttp.request("POST", path`/webhooks/${webhookId}/resume`, webhookSchema),
|
|
781
|
+
/** ์ ์ก ๊ธฐ๋ก (์ต์ ์ ์ฌ์, ๊ธฐ๋ณธ 50๊ฑดยท์ต๋ 100๊ฑด, ๋ณด๊ด 30์ผ) */
|
|
782
|
+
listDeliveries: (webhookId: string, params?: WebhookDeliveryListParams) =>
|
|
783
|
+
storeHttp.request(
|
|
784
|
+
"GET",
|
|
785
|
+
path`/webhooks/${webhookId}/deliveries`,
|
|
786
|
+
z.array(webhookDeliverySchema),
|
|
787
|
+
{ query: params as Query },
|
|
788
|
+
),
|
|
789
|
+
/**
|
|
790
|
+
* FAILED ์ ์ก ๊ธฐ๋ก ํ ๊ฑด์ ๊ฐ์ eventId๋ก ๋ค์ ๋ณด๋ธ๋ค(202). ์๋ก ์ ์ฌ๋ ๊ธฐ๋ก์ ๋๋ ค์ฃผ๋ฉฐ
|
|
791
|
+
* `redeliveryOf`๊ฐ ์๋ณธ deliveryId๋ค. ์๋ณธ์ด FAILED๊ฐ ์๋๋ฉด 409 `DELIVERY_NOT_FAILED`,
|
|
792
|
+
* ์๋ณธ์ด ์ด๋ฏธ ์ฌ์ ์ก๋์ผ๋ฉด 409 `DELIVERY_ALREADY_REDELIVERED`(์๋ณธ๋น 1ํ, ์๋ณธ์ `redeliveredAs` ์ฐธ๊ณ ),
|
|
793
|
+
* ๊ตฌ๋
์ด SUSPENDED๋ฉด 409 `WEBHOOK_SUSPENDED`.
|
|
794
|
+
*/
|
|
795
|
+
redeliver: (webhookId: string, deliveryId: string) =>
|
|
796
|
+
storeHttp.request(
|
|
797
|
+
"POST",
|
|
798
|
+
path`/webhooks/${webhookId}/deliveries/${deliveryId}/redeliver`,
|
|
799
|
+
webhookDeliverySchema,
|
|
800
|
+
),
|
|
801
|
+
/**
|
|
802
|
+
* ์ต๊ทผ 72์๊ฐ์ FAILED ์ค ์์ง ์ฌ์ ์ก๋์ง ์์ ๊ฑด ์ ์ฒด(์ต๋ 500๊ฑด)๋ฅผ ๋ค์ ๋ณด๋ธ๋ค(202).
|
|
803
|
+
* ๊ตฌ๋
์ด SUSPENDED๋ฉด 409 `WEBHOOK_SUSPENDED` โ ๋จผ์ `resume`ํ๋ค.
|
|
804
|
+
*/
|
|
805
|
+
redeliverFailed: (webhookId: string) =>
|
|
806
|
+
storeHttp.request(
|
|
807
|
+
"POST",
|
|
808
|
+
path`/webhooks/${webhookId}/deliveries/redeliver-failed`,
|
|
809
|
+
webhookRedeliverFailedResultSchema,
|
|
810
|
+
),
|
|
811
|
+
/**
|
|
812
|
+
* ์ง์ ํ ์ด๋ฒคํธ ํ์
์ ์ํ ํ์ด๋ก๋(์ด๋ฒคํธ id `evt_test_โฆ`)๋ฅผ ์ค์ ๋ก ๋ณด๋ด๊ณ ์์ ์๋ฒ ์๋ต์
|
|
813
|
+
* ๋๊ธฐ๋ก ๋๋ ค์ค๋ค. ์ฌ์๋ยท์ ์ง ํ์ ยท์ ์ก ๊ธฐ๋ก์ด ์๋ค.
|
|
814
|
+
*/
|
|
815
|
+
sendTest: (webhookId: string, body: WebhookTestRequest) =>
|
|
816
|
+
storeHttp.request("POST", path`/webhooks/${webhookId}/test`, webhookTestResultSchema, {
|
|
817
|
+
body: webhookTestRequestSchema.parse(body),
|
|
818
|
+
}),
|
|
819
|
+
},
|
|
820
|
+
|
|
821
|
+
/** API ๋ก๊ทธ (๋ณด๊ด 7์ผ, ์ฝ์ OWNER/ADMIN) */
|
|
822
|
+
apiLogs: {
|
|
823
|
+
/** ์ต์ ์ ์ปค์ ํ์ด์ง๋ค์ด์
. ๋ค์ ํ์ด์ง๋ ์๋ต์ `nextCursor`๋ฅผ `cursor`๋ก ๋๊ธด๋ค */
|
|
824
|
+
list: (params?: ApiLogListOptions) =>
|
|
825
|
+
storeHttp.request("GET", "/api-logs", apiLogPageSchema, {
|
|
826
|
+
query: params && {
|
|
827
|
+
...params,
|
|
828
|
+
principalType: Array.isArray(params.principalType)
|
|
829
|
+
? params.principalType.join(",") || undefined
|
|
830
|
+
: params.principalType,
|
|
831
|
+
},
|
|
832
|
+
}),
|
|
833
|
+
/** ์ต๊ทผ 24์๊ฐ ์์ฒญ ์ยท์๋ฌ ์ */
|
|
834
|
+
summary: () => storeHttp.request("GET", "/api-logs/summary", apiLogSummarySchema),
|
|
835
|
+
},
|
|
836
|
+
|
|
837
|
+
reviews: {
|
|
838
|
+
list: (params?: ReviewListParams) =>
|
|
839
|
+
storeHttp.request("GET", "/reviews", pageSchema(reviewSchema), { query: params as Query }),
|
|
840
|
+
get: (reviewId: string) => storeHttp.request("GET", path`/reviews/${reviewId}`, reviewSchema),
|
|
841
|
+
createReply: (reviewId: string, content: string) =>
|
|
842
|
+
storeHttp.requestVoid("POST", path`/reviews/${reviewId}/reply`, { body: { content } }),
|
|
843
|
+
updateReply: (reviewId: string, content: string) =>
|
|
844
|
+
storeHttp.requestVoid("PUT", path`/reviews/${reviewId}/reply`, { body: { content } }),
|
|
845
|
+
deleteReply: (reviewId: string) =>
|
|
846
|
+
storeHttp.requestVoid("DELETE", path`/reviews/${reviewId}/reply`),
|
|
847
|
+
},
|
|
848
|
+
|
|
849
|
+
sellerAddresses: {
|
|
850
|
+
list: (type?: AddressType) =>
|
|
851
|
+
storeHttp.request("GET", "/seller-addresses", z.array(sellerAddressSchema), {
|
|
852
|
+
query: { type },
|
|
853
|
+
}),
|
|
854
|
+
create: (body: SellerAddressRequest) =>
|
|
855
|
+
storeHttp.requestVoid("POST", "/seller-addresses", {
|
|
856
|
+
body: sellerAddressRequestSchema.parse(body),
|
|
857
|
+
}),
|
|
858
|
+
update: (addressId: string, body: SellerAddressRequest) =>
|
|
859
|
+
storeHttp.requestVoid("PUT", path`/seller-addresses/${addressId}`, {
|
|
860
|
+
body: sellerAddressRequestSchema.parse(body),
|
|
861
|
+
}),
|
|
862
|
+
remove: (addressId: string) =>
|
|
863
|
+
storeHttp.requestVoid("DELETE", path`/seller-addresses/${addressId}`),
|
|
864
|
+
setDefault: (addressId: string) =>
|
|
865
|
+
storeHttp.requestVoid("POST", path`/seller-addresses/${addressId}/default`),
|
|
866
|
+
},
|
|
867
|
+
|
|
868
|
+
store: {
|
|
869
|
+
get: () => storeHttp.request("GET", "/store", storeSchema),
|
|
870
|
+
listMembers: () => storeHttp.request("GET", "/store/members", z.array(storeMemberSchema)),
|
|
871
|
+
listInvitations: () =>
|
|
872
|
+
storeHttp.request("GET", "/store/invitations", z.array(invitationSchema)),
|
|
873
|
+
},
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export type StoreClient = ReturnType<typeof createStoreClient>;
|