Skip to content

Commit 2818ad9

Browse files
🤖 Merge PR DefinitelyTyped#72729 [@vimeo/vimeo] Add Promise API by @MysteryBlokHed
1 parent 1193ca1 commit 2818ad9

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

types/vimeo__vimeo/index.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export type CompleteCallback = (err: Error | null, result: any, statusCode?: number, headers?: object) => void;
2+
export interface CompleteCallbackObject {
3+
statusCode?: number | undefined;
4+
body: any;
5+
headers?: object | undefined;
6+
}
27

38
export type ProgressCallback = (bytesUploaded: number, bytesTotal: number) => void;
49
export type ErrorCallback = (err: string) => void;
@@ -49,6 +54,7 @@ export class Vimeo {
4954
* `host`, `port`, `query` or `headers`.
5055
* @param callback Called when complete, `function (err, json)`.
5156
*/
57+
request(url: string | RequestOptions): Promise<CompleteCallbackObject>;
5258
request(url: string | RequestOptions, callback: CompleteCallback): void;
5359

5460
/**
@@ -66,6 +72,7 @@ export class Vimeo {
6672
* and configured in your API app settings.
6773
* @param fn Callback to execute on completion.
6874
*/
75+
accessToken(code: string, redirectUri: string): Promise<CompleteCallbackObject>;
6976
accessToken(code: string, redirectUri: string, fn: CompleteCallback): void;
7077

7178
/**
@@ -96,6 +103,7 @@ export class Vimeo {
96103
* occured the first parameter will be that error, otherwise the first
97104
* parameter will be null.
98105
*/
106+
generateClientCredentials(scope: string | string[]): Promise<CompleteCallbackObject>;
99107
generateClientCredentials(scope: string | string[], fn: CompleteCallback): void;
100108

101109
/**
@@ -114,6 +122,7 @@ export class Vimeo {
114122
* @param progressCallback Callback to be executed when upload progress is updated.
115123
* @param errorCallback Callback to be executed when the upload returns an error.
116124
*/
125+
upload(file: string | File, params: object): Promise<string>;
117126
upload(
118127
file: string | File,
119128
params: object,
@@ -142,6 +151,18 @@ export class Vimeo {
142151
* @param progressCallback Callback to be executed when upload progress is updated.
143152
* @param errorCallback Callback to be executed when the upload returns an error.
144153
*/
154+
replace(
155+
file: string | File,
156+
videoUri: string,
157+
params: object,
158+
): Promise<string>;
159+
replace(
160+
file: string | File,
161+
videoUri: string,
162+
completeCallback: UriCallback,
163+
progressCallback: ProgressCallback | undefined,
164+
errorCallback: ErrorCallback,
165+
): void;
145166
replace(
146167
file: string | File,
147168
videoUri: string,

types/vimeo__vimeo/vimeo__vimeo-tests.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,23 @@ clientWithoutAccessToken.buildAuthorizationEndpoint("", "", "");
7171

7272
// $ExpectType void
7373
clientWithoutAccessToken.buildAuthorizationEndpoint("", [""], "");
74+
75+
// Promise API
76+
77+
// $ExpectType Promise<string>
78+
client.upload("", {});
79+
80+
// $ExpectType Promise<string>
81+
client.replace("", "", {});
82+
83+
// $ExpectType Promise<CompleteCallbackObject>
84+
client.request("");
85+
86+
// $ExpectType Promise<CompleteCallbackObject>
87+
client.accessToken("", "");
88+
89+
// $ExpectType Promise<CompleteCallbackObject>
90+
client.generateClientCredentials("");
91+
92+
// $ExpectType Promise<CompleteCallbackObject>
93+
client.generateClientCredentials([""]);

0 commit comments

Comments
 (0)