deliveryapi 0.1.1 → 0.1.3

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.cjs CHANGED
@@ -44,6 +44,9 @@ var HttpClient = class {
44
44
  async post(path, body) {
45
45
  return this.request("POST", `${this.baseUrl}${path}`, body);
46
46
  }
47
+ async put(path, body) {
48
+ return this.request("PUT", `${this.baseUrl}${path}`, body);
49
+ }
47
50
  async patch(path, body) {
48
51
  return this.request("PATCH", `${this.baseUrl}${path}`, body);
49
52
  }
@@ -107,11 +110,19 @@ var SubscriptionsResource = class {
107
110
  this.http = http;
108
111
  }
109
112
  /**
110
- * 택배 구독 생성
113
+ * 택배 구독 생성 (단건)
111
114
  * 상태 변경 시 등록된 웹훅 엔드포인트로 알림 전송
112
115
  */
113
116
  async create(data) {
114
- return this.http.post("/v1/tracking/subscriptions", data);
117
+ return this.http.post("/v1/tracking/subscriptions", {
118
+ items: [data]
119
+ });
120
+ }
121
+ /**
122
+ * 택배 구독 일괄 생성 (최대 100건)
123
+ */
124
+ async createBatch(items) {
125
+ return this.http.post("/v1/tracking/subscriptions", { items });
115
126
  }
116
127
  /**
117
128
  * 택배 구독 목록 조회
@@ -119,8 +130,8 @@ var SubscriptionsResource = class {
119
130
  async list(options) {
120
131
  const params = {};
121
132
  if (options?.status) params["status"] = options.status;
122
- if (options?.page) params["page"] = String(options.page);
123
- if (options?.pageSize) params["pageSize"] = String(options.pageSize);
133
+ if (options?.limit) params["limit"] = String(options.limit);
134
+ if (options?.cursor) params["cursor"] = options.cursor;
124
135
  return this.http.get("/v1/tracking/subscriptions", params);
125
136
  }
126
137
  /**
@@ -130,11 +141,19 @@ var SubscriptionsResource = class {
130
141
  return this.http.get(`/v1/tracking/subscriptions/${subscriptionId}`);
131
142
  }
132
143
  /**
133
- * 택배 구독 취소
144
+ * 택배 구독 취소 (ID)
134
145
  */
135
146
  async cancel(subscriptionId) {
136
147
  await this.http.delete(`/v1/tracking/subscriptions/${subscriptionId}`);
137
148
  }
149
+ /**
150
+ * 택배 구독 취소 (송장번호)
151
+ */
152
+ async cancelByTracking(courierCode, trackingNumber) {
153
+ return this.http.delete(
154
+ `/v1/tracking/subscriptions?courierCode=${encodeURIComponent(courierCode)}&trackingNumber=${encodeURIComponent(trackingNumber)}`
155
+ );
156
+ }
138
157
  };
139
158
 
140
159
  // src/resources/webhooks.ts
@@ -155,10 +174,10 @@ var WebhooksResource = class {
155
174
  return this.http.get("/v1/webhook-v2/endpoints");
156
175
  }
157
176
  /**
158
- * 웹훅 엔드포인트 상세 조회
177
+ * 웹훅 엔드포인트 이름 수정
159
178
  */
160
- async retrieve(endpointId) {
161
- return this.http.get(`/v1/webhook-v2/endpoints/${endpointId}`);
179
+ async update(endpointId, data) {
180
+ await this.http.put(`/v1/webhook-v2/endpoints/${endpointId}`, data);
162
181
  }
163
182
  /**
164
183
  * 웹훅 엔드포인트 삭제
@@ -167,10 +186,13 @@ var WebhooksResource = class {
167
186
  await this.http.delete(`/v1/webhook-v2/endpoints/${endpointId}`);
168
187
  }
169
188
  /**
170
- * 웹훅 엔드포인트 테스트 전송
189
+ * 웹훅 시크릿 재발급
171
190
  */
172
- async test(endpointId) {
173
- return this.http.post(`/v1/webhook-v2/endpoints/${endpointId}/test`);
191
+ async rotateSecret(endpointId, webhookSecret) {
192
+ return this.http.post(
193
+ `/v1/webhook-v2/endpoints/${endpointId}/rotate`,
194
+ webhookSecret ? { webhookSecret } : void 0
195
+ );
174
196
  }
175
197
  };
176
198
 
package/dist/index.d.cts CHANGED
@@ -6,6 +6,7 @@ declare class HttpClient {
6
6
  constructor(apiKey: string, secretKey: string, baseUrl: string);
7
7
  get<T>(path: string, params?: Record<string, string>): Promise<T>;
8
8
  post<T>(path: string, body?: unknown): Promise<T>;
9
+ put<T>(path: string, body?: unknown): Promise<T>;
9
10
  patch<T>(path: string, body?: unknown): Promise<T>;
10
11
  delete<T>(path: string): Promise<T>;
11
12
  private request;
@@ -268,25 +269,55 @@ export interface SubscriptionCreateInput {
268
269
  trackingNumber: string;
269
270
  endpointId: string;
270
271
  subscribedStatuses?: CourierDeliveryStatus[];
271
- clientId?: string;
272
+ id?: string;
272
273
  metadata?: Record<string, string>;
273
274
  }
275
+ export interface SubscriptionCreateResult {
276
+ id?: string;
277
+ courierCode: string;
278
+ trackingNumber: string;
279
+ subscriptionId?: string;
280
+ success: boolean;
281
+ currentStatus?: CourierDeliveryStatus;
282
+ error?: string;
283
+ }
284
+ export interface SubscriptionCreateBatchResult {
285
+ results: SubscriptionCreateResult[];
286
+ summary: {
287
+ total: number;
288
+ successful: number;
289
+ failed: number;
290
+ };
291
+ }
274
292
  export interface SubscriptionListResult {
275
- subscriptions: TrackingSubscription[];
293
+ subscriptions: {
294
+ id: string;
295
+ courierCode: string;
296
+ trackingNumber: string;
297
+ endpointId: string;
298
+ subscribedStatuses: CourierDeliveryStatus[];
299
+ currentStatus: CourierDeliveryStatus;
300
+ status: "active" | "completed" | "cancelled" | "failed";
301
+ metadata?: Record<string, string>;
302
+ dateCreated: string;
303
+ dateModified: string;
304
+ }[];
276
305
  total: number;
306
+ nextCursor?: string;
277
307
  }
278
308
  export interface WebhookCreateInput {
279
309
  url: string;
280
310
  name?: string;
281
311
  }
312
+ export interface WebhookUpdateInput {
313
+ name: string;
314
+ }
282
315
  export interface WebhookListResult {
283
316
  endpoints: WebhookEndpoint[];
284
317
  total: number;
285
318
  }
286
- export interface WebhookTestResult {
287
- success: boolean;
288
- statusCode?: number;
289
- message?: string;
319
+ export interface WebhookRotateSecretResult {
320
+ webhookSecret: string;
290
321
  }
291
322
  export interface CourierListResult {
292
323
  couriers: CourierInfo[];
@@ -312,26 +343,36 @@ declare class SubscriptionsResource {
312
343
  private readonly http;
313
344
  constructor(http: HttpClient);
314
345
  /**
315
- * 택배 구독 생성
346
+ * 택배 구독 생성 (단건)
316
347
  * 상태 변경 시 등록된 웹훅 엔드포인트로 알림 전송
317
348
  */
318
- create(data: SubscriptionCreateInput): Promise<TrackingSubscription>;
349
+ create(data: SubscriptionCreateInput): Promise<SubscriptionCreateBatchResult>;
350
+ /**
351
+ * 택배 구독 일괄 생성 (최대 100건)
352
+ */
353
+ createBatch(items: SubscriptionCreateInput[]): Promise<SubscriptionCreateBatchResult>;
319
354
  /**
320
355
  * 택배 구독 목록 조회
321
356
  */
322
357
  list(options?: {
323
- status?: string;
324
- page?: number;
325
- pageSize?: number;
358
+ status?: "active" | "completed" | "cancelled" | "failed";
359
+ limit?: number;
360
+ cursor?: string;
326
361
  }): Promise<SubscriptionListResult>;
327
362
  /**
328
363
  * 택배 구독 상세 조회
329
364
  */
330
- retrieve(subscriptionId: string): Promise<TrackingSubscription>;
365
+ retrieve(subscriptionId: string): Promise<SubscriptionListResult["subscriptions"][number]>;
331
366
  /**
332
- * 택배 구독 취소
367
+ * 택배 구독 취소 (ID)
333
368
  */
334
369
  cancel(subscriptionId: string): Promise<void>;
370
+ /**
371
+ * 택배 구독 취소 (송장번호)
372
+ */
373
+ cancelByTracking(courierCode: string, trackingNumber: string): Promise<{
374
+ cancelledCount: number;
375
+ }>;
335
376
  }
336
377
  declare class WebhooksResource {
337
378
  private readonly http;
@@ -345,17 +386,17 @@ declare class WebhooksResource {
345
386
  */
346
387
  list(): Promise<WebhookListResult>;
347
388
  /**
348
- * 웹훅 엔드포인트 상세 조회
389
+ * 웹훅 엔드포인트 이름 수정
349
390
  */
350
- retrieve(endpointId: string): Promise<WebhookEndpoint>;
391
+ update(endpointId: string, data: WebhookUpdateInput): Promise<void>;
351
392
  /**
352
393
  * 웹훅 엔드포인트 삭제
353
394
  */
354
395
  delete(endpointId: string): Promise<void>;
355
396
  /**
356
- * 웹훅 엔드포인트 테스트 전송
397
+ * 웹훅 시크릿 재발급
357
398
  */
358
- test(endpointId: string): Promise<WebhookTestResult>;
399
+ rotateSecret(endpointId: string, webhookSecret?: string): Promise<WebhookRotateSecretResult>;
359
400
  }
360
401
  declare class CouriersResource {
361
402
  private readonly http;
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ declare class HttpClient {
6
6
  constructor(apiKey: string, secretKey: string, baseUrl: string);
7
7
  get<T>(path: string, params?: Record<string, string>): Promise<T>;
8
8
  post<T>(path: string, body?: unknown): Promise<T>;
9
+ put<T>(path: string, body?: unknown): Promise<T>;
9
10
  patch<T>(path: string, body?: unknown): Promise<T>;
10
11
  delete<T>(path: string): Promise<T>;
11
12
  private request;
@@ -268,25 +269,55 @@ export interface SubscriptionCreateInput {
268
269
  trackingNumber: string;
269
270
  endpointId: string;
270
271
  subscribedStatuses?: CourierDeliveryStatus[];
271
- clientId?: string;
272
+ id?: string;
272
273
  metadata?: Record<string, string>;
273
274
  }
275
+ export interface SubscriptionCreateResult {
276
+ id?: string;
277
+ courierCode: string;
278
+ trackingNumber: string;
279
+ subscriptionId?: string;
280
+ success: boolean;
281
+ currentStatus?: CourierDeliveryStatus;
282
+ error?: string;
283
+ }
284
+ export interface SubscriptionCreateBatchResult {
285
+ results: SubscriptionCreateResult[];
286
+ summary: {
287
+ total: number;
288
+ successful: number;
289
+ failed: number;
290
+ };
291
+ }
274
292
  export interface SubscriptionListResult {
275
- subscriptions: TrackingSubscription[];
293
+ subscriptions: {
294
+ id: string;
295
+ courierCode: string;
296
+ trackingNumber: string;
297
+ endpointId: string;
298
+ subscribedStatuses: CourierDeliveryStatus[];
299
+ currentStatus: CourierDeliveryStatus;
300
+ status: "active" | "completed" | "cancelled" | "failed";
301
+ metadata?: Record<string, string>;
302
+ dateCreated: string;
303
+ dateModified: string;
304
+ }[];
276
305
  total: number;
306
+ nextCursor?: string;
277
307
  }
278
308
  export interface WebhookCreateInput {
279
309
  url: string;
280
310
  name?: string;
281
311
  }
312
+ export interface WebhookUpdateInput {
313
+ name: string;
314
+ }
282
315
  export interface WebhookListResult {
283
316
  endpoints: WebhookEndpoint[];
284
317
  total: number;
285
318
  }
286
- export interface WebhookTestResult {
287
- success: boolean;
288
- statusCode?: number;
289
- message?: string;
319
+ export interface WebhookRotateSecretResult {
320
+ webhookSecret: string;
290
321
  }
291
322
  export interface CourierListResult {
292
323
  couriers: CourierInfo[];
@@ -312,26 +343,36 @@ declare class SubscriptionsResource {
312
343
  private readonly http;
313
344
  constructor(http: HttpClient);
314
345
  /**
315
- * 택배 구독 생성
346
+ * 택배 구독 생성 (단건)
316
347
  * 상태 변경 시 등록된 웹훅 엔드포인트로 알림 전송
317
348
  */
318
- create(data: SubscriptionCreateInput): Promise<TrackingSubscription>;
349
+ create(data: SubscriptionCreateInput): Promise<SubscriptionCreateBatchResult>;
350
+ /**
351
+ * 택배 구독 일괄 생성 (최대 100건)
352
+ */
353
+ createBatch(items: SubscriptionCreateInput[]): Promise<SubscriptionCreateBatchResult>;
319
354
  /**
320
355
  * 택배 구독 목록 조회
321
356
  */
322
357
  list(options?: {
323
- status?: string;
324
- page?: number;
325
- pageSize?: number;
358
+ status?: "active" | "completed" | "cancelled" | "failed";
359
+ limit?: number;
360
+ cursor?: string;
326
361
  }): Promise<SubscriptionListResult>;
327
362
  /**
328
363
  * 택배 구독 상세 조회
329
364
  */
330
- retrieve(subscriptionId: string): Promise<TrackingSubscription>;
365
+ retrieve(subscriptionId: string): Promise<SubscriptionListResult["subscriptions"][number]>;
331
366
  /**
332
- * 택배 구독 취소
367
+ * 택배 구독 취소 (ID)
333
368
  */
334
369
  cancel(subscriptionId: string): Promise<void>;
370
+ /**
371
+ * 택배 구독 취소 (송장번호)
372
+ */
373
+ cancelByTracking(courierCode: string, trackingNumber: string): Promise<{
374
+ cancelledCount: number;
375
+ }>;
335
376
  }
336
377
  declare class WebhooksResource {
337
378
  private readonly http;
@@ -345,17 +386,17 @@ declare class WebhooksResource {
345
386
  */
346
387
  list(): Promise<WebhookListResult>;
347
388
  /**
348
- * 웹훅 엔드포인트 상세 조회
389
+ * 웹훅 엔드포인트 이름 수정
349
390
  */
350
- retrieve(endpointId: string): Promise<WebhookEndpoint>;
391
+ update(endpointId: string, data: WebhookUpdateInput): Promise<void>;
351
392
  /**
352
393
  * 웹훅 엔드포인트 삭제
353
394
  */
354
395
  delete(endpointId: string): Promise<void>;
355
396
  /**
356
- * 웹훅 엔드포인트 테스트 전송
397
+ * 웹훅 시크릿 재발급
357
398
  */
358
- test(endpointId: string): Promise<WebhookTestResult>;
399
+ rotateSecret(endpointId: string, webhookSecret?: string): Promise<WebhookRotateSecretResult>;
359
400
  }
360
401
  declare class CouriersResource {
361
402
  private readonly http;
package/dist/index.js CHANGED
@@ -42,6 +42,9 @@ var HttpClient = class {
42
42
  async post(path, body) {
43
43
  return this.request("POST", `${this.baseUrl}${path}`, body);
44
44
  }
45
+ async put(path, body) {
46
+ return this.request("PUT", `${this.baseUrl}${path}`, body);
47
+ }
45
48
  async patch(path, body) {
46
49
  return this.request("PATCH", `${this.baseUrl}${path}`, body);
47
50
  }
@@ -105,11 +108,19 @@ var SubscriptionsResource = class {
105
108
  this.http = http;
106
109
  }
107
110
  /**
108
- * 택배 구독 생성
111
+ * 택배 구독 생성 (단건)
109
112
  * 상태 변경 시 등록된 웹훅 엔드포인트로 알림 전송
110
113
  */
111
114
  async create(data) {
112
- return this.http.post("/v1/tracking/subscriptions", data);
115
+ return this.http.post("/v1/tracking/subscriptions", {
116
+ items: [data]
117
+ });
118
+ }
119
+ /**
120
+ * 택배 구독 일괄 생성 (최대 100건)
121
+ */
122
+ async createBatch(items) {
123
+ return this.http.post("/v1/tracking/subscriptions", { items });
113
124
  }
114
125
  /**
115
126
  * 택배 구독 목록 조회
@@ -117,8 +128,8 @@ var SubscriptionsResource = class {
117
128
  async list(options) {
118
129
  const params = {};
119
130
  if (options?.status) params["status"] = options.status;
120
- if (options?.page) params["page"] = String(options.page);
121
- if (options?.pageSize) params["pageSize"] = String(options.pageSize);
131
+ if (options?.limit) params["limit"] = String(options.limit);
132
+ if (options?.cursor) params["cursor"] = options.cursor;
122
133
  return this.http.get("/v1/tracking/subscriptions", params);
123
134
  }
124
135
  /**
@@ -128,11 +139,19 @@ var SubscriptionsResource = class {
128
139
  return this.http.get(`/v1/tracking/subscriptions/${subscriptionId}`);
129
140
  }
130
141
  /**
131
- * 택배 구독 취소
142
+ * 택배 구독 취소 (ID)
132
143
  */
133
144
  async cancel(subscriptionId) {
134
145
  await this.http.delete(`/v1/tracking/subscriptions/${subscriptionId}`);
135
146
  }
147
+ /**
148
+ * 택배 구독 취소 (송장번호)
149
+ */
150
+ async cancelByTracking(courierCode, trackingNumber) {
151
+ return this.http.delete(
152
+ `/v1/tracking/subscriptions?courierCode=${encodeURIComponent(courierCode)}&trackingNumber=${encodeURIComponent(trackingNumber)}`
153
+ );
154
+ }
136
155
  };
137
156
 
138
157
  // src/resources/webhooks.ts
@@ -153,10 +172,10 @@ var WebhooksResource = class {
153
172
  return this.http.get("/v1/webhook-v2/endpoints");
154
173
  }
155
174
  /**
156
- * 웹훅 엔드포인트 상세 조회
175
+ * 웹훅 엔드포인트 이름 수정
157
176
  */
158
- async retrieve(endpointId) {
159
- return this.http.get(`/v1/webhook-v2/endpoints/${endpointId}`);
177
+ async update(endpointId, data) {
178
+ await this.http.put(`/v1/webhook-v2/endpoints/${endpointId}`, data);
160
179
  }
161
180
  /**
162
181
  * 웹훅 엔드포인트 삭제
@@ -165,10 +184,13 @@ var WebhooksResource = class {
165
184
  await this.http.delete(`/v1/webhook-v2/endpoints/${endpointId}`);
166
185
  }
167
186
  /**
168
- * 웹훅 엔드포인트 테스트 전송
187
+ * 웹훅 시크릿 재발급
169
188
  */
170
- async test(endpointId) {
171
- return this.http.post(`/v1/webhook-v2/endpoints/${endpointId}/test`);
189
+ async rotateSecret(endpointId, webhookSecret) {
190
+ return this.http.post(
191
+ `/v1/webhook-v2/endpoints/${endpointId}/rotate`,
192
+ webhookSecret ? { webhookSecret } : void 0
193
+ );
172
194
  }
173
195
  };
174
196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deliveryapi",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Official JavaScript/TypeScript SDK for the DeliveryAPI",
5
5
  "keywords": [
6
6
  "delivery",