Skip to content

Commit

Permalink
feat: add create order type & shipping method type
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjue666 committed Dec 8, 2023
1 parent 6977409 commit 6652761
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-ducks-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cn-international-express-sdk/wanb': major
---

feat: add create order type & shipping method type
4 changes: 2 additions & 2 deletions packages/wanb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cn-international-express-sdk/wanb",
"version": "0.1.0",
"version": "0.1.5",
"types": "./dist/types/index.d.ts",
"main": "./dist/lib/index.js",
"module": "./dist/es/index.js",
Expand Down Expand Up @@ -33,4 +33,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
14 changes: 5 additions & 9 deletions packages/wanb/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import {
postJSONRequest,
myRequest,
} from '@cn-international-express-sdk/utils';
import { WanbConfig } from './state';

export * from './state';

export interface WanbConfig {
app_token: string;
user_id: string;
base_url?: string;
}
export class Wanb {
public config: WanbConfig;

Expand All @@ -28,17 +26,15 @@ export class Wanb {
};
console.log(url, headers);
if (method === 'POST') {
const res = await postJSONRequest<T>(url, sendData || {}, {
headers,
});
const res = await postJSONRequest<T>(url, sendData || {}, headers);
return res as T;
} else {
const res = await myRequest<string>({
method: 'get',
url,
headers,
});
return JSON.parse(res) as T;
return JSON.parse(res).Data as T;
}
}

Expand Down
37 changes: 37 additions & 0 deletions packages/wanb/src/state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export interface WanbConfig {
app_token: string;
user_id: string;
base_url?: string;
}

export interface GetShippingMethodsRes {
ShippingMethods: {
Code: string;
Name: string;
IsTracking: boolean;
IsVolumeWeight: boolean;
MaxVolumeWeightInCm: number;
Region: string;
}[];
}

export type AddOrderRes =
| {
Succeeded: false;
Error: {
Message: string;
};
}
| {
Succeeded: true;
Data: {
ProcessCode: string;
IndexNumber: string;
ReferenceId: string;
TrackingNumber: string;
IsVirtualTrackingNumber: boolean;
SortCode: string;
IsRemoteArea: boolean;
Status: string;
};
};

0 comments on commit 6652761

Please sign in to comment.