· 6 years ago · Aug 30, 2019, 12:34 PM
1// Type definitions for node-asana 0.14.0
2// Project: https://github.com/Asana/node-asana
3// Definitions by: Qubo <https://github.com/tkqubo>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 3.2
6import * as Promise from 'bluebird';
7
8declare namespace asana {
9 var Client: ClientStatic;
10
11 interface ClientStatic {
12 /**
13 * Constructs a Client with instances of all the resources using the dispatcher.
14 * It also keeps a reference to the dispatcher so that way the end user can have
15 * access to it.
16 * @class
17 * @classdesc A wrapper for the Asana API which is authenticated for one user
18 * @param {Dispatcher} dispatcher The request dispatcher to use
19 * @param {Object} options Options to configure the client
20 * @param {String} [clientId] ID of the client, required for Oauth
21 * @param {String} [clientSecret] Secret key, for some Oauth flows
22 * @param {String} [redirectUri] Default redirect URI for this client
23 * @param {String} [asanaBaseUrl] Base URL for Asana, for debugging
24 */
25 (dispatcher: Dispatcher, options?: ClientOptions): asana.Client;
26 /**
27 * Creates a new client.
28 * @param {Object} options Options for specifying the client, see constructor.
29 */
30 create(options?: ClientOptions): Client;
31 }
32
33 /** Options to configure the client */
34 interface ClientOptions extends DispatcherOptions {
35 clientId?: string | number;
36 clientSecret?: string;
37 redirectUri?: string;
38 asanaBaseUrl?: string;
39 }
40
41 interface Client {
42 /**
43 * Ensures the client is authorized to make requests. Kicks off the
44 * configured Oauth flow, if any.
45 *
46 * @returns {Promise<Client>} A promise that resolves to this client when
47 * authorization is complete.
48 */
49 authorize(): Promise<Client>;
50
51 /**
52 * Configure the Client to use a user's API Key and then authenticate
53 * through HTTP Basic Authentication. This should only be done for testing,
54 * as requests using Oauth can provide more security, higher rate limits, and
55 * more features.
56 * @param {String} apiKey The Asana Api Key of the user
57 * @return {Client} this
58 * @param apiKey
59 * @return
60 */
61 useBasicAuth(apiKey: string): this;
62
63 /**
64 * Configure the client to authenticate using a Personal Access Token.
65 * @param {String} accessToken The Personal Access Token to use for
66 * authenticating requests.
67 * @return {Client} this
68 * @param accessToken
69 * @return
70 */
71 useAccessToken(accessToken: string): this;
72
73 /**
74 * Configure the client to authenticate via Oauth. Credentials can be
75 * supplied, or they can be obtained by running an Oauth flow.
76 * @param {Object} options Options for Oauth. Includes any options for
77 * the selected flow.
78 * @option {Function} [flowType] Type of OauthFlow to use to obtain user
79 * authorization. Defaults to autodetect based on environment.
80 * @option {Object} [credentials] Credentials to use; no flow required to
81 * obtain authorization. This object should at a minimum contain an
82 * `access_token` string field.
83 * @return {Client} this
84 * @param options
85 * @return
86 */
87 useOauth(options?: auth.OauthAuthenticatorOptions): this;
88
89 /**
90 * The internal dispatcher. This is mostly used by the resources but provided
91 * for custom requests to the API or API features that have not yet been added
92 * to the client.
93 * @type {Dispatcher}
94 */
95 dispatcher: Dispatcher;
96 /**
97 * An instance of the Attachments resource.
98 * @type {Attachments}
99 */
100 attachments: resources.Attachments;
101 /**
102 * An instance of the Events resource.
103 * @type {Events}
104 */
105 events: resources.Events;
106 /**
107 * An instance of the Projects resource.
108 * @type {Projects}
109 */
110 projects: resources.Projects;
111 /**
112 * An instance of the Stories resource.
113 * @type {Stories}
114 */
115 stories: resources.Stories;
116 /**
117 * An instance of the Tags resource.
118 * @type {Tags}
119 */
120 tags: resources.Tags;
121 /**
122 * An instance of the Tasks resource.
123 * @type {Tasks}
124 */
125 tasks: resources.Tasks;
126 /**
127 * An instance of the Teams resource.
128 * @type {Teams}
129 */
130 teams: resources.Teams;
131 /**
132 * An instance of the Users resource.
133 * @type {Users}
134 */
135 users: resources.Users;
136 /**
137 * An instance of the Workspaces resource.
138 * @type {Workspaces}
139 */
140 workspaces: resources.Workspaces;
141 /**
142 * Store off Oauth info.
143 */
144 app: auth.App;
145 }
146
147 var Dispatcher: DispatcherStatic;
148
149 interface DispatcherStatic {
150 /**
151 * Creates a dispatcher which will act as a basic wrapper for making HTTP
152 * requests to the API, and handle authentication.
153 * @class
154 * @classdesc A HTTP wrapper for the Asana API
155 * @param {Object} options for default behavior of the Dispatcher
156 * @option {Authenticator} [authenticator] Object to use for authentication.
157 * Can also be set later with `setAuthenticator`.
158 * @option {String} [retryOnRateLimit] Automatically handle `RateLimitEnforced`
159 * errors by sleeping and retrying after the waiting period.
160 * @option {Function} [handleUnauthorized] Automatically handle
161 * `NoAuthorization` with the callback. If the callback returns `true`
162 * (or a promise resolving to `true), will retry the request.
163 * @option {String} [asanaBaseUrl] Base URL for Asana, for debugging
164 * @option {Number} [requestTimeout] Timeout (in milliseconds) to wait for the
165 * request to finish.
166 */
167 new (options?: DispatcherOptions): Dispatcher;
168
169 /**
170 * Default handler for requests that are considered unauthorized.
171 * Requests that the authenticator try to refresh its credentials if
172 * possible.
173 * @return {Promise<boolean>} True iff refresh was successful, false if not.
174 * @return
175 */
176 maybeReauthorize(): Promise<boolean>;
177
178 /**
179 * The relative API path for the current version of the Asana API.
180 * @type {String}
181 */
182 API_PATH: string;
183 }
184
185 interface DispatcherOptions {
186 authenticator?: auth.Authenticator;
187 retryOnRateLimit?: boolean;
188 handleUnauthorized?: () => boolean | Promise<boolean>;
189 requestTimeout?: string;
190 }
191
192 interface Dispatcher {
193 /**
194 * Creates an Asana API Url by concatenating the ROOT_URL with path provided.
195 * @param {String} path The path
196 * @return {String} The url
197 * @param path
198 * @return
199 */
200 url(path: string): string;
201
202 /**
203 * Configure the authentication mechanism to use.
204 * @returns {Dispatcher} this
205 * @param authenticator
206 * @return
207 */
208 setAuthenticator(authenticator: auth.Authenticator): this;
209
210 /**
211 * Ensure the dispatcher is authorized to make requests. Call this before
212 * making any API requests.
213 *
214 * @returns {Promise} Resolves when the dispatcher is authorized, rejected if
215 * there was a problem authorizing.
216 * @return
217 */
218 authorize(): Promise<void>;
219
220 /**
221 * Dispatches a request to the Asana API. The request parameters are passed to
222 * the request module.
223 * @param {Object} params The params for request
224 * @param {Object} [dispatchOptions] Options for handling request/response
225 * @return {Promise} The response for the request
226 * @param params
227 * @param dispatchOptions?
228 * @return
229 */
230 dispatch(params: any, dispatchOptions?: any): Promise<any>;
231
232 /**
233 * Dispatches a GET request to the Asana API.
234 * @param {String} path The path of the API
235 * @param {Object} [query] The query params
236 * @param {Object} [dispatchOptions] Options for handling the request and
237 * response. See `dispatch`.
238 * @return {Promise} The response for the request
239 * @param path
240 * @param query?
241 * @param dispatchOptions?
242 * @return
243 */
244 get(path: string, query?: any, dispatchOptions?: any): Promise<any>;
245
246 /**
247 * Dispatches a POST request to the Asana API.
248 * @param {String} path The path of the API
249 * @param {Object} data The data to be sent
250 * @param {Object} [dispatchOptions] Options for handling the request and
251 * response. See `dispatch`.
252 * @return {Promise} The response for the request
253 * @param path
254 * @param data
255 * @param dispatchOptions?
256 * @return
257 */
258 post(path: string, data: any, dispatchOptions?: any): Promise<any>;
259
260 /**
261 * Dispatches a PUT request to the Asana API.
262 * @param {String} path The path of the API
263 * @param {Object} data The data to be sent
264 * @param {Object} [dispatchOptions] Options for handling the request and
265 * response. See `dispatch`.
266 * @return {Promise} The response for the request
267 * @param path
268 * @param data
269 * @param dispatchOptions?
270 * @return
271 */
272 put(path: string, data: any, dispatchOptions?: any): Promise<any>;
273
274 /**
275 * Dispatches a DELETE request to the Asana API.
276 * @param {String} path The path of the API
277 * @param {Object} [dispatchOptions] Options for handling the request and
278 * response. See `dispatch`.
279 * @return {Promise} The response for the request
280 * @param path
281 * @param dispatchOptions?
282 * @return
283 */
284 delete(path: string, dispatchOptions?: any): Promise<any>;
285
286 /**
287 * The base URL for Asana
288 * @type {String}
289 */
290 asanaBaseUrl: string;
291
292 /**
293 * Whether requests should be automatically retried if rate limited.
294 * @type {Boolean}
295 */
296 retryOnRateLimit: boolean;
297
298 /**
299 * Handler for unauthorized requests which may seek reauthorization.
300 * Default behavior is available if configured with an Oauth authenticator
301 * that has a refresh token, and will refresh the current access token.
302 * @type {Function}
303 */
304 handleUnauthorized: () => boolean | Promise<boolean>;
305
306 /**
307 * The amount of time in milliseconds to wait for a request to finish.
308 * @type {Number}
309 */
310 requestTimeout: number;
311 }
312
313 namespace auth {
314 var BasicAuthenticator: BasicAuthenticatorStatic;
315
316 interface BasicAuthenticatorStatic {
317 /**
318 * @param apiKey
319 */
320 new (apiKey: string): BasicAuthenticator;
321 }
322
323 interface BasicAuthenticator extends Authenticator {
324 /**
325 * @param {Object} request The request to modify, for the `request` library.
326 * @return {Object} The `request` parameter, modified to include authentication
327 * information using the stored credentials.
328 * @param request
329 * @return
330 */
331 authenticateRequest(request: BasicAuthenticatorRequest): BasicAuthenticatorRequest;
332 }
333
334 interface BasicAuthenticatorRequest {
335 auth: {
336 username: string;
337 password: string;
338 }
339 }
340
341 var OauthAuthenticator: OauthAuthenticatorStatic;
342
343 interface OauthAuthenticatorStatic {
344 /**
345 * Creates an authenticator that uses Oauth for authentication.
346 *
347 * @param {Object} options Configure the authenticator; must specify one
348 * of `flow` or `credentials`.
349 * @option {App} app The app being authenticated for.
350 * @option {OauthFlow} [flow] The flow to use to get credentials
351 * when needed.
352 * @option {String|Object} [credentials] Initial credentials to use. This can
353 * be either the object returned from an access token request (which
354 * contains the token and some other metadata) or just the `access_token`
355 * field.
356 * @constructor
357 */
358 new (options: OauthAuthenticatorOptions): OauthAuthenticator;
359 }
360
361 interface OauthAuthenticatorOptions {
362 flowType?: auth.FlowType;
363 credentials?: Credentials | string;
364 }
365
366 interface Credentials {
367 access_token?: string;
368 refresh_token?: string;
369 }
370
371 interface OauthAuthenticator extends Authenticator {
372 /**
373 * @param {Object} request The request to modify, for the `request` library.
374 * @return {Object} The `request` parameter, modified to include authentication
375 * information using the stored credentials.
376 * @param request
377 * @return
378 */
379 authenticateRequest(request: OauthAuthenticatorRequest): OauthAuthenticatorRequest;
380 }
381
382 interface OauthAuthenticatorRequest {
383 /**
384 * When browserify-d, the `auth` component of the `request` library
385 * doesn't work so well, so we just manually set the bearer token instead.
386 */
387 headers: {
388 Authorization: string;
389 }
390 }
391
392 /**
393 * A layer to abstract the differences between using different types of
394 * authentication (Oauth vs. Basic). The Authenticator is responsible for
395 * establishing credentials and applying them to outgoing requests.
396 * @constructor
397 */
398 interface Authenticator {
399 /**
400 * Establishes credentials.
401 *
402 * @return {Promise} Resolves when initial credentials have been
403 * completed and `authenticateRequest` calls can expect to succeed.
404 * @return
405 */
406 establishCredentials(): Promise<void>;
407
408 /**
409 * Attempts to refresh credentials, if possible, given the current credentials.
410 *
411 * @return {Promise} Resolves to `true` if credentials have been successfully
412 * established and `authenticateRequests` can expect to succeed, else
413 * resolves to `false`.
414 * @return
415 */
416 refreshCredentials(): Promise<boolean>;
417 }
418
419 var App: AppStatic;
420
421 interface AppStatic {
422 /**
423 * An abstraction around an App used with Asana.
424 *
425 * @options {Object} Options to construct the app
426 * @option {String} clientId The ID of the app
427 * @option {String} [clientSecret] The secret key, if available here
428 * @option {String} [redirectUri] The default redirect URI
429 * @option {String} [scope] Scope to use, supports `default` and `scim`
430 * @option {String} [asanaBaseUrl] Base URL to use for Asana, for debugging
431 * @constructor
432 */
433 new (options: AppOptions): App;
434 }
435
436 interface AppOptions extends AsanaAuthorizeUrlOptions {
437 clientId?: string | number;
438 clientSecret?: string;
439 scope?: string;
440 }
441
442 interface App {
443 /**
444 * @param {Object} options Overrides to the app's defaults
445 * @option {String} asanaBaseUrl
446 * @option {String} redirectUri
447 * @returns {String} The URL used to authorize a user for the app.
448 * @param options
449 * @return
450 */
451 asanaAuthorizeUrl(options?: AsanaAuthorizeUrlOptions): string;
452
453 /**
454 * @param {Object} options Overrides to the app's defaults
455 * @option {String} asanaBaseUrl
456 * @option {String} redirectUri
457 * @returns {String} The URL used to acquire an access token.
458 * @param options
459 * @return
460 */
461 asanaTokenUrl(options?: AsanaAuthorizeUrlOptions): string;
462
463 /**
464 * @param {String} code An authorization code obtained via `asanaAuthorizeUrl`.
465 * @param {Object} options Overrides to the app's defaults
466 * @option {String} asanaBaseUrl
467 * @option {String} redirectUri
468 * @return {Promise<Object>} The token, which will include the `access_token`
469 * used for API access, as well as a `refresh_token` which can be stored
470 * to get a new access token without going through the flow again.
471 * @param code
472 * @param options
473 * @return
474 */
475 accessTokenFromCode(code: string, options?: AsanaAuthorizeUrlOptions): Promise<Credentials>;
476
477 /**
478 * @param {String} refreshToken A refresh token obtained via Oauth.
479 * @param {Object} options Overrides to the app's defaults
480 * @option {String} asanaBaseUrl
481 * @option {String} redirectUri
482 * @return {Promise<Object>} The token, which will include the `access_token`
483 * used for API access.
484 * @param refreshToken
485 * @param options
486 * @return
487 */
488 accessTokenFromRefreshToken(refreshToken: string, options: AsanaAuthorizeUrlOptions): Promise<Credentials>;
489
490 scope: string;
491
492 asanaBaseUrl: string;
493 }
494
495 interface AsanaAuthorizeUrlOptions {
496 redirectUri?: string;
497 asanaBaseUrl?: string;
498 }
499
500 var OauthError: OauthErrorStatic;
501
502 interface OauthErrorStatic {
503 /**
504 * @param options {Object} A data blob parsed from a query string or JSON
505 * response from the Asana API
506 * @option {String} error The string code identifying the error.
507 * @option {String} [error_uri] A link to help and information about the error.
508 * @option {String} [error_description] A description of the error.
509 * @constructor
510 */
511 new (options: OauthErrorOptions): OauthError;
512 }
513
514 interface OauthErrorOptions {
515 error?: string;
516 error_uri?: string;
517 error_description?: string;
518 }
519
520 interface OauthError extends Error {
521 }
522
523 /**
524 * Auto-detects the type of Oauth flow to use that's appropriate to the
525 * environment.
526 *
527 * @returns {Function|null} The type of Oauth flow to use, or null if no
528 * appropriate type could be determined.
529 * @param env
530 * @return
531 */
532 function autoDetect(env: any): Function;
533
534 var RedirectFlow: RedirectFlowStatic;
535
536 interface RedirectFlowStatic extends FlowType {
537 /**
538 * An Oauth flow that runs in the browser and requests user authorization by
539 * redirecting to an authorization page on Asana, and redirecting back with
540 * the credentials.
541 * @param {Object} options See `BaseBrowserFlow` for options.
542 * @constructor
543 */
544 new (options: any): RedirectFlow;
545 }
546
547 interface RedirectFlow extends BaseBrowserFlow {
548 }
549
550 var PopupFlow: PopupFlowStatic;
551
552 interface PopupFlowStatic extends FlowType {
553 /**
554 * An Oauth flow that runs in the browser and requests user authorization by
555 * popping up a window and prompting the user.
556 * @param {Object} options See `BaseBrowserFlow` for options.
557 * @constructor
558 */
559 new (options: any): PopupFlow;
560 }
561
562 interface PopupFlow extends BaseBrowserFlow {
563 /**
564 * @param popupWidth
565 * @param popupHeight
566 */
567 _popupParams(popupWidth: number, popupHeight: number): void;
568
569 runReceiver(): void;
570 }
571
572 var NativeFlow: NativeFlowStatic;
573
574 interface NativeFlowStatic extends FlowType {
575 /**
576 * An Oauth flow that can be run from the console or an app that does
577 * not have the ability to open and manage a browser on its own.
578 * @param {Object} options
579 * @option {App} app App to authenticate for
580 * @option {String function(String)} [instructions] Function returning the
581 * instructions to output to the user. Passed the authorize url.
582 * @option {String function()} [prompt] String to output immediately before
583 * waiting for a line from stdin.
584 * @constructor
585 */
586 new (options: any): NativeFlow;
587 }
588
589 interface NativeFlow extends Flow {
590 /**
591 * Run the Oauth flow, prompting the user to go to the authorization URL
592 * and enter the code it displays when finished.
593 *
594 * @return {Promise<Object>} The access token object, which will include
595 * `access_token` and `refresh_token`.
596 */
597 run(): void;
598
599 /**
600 * @param {String} code An authorization code obtained via `asanaAuthorizeUrl`.
601 * @return {Promise<Object>} The token, which will include the `access_token`
602 * used for API access, as well as a `refresh_token` which can be stored
603 * to get a new access token without going through the flow again.
604 * @param code
605 */
606 accessToken(code: string): void;
607
608 /**
609 * @return {Promise} The access token, which will include a refresh token
610 * that can be stored in the future to create a client without going
611 * through the Oauth flow.
612 * @param url
613 * @return
614 */
615 promptForCode(url: string): any;
616 }
617
618 var ChromeExtensionFlow: ChromeExtensionFlowStatic;
619
620 interface ChromeExtensionFlowStatic extends FlowType {
621 /**
622 * An Oauth flow that runs in a Chrome browser extension and requests user
623 * authorization by opening a temporary tab to prompt the user.
624 * @param {Object} options See `BaseBrowserFlow` for options, plus the below:
625 * @options {String} [receiverPath] Full path and filename from the base
626 * directory of the extension to the receiver page. This is an HTML file
627 * that has been made web-accessible, and that calls the receiver method
628 * `Asana.auth.ChromeExtensionFlow.runReceiver();`.
629 * @constructor
630 */
631 new (options: any): ChromeExtensionFlow;
632 }
633
634 interface ChromeExtensionFlow extends BaseBrowserFlow {
635 /**
636 * Runs the receiver code to send the Oauth result to the requesting tab.
637 */
638 runReceiver(): void;
639 }
640
641 var BaseBrowserFlow: BaseBrowserFlowStatic;
642
643 interface BaseBrowserFlowStatic extends FlowType {
644 /**
645 * A base class for any flow that runs in the browser. All subclasses use the
646 * "implicit grant" flow to authenticate via the browser.
647 * @param {Object} options
648 * @option {App} app The app this flow is for
649 * @option {String} [redirectUri] The URL that Asana should redirect to once
650 * user authorization is complete. Defaults to the URL configured in
651 * the app, and if none then the current page URL.
652 * @constructor
653 */
654 new (options: any): BaseBrowserFlow;
655 }
656
657 interface BaseBrowserFlow extends Flow {
658 /**
659 * @param {String} authUrl The URL the user should be navigated to in order
660 * to authorize the app.
661 * @param {String} state The unique state generated for this auth request.
662 * @return {Promise} Resolved when authorization has successfully started,
663 * i.e. the user has been navigated to a page requesting authorization.
664 * @param authUrl
665 * @param state
666 * @return
667 */
668 startAuthorization(authUrl: string, state: string): any;
669
670 /**
671 * @return {Promise<Object>} Credentials returned from Oauth.
672 * @param state
673 */
674 finishAuthorization(state: string): void;
675
676 /**
677 * @return {String} The URL to redirect to that will receive the
678 * @return
679 */
680 receiverUrl(): string;
681
682 /**
683 * @return {String} The URL to redirect to that will receive the
684 * @return
685 */
686 asanaBaseUrl(): string;
687
688 /**
689 * @returns {String} Generate a new unique state parameter for a request.
690 * @return
691 */
692 getStateParam(): string;
693 }
694
695 interface FlowType {
696 new (options: any): Flow;
697 }
698
699 interface Flow {
700 /**
701 * @returns {String} The URL used to authorize the user for the app.
702 * @return
703 */
704 authorizeUrl(): string;
705
706 /**
707 * Run the appropriate parts of the Oauth flow, attempting to establish user
708 * authorization.
709 * @returns {Promise<Object>} A promise that resolves to the Oauth credentials.
710 */
711 run(): void;
712 }
713 }
714
715 namespace errors {
716 class AsanaError extends Error {
717 /**
718 * @param message
719 * @return
720 */
721 constructor(message: any);
722
723 code: number;
724 value: any;
725 }
726
727 class Forbidden extends AsanaError {
728 /**
729 * @param value
730 * @return
731 */
732 constructor(value: any);
733 }
734
735
736 class InvalidRequest extends AsanaError {
737 /**
738 * @param value
739 * @return
740 */
741 constructor(value: any);
742 }
743
744 class NoAuthorization extends AsanaError {
745 /**
746 * @param value
747 * @return
748 */
749 constructor(value: any);
750 }
751
752 class NotFound extends AsanaError {
753 /**
754 * @param value
755 * @return
756 */
757 constructor(value: any);
758 }
759
760 class RateLimitEnforced extends AsanaError {
761 /**
762 * @param value
763 * @return
764 */
765 constructor(value: any);
766 }
767
768 class ServerError extends AsanaError {
769 /**
770 * @param value
771 * @return
772 */
773 constructor(value: any);
774 }
775 }
776
777 namespace resources {
778 interface AttachmentsStatic {
779 /**
780 * @param dispatcher
781 */
782 new (dispatcher: Dispatcher): Attachments;
783 }
784
785 namespace Attachments {
786 interface Type extends Resource {
787 readonly id: number;
788 readonly created_at: string;
789 readonly download_url: string;
790 readonly view_url: string;
791 readonly name: string;
792 readonly host: string;
793 readonly parent: Resource;
794 }
795 }
796
797 var Attachments: AttachmentsStatic;
798
799 /**
800 * An _attachment_ object represents any file attached to a task in Asana,
801 * whether it's an uploaded file or one associated via a third-party service
802 * such as Dropbox or Google Drive.
803 * @class
804 * @param {Dispatcher} dispatcher The API dispatcher
805 */
806 interface Attachments extends Resource {
807 /**
808 * * Returns the full record for a single attachment.
809 * * @param {Number} attachment Globally unique identifier for the attachment.
810 * * @param {Object} [params] Parameters for the request
811 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
812 * * @return {Promise} The requested resource
813 * @param attachment
814 * @param params?
815 * @param dispatchOptions?
816 * @return
817 */
818 findById(attachment: number, params?: Params, dispatchOptions?: any): Promise<Attachments.Type>;
819
820 /**
821 * * Returns the compact records for all attachments on the task.
822 * * @param {Number} task Globally unique identifier for the task.
823 * * @param {Object} [params] Parameters for the request
824 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
825 * * @return {Promise} The response from the API
826 * @param task
827 * @param params?
828 * @param dispatchOptions?
829 * @return
830 */
831 findByTask(task: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Attachments.Type>>;
832 }
833
834 interface EventsStatic {
835 /**
836 * @param dispatcher
837 * @return
838 */
839 new (dispatcher: Dispatcher): Events;
840 }
841
842 var Events: EventsStatic;
843
844 /**
845 * An _event_ is an object representing a change to a resource that was observed
846 * by an event subscription.
847 *
848 * In general, requesting events on a resource is faster and subject to higher
849 * rate limits than requesting the resource itself. Additionally, change events
850 * bubble up - listening to events on a project would include when stories are
851 * added to tasks in the project, even on subtasks.
852 *
853 * Establish an initial sync token by making a request with no sync token.
854 * The response will be a `412` error - the same as if the sync token had
855 * expired.
856 *
857 * Subsequent requests should always provide the sync token from the immediately
858 * preceding call.
859 *
860 * Sync tokens may not be valid if you attempt to go 'backward' in the history
861 * by requesting previous tokens, though re-requesting the current sync token
862 * is generally safe, and will always return the same results.
863 *
864 * When you receive a `412 Precondition Failed` error, it means that the
865 * sync token is either invalid or expired. If you are attempting to keep a set
866 * of data in sync, this signals you may need to re-crawl the data.
867 *
868 * Sync tokens always expire after 24 hours, but may expire sooner, depending on
869 * load on the service.
870 * @class
871 * @param {Dispatcher} dispatcher The API dispatcher
872 */
873 interface Events extends Resource { }
874
875 interface ProjectsStatic {
876 /**
877 * @param dispatcher
878 */
879 new (dispatcher: Dispatcher): Projects;
880 }
881
882 namespace Projects {
883 interface Type extends Resource {
884 created_at: string;
885 modified_at: string;
886 due_date: string;
887 current_status: Status;
888 public: boolean;
889 archived: boolean;
890 notes: string;
891 color: string;
892 workspace: Resource;
893 team: Resource;
894 members: Resource[];
895 followers: Resource[];
896 }
897
898 interface CreateParams {
899 name?: string;
900 team?: number;
901 public?: boolean;
902 due_date: string;
903 notes?: string;
904 color?: string;
905 }
906
907 interface FollowersParams {
908 followers: (number | string)[];
909 }
910
911 interface MembersParams {
912 members: (number | string)[];
913 }
914
915 interface Status {
916 color: string;
917 text: string;
918 html_text: string;
919 modified_at: string;
920 author: Resource;
921 }
922
923 interface FindAllParams extends PaginationParams {
924 team?: number;
925 archived?: boolean;
926 }
927
928 interface FindByParams extends PaginationParams {
929 archived?: boolean;
930 }
931 }
932
933 var Projects: ProjectsStatic;
934
935 /**
936 * A _project_ represents a prioritized list of tasks in Asana. It exists in a
937 * single workspace or organization and is accessible to a subset of users in
938 * that workspace or organization, depending on its permissions.
939 *
940 * Projects in organizations are shared with a single team. You cannot currently
941 * change the team of a project via the API. Non-organization workspaces do not
942 * have teams and so you should not specify the team of project in a
943 * regular workspace.
944 * @class
945 * @param {Dispatcher} dispatcher The API dispatcher
946 */
947 interface Projects extends Resource {
948 /**
949 * * Creates a new project in a workspace or team.
950 * *
951 * * Every project is required to be created in a specific workspace or
952 * * organization, and this cannot be changed once set. Note that you can use
953 * * the `workspace` parameter regardless of whether or not it is an
954 * * organization.
955 * *
956 * * If the workspace for your project _is_ an organization, you must also
957 * * supply a `team` to share the project with.
958 * *
959 * * Returns the full record of the newly created project.
960 * * @param {Object} data Data for the request
961 * * @param {String} data.workspace The workspace or organization to create the project in.
962 * * @param {String} [data.team] If creating in an organization, the specific team to create the
963 * * project in.
964 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
965 * * @return {Promise} The response from the API
966 * @param data
967 * @param dispatchOptions?
968 * @return
969 */
970 create(data: Projects.CreateParams & { workspace: number }, dispatchOptions?: any): Promise<Projects.Type>;
971
972 /**
973 * * If the workspace for your project _is_ an organization, you must also
974 * * supply a `team` to share the project with.
975 * *
976 * * Returns the full record of the newly created project.
977 * * @param {Number} workspace The workspace or organization to create the project in.
978 * * @param {Object} data Data for the request
979 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
980 * * @return {Promise} The response from the API
981 * @param workspace
982 * @param data
983 * @param dispatchOptions?
984 * @return
985 */
986 createInWorkspace(workspace: number, data: Projects.CreateParams, dispatchOptions?: any): Promise<Projects.Type>;
987
988 /**
989 * * Creates a project shared with the given team.
990 * *
991 * * Returns the full record of the newly created project.
992 * * @param {Number} team The team to create the project in.
993 * * @param {Object} data Data for the request
994 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
995 * * @return {Promise} The response from the API
996 * @param team
997 * @param data
998 * @param dispatchOptions?
999 * @return
1000 */
1001 createInTeam(team: number, data: Projects.CreateParams, dispatchOptions?: any): Promise<Projects.Type>;
1002
1003 /**
1004 * * Returns the complete project record for a single project.
1005 * * @param {Number} project The project to get.
1006 * * @param {Object} [params] Parameters for the request
1007 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1008 * * @return {Promise} The requested resource
1009 * @param project
1010 * @param params?
1011 * @param dispatchOptions?
1012 * @return
1013 */
1014 findById(project: string | number, params?: Params, dispatchOptions?: any): Promise<Projects.Type>;
1015
1016 /**
1017 * * A specific, existing project can be updated by making a PUT request on the
1018 * * URL for that project. Only the fields provided in the `data` block will be
1019 * * updated; any unspecified fields will remain unchanged.
1020 * *
1021 * * When using this method, it is best to specify only those fields you wish
1022 * * to change, or else you may overwrite changes made by another user since
1023 * * you last retrieved the task.
1024 * *
1025 * * Returns the complete updated project record.
1026 * * @param {Number} project The project to update.
1027 * * @param {Object} data Data for the request
1028 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1029 * * @return {Promise} The response from the API
1030 * @param project
1031 * @param data
1032 * @param dispatchOptions?
1033 * @return
1034 */
1035 update(project: string | number, data: Projects.CreateParams, dispatchOptions?: any): Promise<Projects.Type>;
1036
1037 /**
1038 * * A specific, existing project can be deleted by making a DELETE request
1039 * * on the URL for that project.
1040 * *
1041 * * Returns an empty data record.
1042 * * @param {Number} project The project to delete.
1043 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1044 * * @return {Promise} The response from the API
1045 * @param project
1046 * @param dispatchOptions?
1047 * @return
1048 */
1049 delete(project: string | number, dispatchOptions?: any): Promise<void>;
1050
1051 /**
1052 * * Returns the compact project records for some filtered set of projects.
1053 * * Use one or more of the parameters provided to filter the projects returned.
1054 * * @param {Object} [params] Parameters for the request
1055 * * @param {String} [params.workspace] The workspace or organization to filter projects on.
1056 * * @param {String} [params.team] The team to filter projects on.
1057 * * @param {Boolean} [params.archived] Only return projects whose `archived` field takes on the value of
1058 * * this parameter.
1059 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1060 * * @return {Promise} The response from the API
1061 * @param params?
1062 * @param dispatchOptions?
1063 * @return
1064 */
1065 findAll(params?: Projects.FindAllParams, dispatchOptions?: any): Promise<ResourceList<Projects.Type>>;
1066
1067 /**
1068 * * Returns the compact project records for all projects in the workspace.
1069 * * @param {Number} workspace The workspace or organization to find projects in.
1070 * * @param {Object} [params] Parameters for the request
1071 * * @param {Boolean} [params.archived] Only return projects whose `archived` field takes on the value of
1072 * * this parameter.
1073 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1074 * * @return {Promise} The response from the API
1075 * @param workspace
1076 * @param params?
1077 * @param dispatchOptions?
1078 * @return
1079 */
1080 findByWorkspace(workspace: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise<ResourceList<Projects.Type>>;
1081
1082 /**
1083 * * Returns the compact project records for all projects in the team.
1084 * * @param {Number} team The team to find projects in.
1085 * * @param {Object} [params] Parameters for the request
1086 * * @param {Boolean} [params.archived] Only return projects whose `archived` field takes on the value of
1087 * * this parameter.
1088 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1089 * * @return {Promise} The response from the API
1090 * @param team
1091 * @param params?
1092 * @param dispatchOptions?
1093 * @return
1094 */
1095 findByTeam(team: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise<ResourceList<Projects.Type>>;
1096
1097 /**
1098 * * Returns compact records for all sections in the specified project.
1099 * * @param {Number} project The project to get sections from.
1100 * * @param {Object} [params] Parameters for the request
1101 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1102 * * @return {Promise} The response from the API
1103 * @param project
1104 * @param params?
1105 * @param dispatchOptions?
1106 * @return
1107 */
1108 sections(project: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Sections.Type>>;
1109
1110 /**
1111 * * Returns the compact task records for all tasks within the given project,
1112 * * ordered by their priority within the project. Tasks can exist in more than one project at a time.
1113 * * @param {Number} project The project in which to search for tasks.
1114 * * @param {Object} [params] Parameters for the request
1115 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1116 * * @return {Promise} The response from the API
1117 * @param project
1118 * @param params?
1119 * @param dispatchOptions?
1120 * @return
1121 */
1122 tasks(project: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tasks.Type>>;
1123
1124 /**
1125 * * Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if
1126 * * the users are not already members of the project they will also become members as a result of this operation.
1127 * * Returns the updated project record.
1128 * * @param {Number} project The project to add followers to.
1129 * * @param {Object} data Data for the request
1130 * * @param {Array} data.followers An array of followers to add to the project.
1131 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1132 * * @return {Promise} The response from the API
1133 * @param project
1134 * @param data
1135 * @param dispatchOptions?
1136 * @return
1137 */
1138 addFollowers(project: string | number, data: Projects.FollowersParams, dispatchOptions?: any): Promise<Projects.Type>;
1139
1140 /**
1141 * * Removes the specified list of users from following the project, this will not affect project membership status.
1142 * * Returns the updated project record.
1143 * * @param {Number} project The project to remove followers from.
1144 * * @param {Object} data Data for the request
1145 * * @param {Array} data.followers An array of followers to remove from the project.
1146 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1147 * * @return {Promise} The response from the API
1148 * @param project
1149 * @param data
1150 * @param dispatchOptions?
1151 * @return
1152 */
1153 removeFollowers(project: string | number, data: Projects.FollowersParams, dispatchOptions?: any): Promise<Projects.Type>;
1154
1155 /**
1156 * * Adds the specified list of users as members of the project. Returns the updated project record.
1157 * * @param {Number} project The project to add members to.
1158 * * @param {Object} data Data for the request
1159 * * @param {Array} data.members An array of members to add to the project.
1160 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1161 * * @return {Promise} The response from the API
1162 * @param project
1163 * @param data
1164 * @param dispatchOptions?
1165 * @return
1166 */
1167 addMembers(project: string | number, data: Projects.MembersParams, dispatchOptions?: any): Promise<Projects.Type>;
1168
1169 /**
1170 * * Removes the specified list of members from the project. Returns the updated project record.
1171 * * @param {Number} project The project to remove members from.
1172 * * @param {Object} data Data for the request
1173 * * @param {Array} data.members An array of members to remove from the project.
1174 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1175 * * @return {Promise} The response from the API
1176 * @param project
1177 * @param data
1178 * @param dispatchOptions?
1179 * @return
1180 */
1181 removeMembers(project: string | number, data: Projects.MembersParams, dispatchOptions?: any): Promise<Projects.Type>;
1182 }
1183
1184 interface StoriesStatic {
1185 /**
1186 * @param dispatcher
1187 */
1188 new (dispatcher: Dispatcher): Stories;
1189 }
1190
1191 namespace Stories {
1192 interface ShortType extends Resource {
1193 created_at: string;
1194 created_by: Resource;
1195 type: string;
1196 text: string;
1197 }
1198
1199 interface Type extends ShortType {
1200 html_text: string;
1201 source: string;
1202 target: Resource;
1203 hearts: Type[];
1204 }
1205 }
1206
1207 var Stories: StoriesStatic;
1208
1209 /**
1210 * A _story_ represents an activity associated with an object in the Asana
1211 * system. Stories are generated by the system whenever users take actions such
1212 * as creating or assigning tasks, or moving tasks between projects. _Comments_
1213 * are also a form of user-generated story.
1214 *
1215 * Stories are a form of history in the system, and as such they are read-only.
1216 * Once generated, it is not possible to modify a story.
1217 * @class
1218 * @param {Dispatcher} dispatcher The API dispatcher
1219 */
1220 interface Stories extends Resource {
1221 /**
1222 * * Returns the compact records for all stories on the task.
1223 * * @param {Number} task Globally unique identifier for the task.
1224 * * @param {Object} [params] Parameters for the request
1225 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1226 * * @return {Promise} The response from the API
1227 * @param task
1228 * @param params?
1229 * @param dispatchOptions?
1230 * @return
1231 */
1232 findByTask(task: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Stories.Type>>;
1233
1234 /**
1235 * * Returns the full record for a single story.
1236 * * @param {Number} story Globally unique identifier for the story.
1237 * * @param {Object} [params] Parameters for the request
1238 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1239 * * @return {Promise} The requested resource
1240 * @param story
1241 * @param params?
1242 * @param dispatchOptions?
1243 * @return
1244 */
1245 findById(story: number, params?: Params, dispatchOptions?: any): Promise<Stories.Type>;
1246
1247 /**
1248 * * Adds a comment to a task. The comment will be authored by the
1249 * * currently authenticated user, and timestamped when the server receives
1250 * * the request.
1251 * *
1252 * * Returns the full record for the new story added to the task.
1253 * * @param {Number} task Globally unique identifier for the task.
1254 * * @param {Object} data Data for the request
1255 * * @param {String} data.text The plain text of the comment to add.
1256 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1257 * * @return {Promise} The response from the API
1258 * @param task
1259 * @param data
1260 * @param dispatchOptions?
1261 * @return
1262 */
1263 createOnTask(task: string | number, data: any, dispatchOptions?: any): Promise<ResourceList<Stories.ShortType>>;
1264 }
1265
1266 interface TagsStatic {
1267 /**
1268 * @param dispatcher
1269 */
1270 new (dispatcher: Dispatcher): Tags;
1271 }
1272
1273 namespace Tags {
1274 interface Type extends Resource {
1275 created_at: string;
1276 notes: string;
1277 workspace: Resource;
1278 color: string;
1279 followers: Resource[];
1280 }
1281
1282 interface FindAllParams extends PaginationParams {
1283 team?: number;
1284 archived?: boolean;
1285 }
1286 }
1287
1288 var Tags: TagsStatic;
1289
1290 /**
1291 * A _tag_ is a label that can be attached to any task in Asana. It exists in a
1292 * single workspace or organization.
1293 *
1294 * Tags have some metadata associated with them, but it is possible that we will
1295 * simplify them in the future so it is not encouraged to rely too heavily on it.
1296 * Unlike projects, tags do not provide any ordering on the tasks they
1297 * are associated with.
1298 * @class
1299 * @param {Dispatcher} dispatcher The API dispatcher
1300 */
1301 interface Tags extends Resource {
1302 /**
1303 * * Creates a new tag in a workspace or organization.
1304 * *
1305 * * Every tag is required to be created in a specific workspace or
1306 * * organization, and this cannot be changed once set. Note that you can use
1307 * * the `workspace` parameter regardless of whether or not it is an
1308 * * organization.
1309 * *
1310 * * Returns the full record of the newly created tag.
1311 * * @param {Object} data Data for the request
1312 * * @param {String} data.workspace The workspace or organization to create the tag in.
1313 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1314 * * @return {Promise} The response from the API
1315 * @param data
1316 * @param dispatchOptions?
1317 * @return
1318 */
1319 create(data: Tags.Type & { workspace: string }, dispatchOptions?: any): Promise<Tags.Type>;
1320
1321 /**
1322 * * Creates a new tag in a workspace or organization.
1323 * *
1324 * * Every tag is required to be created in a specific workspace or
1325 * * organization, and this cannot be changed once set. Note that you can use
1326 * * the `workspace` parameter regardless of whether or not it is an
1327 * * organization.
1328 * *
1329 * * Returns the full record of the newly created tag.
1330 * * @param {Number} workspace The workspace or organization to create the tag in.
1331 * * @param {Object} data Data for the request
1332 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1333 * * @return {Promise} The response from the API
1334 * @param workspace
1335 * @param data
1336 * @param dispatchOptions?
1337 * @return
1338 */
1339 createInWorkspace(workspace: number, data: Tags.Type, dispatchOptions?: any): Promise<Tags.Type>;
1340
1341 /**
1342 * * Returns the complete tag record for a single tag.
1343 * * @param {Number} tag The tag to get.
1344 * * @param {Object} [params] Parameters for the request
1345 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1346 * * @return {Promise} The requested resource
1347 * @param tag
1348 * @param params?
1349 * @param dispatchOptions?
1350 * @return
1351 */
1352 findById(tag: number, params?: Params, dispatchOptions?: any): Promise<Tags.Type>;
1353
1354 /**
1355 * * Updates the properties of a tag. Only the fields provided in the `data`
1356 * * block will be updated; any unspecified fields will remain unchanged.
1357 * *
1358 * * When using this method, it is best to specify only those fields you wish
1359 * * to change, or else you may overwrite changes made by another user since
1360 * * you last retrieved the task.
1361 * *
1362 * * Returns the complete updated tag record.
1363 * * @param {Number} tag The tag to update.
1364 * * @param {Object} data Data for the request
1365 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1366 * * @return {Promise} The response from the API
1367 * @param tag
1368 * @param data
1369 * @param dispatchOptions?
1370 * @return
1371 */
1372 update(tag: number, data: Tags.Type, dispatchOptions?: any): Promise<Tags.Type>;
1373
1374 /**
1375 * * A specific, existing tag can be deleted by making a DELETE request
1376 * * on the URL for that tag.
1377 * *
1378 * * Returns an empty data record.
1379 * * @param {Number} tag The tag to delete.
1380 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1381 * * @return {Promise} The response from the API
1382 * @param tag
1383 * @param dispatchOptions?
1384 * @return
1385 */
1386 delete(tag: number, dispatchOptions?: any): Promise<void>;
1387
1388 /**
1389 * * Returns the compact tag records for some filtered set of tags.
1390 * * Use one or more of the parameters provided to filter the tags returned.
1391 * * @param {Object} [params] Parameters for the request
1392 * * @param {String} [params.workspace] The workspace or organization to filter tags on.
1393 * * @param {String} [params.team] The team to filter tags on.
1394 * * @param {Boolean} [params.archived] Only return tags whose `archived` field takes on the value of
1395 * * this parameter.
1396 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1397 * * @return {Promise} The response from the API
1398 * @param params?
1399 * @param dispatchOptions?
1400 * @return
1401 */
1402 findAll(params?: Tags.FindAllParams, dispatchOptions?: any): Promise<ResourceList<Tags.Type>>;
1403
1404 /**
1405 * * Returns the compact tag records for all tags in the workspace.
1406 * * @param {Number} workspace The workspace or organization to find tags in.
1407 * * @param {Object} [params] Parameters for the request
1408 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1409 * * @return {Promise} The response from the API
1410 * @param workspace
1411 * @param params?
1412 * @param dispatchOptions?
1413 * @return
1414 */
1415 findByWorkspace(workspace: number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tags.Type>>;
1416
1417 /**
1418 * * Returns the compact task records for all tasks with the given tag.
1419 * * Tasks can have more than one tag at a time.
1420 * * @param {Number} tag The tag to fetch tasks from.
1421 * * @param {Object} [params] Parameters for the request
1422 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1423 * * @return {Promise} The response from the API
1424 * @param tag
1425 * @param params?
1426 * @param dispatchOptions?
1427 * @return
1428 */
1429 getTasksWithTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tasks.Type>>;
1430 }
1431
1432 interface TasksStatic {
1433 /**
1434 * @param dispatcher
1435 */
1436 new (dispatcher: Dispatcher): Tasks;
1437 }
1438
1439 namespace Tasks {
1440 interface Type extends Resource {
1441 created_at: string;
1442 modified_at: string;
1443 completed_at: string;
1444 completed: boolean;
1445 due_on: string;
1446 due_at: string;
1447 assignee_status: string;
1448 assignee: Assignee;
1449 notes: string;
1450 workspace: Resource;
1451 num_hearts: number;
1452 hearted: boolean;
1453 parent: Resource;
1454 tags: Resource[];
1455 projects: Resource[];
1456 memberships: Membership[];
1457 followers: Resource[];
1458 }
1459
1460 interface CreateParams {
1461 name: string;
1462 completed?: boolean;
1463 hearted?: boolean;
1464 notes?: string;
1465 }
1466
1467 interface FollowersParams {
1468 followers: (number | string)[];
1469 }
1470
1471 interface AddProjectParams {
1472 project: string | number;
1473 insertBefore?: number;
1474 insertAfter?: number;
1475 section?: number;
1476 }
1477
1478 interface RemoveProjectParams {
1479 project: string | number;
1480 }
1481
1482 interface TagParams {
1483 tag: string;
1484 }
1485
1486 interface CommentParams {
1487 text: string;
1488 }
1489
1490 interface FindAllParams extends PaginationParams {
1491 assignee?: number;
1492 workspace: number;
1493 completed_since?: string;
1494 modified_since?: string;
1495 }
1496 }
1497
1498 var Tasks: TasksStatic;
1499
1500 /**
1501 * The _task_ is the basic object around which many operations in Asana are
1502 * centered. In the Asana application, multiple tasks populate the middle pane
1503 * according to some view parameters, and the set of selected tasks determines
1504 * the more detailed information presented in the details pane.
1505 * @class
1506 * @param {Dispatcher} dispatcher The API dispatcher
1507 */
1508 interface Tasks extends Resource {
1509 /**
1510 * * Creating a new task is as easy as POSTing to the `/tasks` endpoint
1511 * * with a data block containing the fields you'd like to set on the task.
1512 * * Any unspecified fields will take on default values.
1513 * *
1514 * * Every task is required to be created in a specific workspace, and this
1515 * * workspace cannot be changed once set. The workspace need not be set
1516 * * explicitly if you specify a `project` or a `parent` task instead.
1517 * * @param {Object} data Data for the request
1518 * * @param {Number} [data.workspace] The workspace to create a task in.
1519 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1520 * * @return {Promise} The response from the API
1521 * @param data
1522 * @param dispatchOptions?
1523 * @return
1524 */
1525 create(data: Tasks.CreateParams & { workspace: string }, dispatchOptions?: any): Promise<Tasks.Type>;
1526
1527 /**
1528 * * Creating a new task is as easy as POSTing to the `/tasks` endpoint
1529 * * with a data block containing the fields you'd like to set on the task.
1530 * * Any unspecified fields will take on default values.
1531 * *
1532 * * Every task is required to be created in a specific workspace, and this
1533 * * workspace cannot be changed once set. The workspace need not be set
1534 * * explicitly if you specify a `project` or a `parent` task instead.
1535 * * @param {Number} workspace The workspace to create a task in.
1536 * * @param {Object} data Data for the request
1537 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1538 * * @return {Promise} The response from the API
1539 * @param workspace
1540 * @param data
1541 * @param dispatchOptions?
1542 * @return
1543 */
1544 createInWorkspace(workspace: number, data: Tasks.CreateParams, dispatchOptions?: any): Promise<Tasks.Type>;
1545
1546 /**
1547 * * Returns the complete task record for a single task.
1548 * * @param {Number} task The task to get.
1549 * * @param {Object} [params] Parameters for the request
1550 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1551 * * @return {Promise} The requested resource
1552 * @param task
1553 * @param params?
1554 * @param dispatchOptions?
1555 * @return
1556 */
1557 findById(task: string | number, params?: Params, dispatchOptions?: any): Promise<Tasks.Type>;
1558
1559 /**
1560 * * A specific, existing task can be updated by making a PUT request on the
1561 * * URL for that task. Only the fields provided in the `data` block will be
1562 * * updated; any unspecified fields will remain unchanged.
1563 * *
1564 * * When using this method, it is best to specify only those fields you wish
1565 * * to change, or else you may overwrite changes made by another user since
1566 * * you last retrieved the task.
1567 * *
1568 * * Returns the complete updated task record.
1569 * * @param {Number} task The task to update.
1570 * * @param {Object} data Data for the request
1571 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1572 * * @return {Promise} The response from the API
1573 * @param task
1574 * @param data
1575 * @param dispatchOptions?
1576 * @return
1577 */
1578 update(task: string | number, data: Tasks.CreateParams, dispatchOptions?: any): Promise<Tasks.Type>;
1579
1580 /**
1581 * * A specific, existing task can be deleted by making a DELETE request on the
1582 * * URL for that task. Deleted tasks go into the "trash" of the user making
1583 * * the delete request. Tasks can be recovered from the trash within a period
1584 * * of 30 days; afterward they are completely removed from the system.
1585 * *
1586 * * Returns an empty data record.
1587 * * @param {Number} task The task to delete.
1588 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1589 * * @return {Promise} The response from the API
1590 * @param task
1591 * @param dispatchOptions?
1592 * @return
1593 */
1594 delete(task: string | number, dispatchOptions?: any): Promise<void>;
1595
1596 /**
1597 * * Returns the compact task records for all tasks within the given project,
1598 * * ordered by their priority within the project.
1599 * * @param {Number} projectId The project in which to search for tasks.
1600 * * @param {Object} [params] Parameters for the request
1601 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1602 * * @return {Promise} The response from the API
1603 * @param projectId
1604 * @param params?
1605 * @param dispatchOptions?
1606 * @return
1607 */
1608 findByProject(projectId: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tasks.Type>>;
1609
1610 /**
1611 * * Returns the compact task records for all tasks with the given tag.
1612 * * @param {Number} tag The tag in which to search for tasks.
1613 * * @param {Object} [params] Parameters for the request
1614 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1615 * * @return {Promise} The response from the API
1616 * @param tag
1617 * @param params?
1618 * @param dispatchOptions?
1619 * @return
1620 */
1621 findByTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tasks.Type>>;
1622
1623 /**
1624 * * Returns the compact task records for some filtered set of tasks. Use one
1625 * * or more of the parameters provided to filter the tasks returned.
1626 * * @param {Object} [params] Parameters for the request
1627 * * @param {Number} [params.assignee] The assignee to filter tasks on.
1628 * * @param {Number} [params.workspace] The workspace or organization to filter tasks on.
1629 * * @param {Number} [params.completed_since] Only return tasks that are either incomplete or that have been
1630 * * completed since this time.
1631 * * @param {Number} [params.modified_since] Only return tasks that have been modified since the given time.
1632 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1633 * * @return {Promise} The response from the API
1634 * @param params?
1635 * @param dispatchOptions?
1636 * @return
1637 */
1638 findAll(params?: Tasks.FindAllParams, dispatchOptions?: any): Promise<ResourceList<Tasks.Type>>;
1639
1640 /**
1641 * * Adds each of the specified followers to the task, if they are not already
1642 * * following. Returns the complete, updated record for the affected task.
1643 * * @param {Number} task The task to add followers to.
1644 * * @param {Object} data Data for the request
1645 * * @param {Array} data.followers An array of followers to add to the task.
1646 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1647 * * @return {Promise} The response from the API
1648 * @param task
1649 * @param data
1650 * @param dispatchOptions?
1651 * @return
1652 */
1653 addFollowers(task: string | number, data: Tasks.FollowersParams, dispatchOptions?: any): Promise<Tasks.Type>;
1654
1655 /**
1656 * * Removes each of the specified followers from the task if they are
1657 * * following. Returns the complete, updated record for the affected task.
1658 * * @param {Number} task The task to remove followers from.
1659 * * @param {Object} data Data for the request
1660 * * @param {Array} data.followers An array of followers to remove from the task.
1661 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1662 * * @return {Promise} The response from the API
1663 * @param task
1664 * @param data
1665 * @param dispatchOptions?
1666 * @return
1667 */
1668 removeFollowers(task: string | number, data: Tasks.FollowersParams, dispatchOptions?: any): Promise<Tasks.Type>;
1669
1670 /**
1671 * * Returns a compact representation of all of the projects the task is in.
1672 * * @param {Number} task The task to get projects on.
1673 * * @param {Object} [params] Parameters for the request
1674 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1675 * * @return {Promise} The response from the API
1676 * @param task
1677 * @param params?
1678 * @param dispatchOptions?
1679 * @return
1680 */
1681 projects(task: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Projects.Type>>;
1682
1683 /**
1684 * * Adds the task to the specified project, in the optional location
1685 * * specified. If no location arguments are given, the task will be added to
1686 * * the beginning of the project.
1687 * *
1688 * * `addProject` can also be used to reorder a task within a project that
1689 * * already contains it.
1690 * *
1691 * * Returns an empty data block.
1692 * * @param {Number} task The task to add to a project.
1693 * * @param {Object} data Data for the request
1694 * * @param {Number} data.project The project to add the task to.
1695 * * @param {Number} [data.insertAfter] A task in the project to insert the task after, or `null` to
1696 * * insert at the beginning of the list.
1697 * * @param {Number} [data.insertBefore] A task in the project to insert the task before, or `null` to
1698 * * insert at the end of the list.
1699 * * @param {Number} [data.section] A section in the project to insert the task into. The task will be
1700 * * inserted at the top of the section.
1701 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1702 * * @return {Promise} The response from the API
1703 * @param task
1704 * @param data
1705 * @param dispatchOptions?
1706 * @return
1707 */
1708 addProject(task: string | number, data: Tasks.AddProjectParams, dispatchOptions?: any): Promise<{}>;
1709
1710 /**
1711 * * Removes the task from the specified project. The task will still exist
1712 * * in the system, but it will not be in the project anymore.
1713 * *
1714 * * Returns an empty data block.
1715 * * @param {Number} task The task to remove from a project.
1716 * * @param {Object} data Data for the request
1717 * * @param {Number} data.project The project to remove the task from.
1718 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1719 * * @return {Promise} The response from the API
1720 * @param task
1721 * @param data
1722 * @param dispatchOptions?
1723 * @return
1724 */
1725 removeProject(task: string | number, data: Tasks.RemoveProjectParams, dispatchOptions?: any): Promise<{}>;
1726
1727 /**
1728 * * Returns a compact representation of all of the tags the task has.
1729 * * @param {Number} task The task to get tags on.
1730 * * @param {Object} [params] Parameters for the request
1731 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1732 * * @return {Promise} The response from the API
1733 * @param task
1734 * @param params?
1735 * @param dispatchOptions?
1736 * @return
1737 */
1738 tags(task: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tags.Type>>;
1739
1740 /**
1741 * * Adds a tag to a task. Returns an empty data block.
1742 * * @param {Number} task The task to add a tag to.
1743 * * @param {Object} data Data for the request
1744 * * @param {Number} data.tag The tag to add to the task.
1745 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1746 * * @return {Promise} The response from the API
1747 * @param task
1748 * @param data
1749 * @param dispatchOptions?
1750 * @return
1751 */
1752 addTag(task: string | number, data: Tasks.TagParams, dispatchOptions?: any): Promise<{}>;
1753
1754 /**
1755 * * Removes a tag from the task. Returns an empty data block.
1756 * * @param {Number} task The task to remove a tag from.
1757 * * @param {Object} data Data for the request
1758 * * @param {String} data.tag The tag to remove from the task.
1759 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1760 * * @return {Promise} The response from the API
1761 * @param task
1762 * @param data
1763 * @param dispatchOptions?
1764 * @return
1765 */
1766 removeTag(task: string | number, data: Tasks.TagParams, dispatchOptions?: any): Promise<{}>;
1767
1768 /**
1769 * * Returns a compact representation of all of the subtasks of a task.
1770 * * @param {Number} task The task to get the subtasks of.
1771 * * @param {Object} [params] Parameters for the request
1772 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1773 * * @return {Promise} The response from the API
1774 * @param task
1775 * @param params?
1776 * @param dispatchOptions?
1777 * @return
1778 */
1779 subtasks(task: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Tasks.Type>>;
1780
1781 /**
1782 * * Creates a new subtask and adds it to the parent task. Returns the full record
1783 * * for the newly created subtask.
1784 * * @param {Number} task The task to add a subtask to.
1785 * * @param {Object} data Data for the request
1786 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1787 * * @return {Promise} The response from the API
1788 * @param task
1789 * @param data
1790 * @param dispatchOptions?
1791 * @return
1792 */
1793 addSubtask(task: string | number, data: Tasks.CreateParams, dispatchOptions?: any): Promise<Tasks.Type>;
1794
1795 /**
1796 * * Returns a compact representation of all of the stories on the task.
1797 * * @param {Number} task The task containing the stories to get.
1798 * * @param {Object} [params] Parameters for the request
1799 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1800 * * @return {Promise} The response from the API
1801 * @param task
1802 * @param params?
1803 * @param dispatchOptions?
1804 * @return
1805 */
1806 stories(task: string | number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Stories.Type>>;
1807
1808 /**
1809 * * Adds a comment to a task. The comment will be authored by the
1810 * * currently authenticated user, and timestamped when the server receives
1811 * * the request.
1812 * *
1813 * * Returns the full record for the new story added to the task.
1814 * * @param {Number} task Globally unique identifier for the task.
1815 * * @param {Object} data Data for the request
1816 * * @param {String} data.text The plain text of the comment to add.
1817 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1818 * * @return {Promise} The response from the API
1819 * @param task
1820 * @param data
1821 * @param dispatchOptions?
1822 * @return
1823 */
1824 addComment(task: string | number, data: Tasks.CommentParams, dispatchOptions?: any): Promise<Stories.Type>;
1825 }
1826
1827 namespace Sections {
1828 interface Type extends Resource {
1829 created_at: string;
1830 }
1831 }
1832
1833 interface TeamsStatic {
1834 /**
1835 * @param dispatcher
1836 */
1837 new (dispatcher: Dispatcher): Teams;
1838 }
1839
1840 namespace Teams {
1841 interface Type extends Resource {
1842 organization: Resource;
1843 }
1844 }
1845
1846 var Teams: TeamsStatic;
1847
1848 /**
1849 * A _team_ is used to group related projects and people together within an
1850 * organization. Each project in an organization is associated with a team.
1851 * @class
1852 * @param {Dispatcher} dispatcher The API dispatcher
1853 */
1854 interface Teams extends Resource {
1855 /**
1856 * * Returns the full record for a single team.
1857 * * @param {Number} team Globally unique identifier for the team.
1858 * * @param {Object} [params] Parameters for the request
1859 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1860 * * @return {Promise} The requested resource
1861 * @param team
1862 * @param params?
1863 * @param dispatchOptions?
1864 * @return
1865 */
1866 findById(team: number, params?: Params, dispatchOptions?: any): Promise<Teams.Type>;
1867
1868 /**
1869 * * Returns the compact records for all teams in the organization visible to
1870 * * the authorized user.
1871 * * @param {Number} organization Globally unique identifier for the workspace or organization.
1872 * * @param {Object} [params] Parameters for the request
1873 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1874 * * @return {Promise} The response from the API
1875 * @param organization
1876 * @param params?
1877 * @param dispatchOptions?
1878 * @return
1879 */
1880 findByOrganization(organization: number, params?: Params, dispatchOptions?: any): Promise<SimpleResourceList>;
1881
1882 /**
1883 * * Returns the compact records for all users that are members of the team.
1884 * * @param {Number} team Globally unique identifier for the team.
1885 * * @param {Object} [params] Parameters for the request
1886 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1887 * * @return {Promise} The response from the API
1888 * @param team
1889 * @param params?
1890 * @param dispatchOptions?
1891 * @return
1892 */
1893 users(team: number, params?: Params, dispatchOptions?: any): Promise<SimpleResourceList>;
1894
1895 /**
1896 * * The user making this call must be a member of the team in order to add others.
1897 * * The user to add must exist in the same organization as the team in order to be added.
1898 * * The user to add can be referenced by their globally unique user ID or their email address.
1899 * * Returns the full user record for the added user.
1900 * * @param {Number} team Globally unique identifier for the team.
1901 * * @param {Object} data Data for the request
1902 * * @param {Number|String} data.user An identifier for the user. Can be one of an email address,
1903 * * the globally unique identifier for the user, or the keyword `me`
1904 * * to indicate the current user making the request.
1905 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1906 * * @return {Promise} The response from the API
1907 * @param team
1908 * @param data
1909 * @param dispatchOptions?
1910 * @return
1911 */
1912 addUser(team: number, data: UserParams, dispatchOptions?: any): Promise<any>;
1913
1914 /**
1915 * * The user to remove can be referenced by their globally unique user ID or their email address.
1916 * * Removes the user from the specified team. Returns an empty data record.
1917 * * @param {Number} team Globally unique identifier for the team.
1918 * * @param {Object} data Data for the request
1919 * * @param {Number|String} data.user An identifier for the user. Can be one of an email address,
1920 * * the globally unique identifier for the user, or the keyword `me`
1921 * * to indicate the current user making the request.
1922 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1923 * * @return {Promise} The response from the API
1924 * @param team
1925 * @param data
1926 * @param dispatchOptions?
1927 * @return
1928 */
1929 removeUser(team: number, data: UserParams, dispatchOptions?: any): Promise<any>;
1930 }
1931
1932 interface UsersStatic {
1933 /**
1934 * @param dispatcher
1935 */
1936 new (dispatcher: Dispatcher): Users;
1937 }
1938
1939 namespace Users {
1940 interface FindAllParams extends PaginationParams {
1941 workspace: number;
1942 }
1943
1944 interface Type extends Resource {
1945 email: string;
1946 workspaces: Resource[];
1947 photo: { [key: string]: string };
1948 }
1949 }
1950
1951 var Users: UsersStatic;
1952
1953 /**
1954 * A _user_ object represents an account in Asana that can be given access to
1955 * various workspaces, projects, and tasks.
1956 *
1957 * Like other objects in the system, users are referred to by numerical IDs.
1958 * However, the special string identifier `me` can be used anywhere
1959 * a user ID is accepted, to refer to the current authenticated user.
1960 * @class
1961 * @param {Dispatcher} dispatcher The API dispatcher
1962 */
1963 interface Users extends Resource {
1964 /**
1965 * * Returns the full user record for the currently authenticated user.
1966 * * @param {Object} [params] Parameters for the request
1967 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1968 * * @return {Promise} The requested resource
1969 * @param params?
1970 * @param dispatchOptions?
1971 * @return
1972 */
1973 me(params?: Params, dispatchOptions?: any): Promise<Users.Type>;
1974
1975 /**
1976 * * Returns the full user record for the single user with the provided ID.
1977 * * @param {Number|String} user An identifier for the user. Can be one of an email address,
1978 * * the globally unique identifier for the user, or the keyword `me`
1979 * * to indicate the current user making the request.
1980 * * @param {Object} [params] Parameters for the request
1981 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1982 * * @return {Promise} The requested resource
1983 * @param user
1984 * @param params?
1985 * @param dispatchOptions?
1986 * @return
1987 */
1988 findById(user: string | number, params?: Params, dispatchOptions?: any): Promise<Users.Type>;
1989
1990 /**
1991 * * Returns the user records for all users in the specified workspace or
1992 * * organization.
1993 * * @param {Number} workspace The workspace in which to get users.
1994 * * @param {Object} [params] Parameters for the request
1995 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
1996 * * @return {Promise} The response from the API
1997 * @param workspace
1998 * @param params?
1999 * @param dispatchOptions?
2000 * @return
2001 */
2002 findByWorkspace(workspace: number, params?: Params, dispatchOptions?: any): Promise<ResourceList<Users.Type>>;
2003
2004 /**
2005 * * Returns the user records for all users in all workspaces and organizations
2006 * * accessible to the authenticated user. Accepts an optional workspace ID
2007 * * parameter.
2008 * * @param {Object} [params] Parameters for the request
2009 * * @param {Number} [params.workspace] The workspace or organization to filter users on.
2010 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2011 * * @return {Promise} The response from the API
2012 * @param params
2013 * @param dispatchOptions?
2014 * @return
2015 */
2016 findAll(params: Users.FindAllParams, dispatchOptions?: any): Promise<SimpleResourceList>;
2017 }
2018
2019 /**
2020 * **Webhooks are currently in BETA - The information here may change.**
2021 *
2022 * Webhooks allow an application to be notified of changes. This is in addition
2023 * to the ability to fetch those changes directly as
2024 * [Events](/developers/api-reference/events) - in fact, Webhooks are just a way
2025 * to receive Events via HTTP POST at the time they occur instead of polling for
2026 * them. For services accessible via HTTP this is often vastly more convenient,
2027 * and if events are not too frequent can be significantly more efficient.
2028 *
2029 * In both cases, however, changes are represented as Event objects - refer to
2030 * the [Events documentation](/developers/api-reference/events) for more
2031 * information on what data these events contain.
2032 *
2033 * **NOTE:** While Webhooks send arrays of Event objects to their target, the
2034 * Event objects themselves contain *only IDs*, rather than the actual resource
2035 * they are referencing. So while a normal event you receive via GET /events
2036 * would look like this:
2037 *
2038 * {\
2039 * "resource": {\
2040 * "id": 1337,\
2041 * "name": "My Task"\
2042 * },\
2043 * "parent": null,\
2044 * "created_at": "2013-08-21T18:20:37.972Z",\
2045 * "user": {\
2046 * "id": 1123,\
2047 * "name": "Tom Bizarro"\
2048 * },\
2049 * "action": "changed",\
2050 * "type": "task"\
2051 * }
2052 *
2053 * In a Webhook payload you would instead receive this:
2054 *
2055 * {\
2056 * "resource": 1337,\
2057 * "parent": null,\
2058 * "created_at": "2013-08-21T18:20:37.972Z",\
2059 * "user": 1123,\
2060 * "action": "changed",\
2061 * "type": "task"\
2062 * }
2063 *
2064 * Webhooks themselves contain only the information necessary to deliver the
2065 * events to the desired target as they are generated.
2066 * @class
2067 * @param {Dispatcher} dispatcher The API dispatcher
2068 */
2069 class Webhooks extends Resource {
2070 /**
2071 * @param dispatcher
2072 */
2073 constructor(dispatcher: Dispatcher);
2074
2075 /**
2076 * * Establishing a webhook is a two-part process. First, a simple HTTP POST
2077 * * similar to any other resource creation. Since you could have multiple
2078 * * webhooks we recommend specifying a unique local id for each target.
2079 * *
2080 * * Next comes the confirmation handshake. When a webhook is created, we will
2081 * * send a test POST to the `target` with an `X-Hook-Secret` header as
2082 * * described in the
2083 * * [Resthooks Security documentation](http://resthooks.org/docs/security/).
2084 * * The target must respond with a `200 OK` and a matching `X-Hook-Secret`
2085 * * header to confirm that this webhook subscription is indeed expected.
2086 * *
2087 * * If you do not acknowledge the webhook's confirmation handshake it will
2088 * * fail to setup, and you will receive an error in response to your attempt
2089 * * to create it. This means you need to be able to receive and complete the
2090 * * webhook *while* the POST request is in-flight.
2091 * * @param {Number} resource A resource ID to subscribe to. The resource can be a task or project.
2092 * * @param {String} target The URL to receive the HTTP POST.
2093 * * @param {Object} data Data for the request
2094 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2095 * * @return {Promise} The response from the API
2096 * @param resource
2097 * @param target
2098 * @param data
2099 * @param dispatchOptions?
2100 * @return
2101 */
2102 create(resource: number, target: string, data: any, dispatchOptions?: any): Promise<any>;
2103
2104 /**
2105 * * Returns the compact representation of all webhooks your app has
2106 * * registered for the authenticated user in the given workspace.
2107 * * @param {Number} workspace The workspace to query for webhooks in.
2108 * * @param {Object} [params] Parameters for the request
2109 * * @param {Number} [params.resource] Only return webhooks for the given resource.
2110 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2111 * * @return {Promise} The response from the API
2112 * @param workspace
2113 * @param params?
2114 * @param dispatchOptions?
2115 * @return
2116 */
2117 getAll(workspace: number, params?: any, dispatchOptions?: any): Promise<any>;
2118
2119 /**
2120 * * Returns the full record for the given webhook.
2121 * * @param {String} webhook The webhook to get.
2122 * * @param {Object} [params] Parameters for the request
2123 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2124 * * @return {Promise} The requested resource
2125 * @param webhook
2126 * @param params?
2127 * @param dispatchOptions?
2128 * @return
2129 */
2130 getById(webhook: string, params?: any, dispatchOptions?: any): Promise<any>;
2131
2132 /**
2133 * * This method permanently removes a webhook. Note that it may be possible
2134 * * to receive a request that was already in flight after deleting the
2135 * * webhook, but no further requests will be issued.
2136 * * @param {String} webhook The webhook to delete.
2137 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2138 * * @return {Promise} The response from the API
2139 * @param webhook
2140 * @param dispatchOptions?
2141 * @return
2142 */
2143 deleteById(webhook: string, dispatchOptions?: any): Promise<any>;
2144 }
2145
2146 interface WorkspacesStatic {
2147 /**
2148 * @param dispatcher
2149 */
2150 new (dispatcher: Dispatcher): Workspaces;
2151 }
2152
2153 namespace Workspaces {
2154 interface ShortType extends Resource {
2155 id_organization?: boolean;
2156 }
2157
2158 interface Type extends Resource {
2159 id_organization: boolean;
2160 email_domains: string[];
2161 }
2162
2163 interface TypeaheadParams {
2164 type: string;
2165 query?: string;
2166 count?: number;
2167 }
2168 }
2169
2170 var Workspaces: WorkspacesStatic;
2171
2172 /**
2173 * A _workspace_ is the highest-level organizational unit in Asana. All projects
2174 * and tasks have an associated workspace.
2175 *
2176 * An _organization_ is a special kind of workspace that represents a company.
2177 * In an organization, you can group your projects into teams. You can read
2178 * more about how organizations work on the Asana Guide.
2179 * To tell if your workspace is an organization or not, check its
2180 * `is_organization` property.
2181 *
2182 * Over time, we intend to migrate most workspaces into organizations and to
2183 * release more organization-specific functionality. We may eventually deprecate
2184 * using workspace-based APIs for organizations. Currently, and until after
2185 * some reasonable grace period following any further announcements, you can
2186 * still reference organizations in any `workspace` parameter.
2187 * @class
2188 * @param {Dispatcher} dispatcher The API dispatcher
2189 */
2190 interface Workspaces extends Resource {
2191 /**
2192 * * Returns the full workspace record for a single workspace.
2193 * * @param {Number} workspace Globally unique identifier for the workspace or organization.
2194 * * @param {Object} [params] Parameters for the request
2195 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2196 * * @return {Promise} The requested resource
2197 * @param workspace
2198 * @param params?
2199 * @param dispatchOptions?
2200 * @return
2201 */
2202 findById(workspace: number, params?: Params, dispatchOptions?: any): Promise<Workspaces.Type>;
2203
2204 /**
2205 * * Returns the compact records for all workspaces visible to the authorized user.
2206 * * @param {Object} [params] Parameters for the request
2207 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2208 * * @return {Promise} The response from the API
2209 * @param params?
2210 * @param dispatchOptions?
2211 * @return
2212 */
2213 findAll(params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Workspaces.ShortType>>;
2214
2215 /**
2216 * * A specific, existing workspace can be updated by making a PUT request on
2217 * * the URL for that workspace. Only the fields provided in the data block
2218 * * will be updated; any unspecified fields will remain unchanged.
2219 * *
2220 * * Currently the only field that can be modified for a workspace is its `name`.
2221 * *
2222 * * Returns the complete, updated workspace record.
2223 * * @param {Number} workspace The workspace to update.
2224 * * @param {Object} data Data for the request
2225 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2226 * * @return {Promise} The response from the API
2227 * @param workspace
2228 * @param data
2229 * @param dispatchOptions?
2230 * @return
2231 */
2232 update(workspace: number, data: { name?: string }, dispatchOptions?: any): Promise<Workspaces.Type>;
2233
2234 /**
2235 * * Retrieves objects in the workspace based on an auto-completion/typeahead
2236 * * search algorithm. This feature is meant to provide results quickly, so do
2237 * * not rely on this API to provide extremely accurate search results. The
2238 * * result set is limited to a single page of results with a maximum size,
2239 * * so you won't be able to fetch large numbers of results.
2240 * * @param {Number} workspace The workspace to fetch objects from.
2241 * * @param {Object} [params] Parameters for the request
2242 * * @param {String} params.type The type of values the typeahead should return.
2243 * * Note that unlike in the names of endpoints, the types listed here are
2244 * * in singular form (e.g. `task`). Using multiple types is not yet supported.
2245 * * @param {String} [params.query] The string that will be used to search for relevant objects. If an
2246 * * empty string is passed in, the API will currently return an empty
2247 * * result set.
2248 * * @param {Number} [params.count] The number of results to return. The default is `20` if this
2249 * * parameter is omitted, with a minimum of `1` and a maximum of `100`.
2250 * * If there are fewer results found than requested, all will be returned.
2251 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2252 * * @return {Promise} The response from the API
2253 * @param workspace
2254 * @param params?
2255 * @param dispatchOptions?
2256 * @return
2257 */
2258 typeahead(workspace: number, params?: Workspaces.TypeaheadParams, dispatchOptions?: any): Promise<SimpleResourceList>;
2259
2260 /**
2261 * * The user can be referenced by their globally unique user ID or their email address.
2262 * * Returns the full user record for the invited user.
2263 * * @param {Number} workspace The workspace or organization to invite the user to.
2264 * * @param {Object} data Data for the request
2265 * * @param {Number|String} data.user An identifier for the user. Can be one of an email address,
2266 * * the globally unique identifier for the user, or the keyword `me`
2267 * * to indicate the current user making the request.
2268 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2269 * * @return {Promise} The response from the API
2270 * @param workspace
2271 * @param data
2272 * @param dispatchOptions?
2273 * @return
2274 */
2275 addUser(workspace: number, data: UserParams, dispatchOptions?: any): Promise<Users.Type>;
2276
2277 /**
2278 * * The user making this call must be an admin in the workspace.
2279 * * Returns an empty data record.
2280 * * @param {Number} workspace The workspace or organization to invite the user to.
2281 * * @param {Object} data Data for the request
2282 * * @param {Number|String} data.user An identifier for the user. Can be one of an email address,
2283 * * the globally unique identifier for the user, or the keyword `me`
2284 * * to indicate the current user making the request.
2285 * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
2286 * * @return {Promise} The response from the API
2287 * @param workspace
2288 * @param data
2289 * @param dispatchOptions?
2290 * @return
2291 */
2292 removeUser(workspace: number, data: UserParams, dispatchOptions?: any): Promise<any>;
2293 }
2294
2295 interface ResourceStatic {
2296 /**
2297 * @param dispatcher
2298 */
2299 new (dispatcher: Dispatcher): Resource;
2300
2301 /**
2302 * @type {number} Default number of items to get per page.
2303 */
2304 DEFAULT_PAGE_LIMIT: number;
2305
2306 /**
2307 * Helper method that dispatches a GET request to the API, where the expected
2308 * result is a collection.
2309 * @param {Dispatcher} dispatcher
2310 * @param {String} path The path of the API
2311 * @param {Object} [query] The query params
2312 * @param {Object} [dispatchOptions] Options for handling the request and
2313 * response. See `Dispatcher.dispatch`.
2314 * @return {Promise<SimpleResourceList>} The Collection response for the request
2315 * @param dispatcher
2316 * @param path
2317 * @param query?
2318 * @param dispatchOptions?
2319 */
2320 getCollection(dispatcher: any, path: string, query?: any, dispatchOptions?: any): Promise<any>;
2321
2322 /**
2323 * Helper method for any request Promise from the Dispatcher, unwraps the `data`
2324 * value from the payload.
2325 * @param {Promise} promise A promise returned from a `Dispatcher` request.
2326 * @return {Promise} The `data` portion of the response payload.
2327 * @param promise
2328 * @return
2329 */
2330 unwrap(promise: any): Promise<any>;
2331 }
2332
2333 var Resource: ResourceStatic;
2334
2335 /**
2336 * Base class for a resource accessible via the API. Uses a `Dispatcher` to
2337 * access the resources.
2338 * @param {Dispatcher} dispatcher
2339 * @constructor
2340 */
2341 interface Resource {
2342 /**
2343 * Dispatches a GET request to the API, where the expected result is a
2344 * single resource.
2345 * @param {String} path The path of the API
2346 * @param {Object} [query] The query params
2347 * @param {Object} [dispatchOptions] Options for handling the request and
2348 * response. See `Dispatcher.dispatch`.
2349 * @return {Promise} The response for the request
2350 * @param path
2351 * @param query?
2352 * @param dispatchOptions?
2353 * @return
2354 */
2355 dispatchGet(path: string, query?: any, dispatchOptions?: any): Promise<any>;
2356
2357 /**
2358 * Dispatches a GET request to the API, where the expected result is a
2359 * collection.
2360 * @param {String} path The path of the API
2361 * @param {Object} [query] The query params
2362 * @param {Object} [dispatchOptions] Options for handling the request and
2363 * response. See `Dispatcher.dispatch`.
2364 * @return {Promise} The response for the request
2365 * @param path
2366 * @param query?
2367 * @param dispatchOptions?
2368 * @return
2369 */
2370 dispatchGetCollection(path: string, query?: any, dispatchOptions?: any): Promise<any>;
2371
2372 /**
2373 * Dispatches a POST request to the API, where the expected response is a
2374 * single resource.
2375 * @param {String} path The path of the API
2376 * @param {Object} [query] The query params
2377 * @param {Object} [dispatchOptions] Options for handling the request and
2378 * response. See `Dispatcher.dispatch`.
2379 * @return {Promise} The response for the request
2380 * @param path
2381 * @param query?
2382 * @param dispatchOptions?
2383 * @return
2384 */
2385 dispatchPost(path: string, query?: any, dispatchOptions?: any): Promise<any>;
2386
2387 /**
2388 * Dispatches a POST request to the API, where the expected response is a
2389 * single resource.
2390 * @param {String} path The path of the API
2391 * @param {Object} [query] The query params
2392 * @param {Object} [dispatchOptions] Options for handling the request and
2393 * response. See `Dispatcher.dispatch`.
2394 * @return {Promise} The response for the request
2395 * @param path
2396 * @param query?
2397 * @param dispatchOptions?
2398 * @return
2399 */
2400 dispatchPut(path: string, query?: any, dispatchOptions?: any): Promise<any>;
2401
2402 /**
2403 * Dispatches a DELETE request to the API. The expected response is an
2404 * empty resource.
2405 * @param {String} path The path of the API
2406 * @param {Object} [dispatchOptions] Options for handling the request and
2407 * response. See `Dispatcher.dispatch`.
2408 * @return {Promise} The response for the request
2409 * @param path
2410 * @param dispatchOptions?
2411 * @return
2412 */
2413 dispatchDelete(path: string, dispatchOptions?: any): Promise<any>;
2414 }
2415
2416 interface ResourceList<T extends Resource> {
2417 /**
2418 * Get the next page of results in a collection.
2419 *
2420 * @returns {Promise<Collection?>} Resolves to either a collection representing
2421 * the next page of results, or null if no more pages.
2422 */
2423 nextPage(): Promise<ResourceList<T> | null>
2424 data: T[];
2425 _response: {
2426 data: T[];
2427 next_page?: NextPage;
2428 };
2429 _dispatcher: {
2430 authenticator: {
2431 apiKey: string;
2432 };
2433 asanaBaseUrl: string;
2434 retryOnRateLimit: boolean;
2435 requestTimeout: number;
2436 _cachedVersionInfo: VersionInfo;
2437 }
2438 }
2439
2440 type SimpleResourceList = ResourceList<Resource>;
2441
2442 interface NextPage {
2443 offset: string;
2444 uri: string;
2445 path: string;
2446 }
2447
2448 interface VersionInfo {
2449 version: string;
2450 language: string;
2451 language_version: string;
2452 os: string;
2453 os_version: string;
2454 }
2455
2456 interface Resource {
2457 id: number;
2458 name: string;
2459 gid: string;
2460 }
2461
2462 interface PaginationParams extends Params {
2463 limit?: number;
2464 offset?: string;
2465 }
2466
2467 interface Params {
2468 opt_fields?: string;
2469 opt_expand?: string;
2470 }
2471
2472 interface UserParams {
2473 user: string | number;
2474 }
2475
2476 interface Membership {
2477 project: Resource;
2478 section: Resource;
2479 }
2480
2481 interface Assignee extends Resource {
2482 email?: string;
2483 workspaces?: Resource[];
2484 photo?: { [key: string]: string };
2485 }
2486 }
2487
2488 var VERSION: string;
2489}
2490
2491export = asana;