-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from kimver/master
add typescript support
- Loading branch information
Showing
5 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
language: node_js | ||
node_js: | ||
- '4.2.2' | ||
- 'v6.17.0' | ||
|
||
before_script: | ||
- npm install | ||
|
||
script: "npm test" | ||
|
||
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
interface ApiOption { | ||
host?: string; | ||
protocol?: string; | ||
getRequestCount?: (token: string) => any; | ||
saveRequestCount?: (token: string) => void; | ||
} | ||
|
||
interface AuthOption { | ||
appKey: string; | ||
appSecret: string; | ||
callbackUrl?: string; | ||
redirectUrl?: string; | ||
scope?: string[]; | ||
private?: boolean; | ||
} | ||
|
||
declare module 'yhsd-api' { | ||
class Auth { | ||
constructor(options: AuthOption); | ||
|
||
// 验证 Hmac | ||
verifyHmac(queryObj: object): boolean; | ||
|
||
// 获取应用授权页面地址,用于开放应用 | ||
getAuthorizeUrl(shopKey: string, state: string): string; | ||
|
||
// 获取 token | ||
getToken(code?: string): Promise<string>; | ||
} | ||
|
||
class Api { | ||
|
||
constructor(token: string, option?: ApiOption); | ||
|
||
// 发送 GET 请求 | ||
get(path: string, query?: object): Promise<any>; | ||
|
||
// 发送 PUT 请求 | ||
put(path: string, data?: object): Promise<any>; | ||
|
||
// 发送 POST 请求 | ||
post(path: string, data?: object): Promise<any>; | ||
|
||
// 发送 DELETE 请求 | ||
delete(path: string): Promise<any>; | ||
|
||
// 请求函数 | ||
request(method: string, path: string, params?: object): Promise<any> | ||
} | ||
|
||
class WebHook { | ||
constructor(webHookToken: string); | ||
|
||
// 验证WebHook Hmac | ||
verifyHmac(hmac: string, bodyData: string): boolean; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters