microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
86466695ed3443c9a6a1facdfd9bce89c668afbf

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

lib/app-center-node-client/src/account/operations/appInvitations.js

1444lines · modecode

1/*
2 * Code generated by Microsoft (R) AutoRest Code Generator.
3 * Changes may cause incorrect behavior and will be lost if the code is
4 * regenerated.
5 */
6
7'use strict';
8
9const msRest = require('ms-rest');
10const WebResource = msRest.WebResource;
11
12/**
13 * Invites a new or existing user to an app
14 *
15 * @param {string} appName The name of the application
16 *
17 * @param {string} ownerName The name of the owner
18 *
19 * @param {object} [options] Optional Parameters.
20 *
21 * @param {object} [options.userEmail] The email of the user to invite
22 *
23 * @param {string} options.userEmail.userEmail The user's email address'
24 *
25 * @param {object} [options.customHeaders] Headers that will be added to the
26 * request
27 *
28 * @param {function} callback - The callback.
29 *
30 * @returns {function} callback(err, result, request, response)
31 *
32 * {Error} err - The Error object if an error occurred, null otherwise.
33 *
34 * {null} [result] - The deserialized result object if an error did not occur.
35 *
36 * {object} [request] - The HTTP Request object if an error did not occur.
37 *
38 * {stream} [response] - The HTTP Response stream if an error did not occur.
39 */
40function _create(appName, ownerName, options, callback) {
41 /* jshint validthis: true */
42 let client = this.client;
43 if(!callback && typeof options === 'function') {
44 callback = options;
45 options = null;
46 }
47 if (!callback) {
48 throw new Error('callback cannot be null.');
49 }
50 let userEmail = (options && options.userEmail !== undefined) ? options.userEmail : undefined;
51 // Validate
52 try {
53 if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') {
54 throw new Error('appName cannot be null or undefined and it must be of type string.');
55 }
56 if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') {
57 throw new Error('ownerName cannot be null or undefined and it must be of type string.');
58 }
59 } catch (error) {
60 return callback(error);
61 }
62
63 // Construct URL
64 let baseUrl = this.client.baseUri;
65 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/invitations';
66 requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName));
67 requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName));
68
69 // Create HTTP transport objects
70 let httpRequest = new WebResource();
71 httpRequest.method = 'POST';
72 httpRequest.url = requestUrl;
73 httpRequest.headers = {};
74 // Set Headers
75 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
76 if(options) {
77 for(let headerName in options['customHeaders']) {
78 if (options['customHeaders'].hasOwnProperty(headerName)) {
79 httpRequest.headers[headerName] = options['customHeaders'][headerName];
80 }
81 }
82 }
83 // Serialize Request
84 let requestContent = null;
85 let requestModel = null;
86 try {
87 if (userEmail !== null && userEmail !== undefined) {
88 let requestModelMapper = new client.models['UserEmailRequest']().mapper();
89 requestModel = client.serialize(requestModelMapper, userEmail, 'userEmail');
90 requestContent = JSON.stringify(requestModel);
91 }
92 } catch (error) {
93 let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
94 `payload - ${JSON.stringify(userEmail, null, 2)}.`);
95 return callback(serializationError);
96 }
97 httpRequest.body = requestContent;
98 // Send Request
99 return client.pipeline(httpRequest, (err, response, responseBody) => {
100 if (err) {
101 return callback(err);
102 }
103 let statusCode = response.statusCode;
104 if (statusCode < 200 || statusCode >= 300) {
105 let error = new Error(responseBody);
106 error.statusCode = response.statusCode;
107 error.request = msRest.stripRequest(httpRequest);
108 error.response = msRest.stripResponse(response);
109 if (responseBody === '') responseBody = null;
110 let parsedErrorResponse;
111 try {
112 parsedErrorResponse = JSON.parse(responseBody);
113 if (parsedErrorResponse) {
114 let internalError = null;
115 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
116 error.code = internalError ? internalError.code : parsedErrorResponse.code;
117 error.message = internalError ? internalError.message : parsedErrorResponse.message;
118 }
119 } catch (defaultError) {
120 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
121 `- "${responseBody}" for the default response.`;
122 return callback(error);
123 }
124 return callback(error);
125 }
126 // Create Result
127 let result = null;
128 if (responseBody === '') responseBody = null;
129
130 return callback(null, result, httpRequest, response);
131 });
132}
133
134/**
135 * Gets the pending invitations for the app
136 *
137 * @param {string} appName The name of the application
138 *
139 * @param {string} ownerName The name of the owner
140 *
141 * @param {object} [options] Optional Parameters.
142 *
143 * @param {object} [options.customHeaders] Headers that will be added to the
144 * request
145 *
146 * @param {function} callback - The callback.
147 *
148 * @returns {function} callback(err, result, request, response)
149 *
150 * {Error} err - The Error object if an error occurred, null otherwise.
151 *
152 * {object} [result] - The deserialized result object if an error did not occur.
153 * See {@link AppInvitationDetailResponse} for more
154 * information.
155 *
156 * {object} [request] - The HTTP Request object if an error did not occur.
157 *
158 * {stream} [response] - The HTTP Response stream if an error did not occur.
159 */
160function _list(appName, ownerName, options, callback) {
161 /* jshint validthis: true */
162 let client = this.client;
163 if(!callback && typeof options === 'function') {
164 callback = options;
165 options = null;
166 }
167 if (!callback) {
168 throw new Error('callback cannot be null.');
169 }
170 // Validate
171 try {
172 if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') {
173 throw new Error('appName cannot be null or undefined and it must be of type string.');
174 }
175 if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') {
176 throw new Error('ownerName cannot be null or undefined and it must be of type string.');
177 }
178 } catch (error) {
179 return callback(error);
180 }
181
182 // Construct URL
183 let baseUrl = this.client.baseUri;
184 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/invitations';
185 requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName));
186 requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName));
187
188 // Create HTTP transport objects
189 let httpRequest = new WebResource();
190 httpRequest.method = 'GET';
191 httpRequest.url = requestUrl;
192 httpRequest.headers = {};
193 // Set Headers
194 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
195 if(options) {
196 for(let headerName in options['customHeaders']) {
197 if (options['customHeaders'].hasOwnProperty(headerName)) {
198 httpRequest.headers[headerName] = options['customHeaders'][headerName];
199 }
200 }
201 }
202 httpRequest.body = null;
203 // Send Request
204 return client.pipeline(httpRequest, (err, response, responseBody) => {
205 if (err) {
206 return callback(err);
207 }
208 let statusCode = response.statusCode;
209 if (statusCode !== 200) {
210 let error = new Error(responseBody);
211 error.statusCode = response.statusCode;
212 error.request = msRest.stripRequest(httpRequest);
213 error.response = msRest.stripResponse(response);
214 if (responseBody === '') responseBody = null;
215 let parsedErrorResponse;
216 try {
217 parsedErrorResponse = JSON.parse(responseBody);
218 if (parsedErrorResponse) {
219 let internalError = null;
220 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
221 error.code = internalError ? internalError.code : parsedErrorResponse.code;
222 error.message = internalError ? internalError.message : parsedErrorResponse.message;
223 }
224 } catch (defaultError) {
225 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
226 `- "${responseBody}" for the default response.`;
227 return callback(error);
228 }
229 return callback(error);
230 }
231 // Create Result
232 let result = null;
233 if (responseBody === '') responseBody = null;
234 // Deserialize Response
235 if (statusCode === 200) {
236 let parsedResponse = null;
237 try {
238 parsedResponse = JSON.parse(responseBody);
239 result = JSON.parse(responseBody);
240 if (parsedResponse !== null && parsedResponse !== undefined) {
241 let resultMapper = new client.models['AppInvitationDetailResponse']().mapper();
242 result = client.deserialize(resultMapper, parsedResponse, 'result');
243 }
244 } catch (error) {
245 let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
246 deserializationError.request = msRest.stripRequest(httpRequest);
247 deserializationError.response = msRest.stripResponse(response);
248 return callback(deserializationError);
249 }
250 }
251
252 return callback(null, result, httpRequest, response);
253 });
254}
255
256/**
257 * Invites a new or existing user to an app
258 *
259 * @param {string} appName The name of the application
260 *
261 * @param {string} ownerName The name of the owner
262 *
263 * @param {string} userEmail The email of the user to invite
264 *
265 * @param {object} [options] Optional Parameters.
266 *
267 * @param {object} [options.customHeaders] Headers that will be added to the
268 * request
269 *
270 * @param {function} callback - The callback.
271 *
272 * @returns {function} callback(err, result, request, response)
273 *
274 * {Error} err - The Error object if an error occurred, null otherwise.
275 *
276 * {null} [result] - The deserialized result object if an error did not occur.
277 *
278 * {object} [request] - The HTTP Request object if an error did not occur.
279 *
280 * {stream} [response] - The HTTP Response stream if an error did not occur.
281 */
282function _createByEmail(appName, ownerName, userEmail, options, callback) {
283 /* jshint validthis: true */
284 let client = this.client;
285 if(!callback && typeof options === 'function') {
286 callback = options;
287 options = null;
288 }
289 if (!callback) {
290 throw new Error('callback cannot be null.');
291 }
292 // Validate
293 try {
294 if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') {
295 throw new Error('appName cannot be null or undefined and it must be of type string.');
296 }
297 if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') {
298 throw new Error('ownerName cannot be null or undefined and it must be of type string.');
299 }
300 if (userEmail === null || userEmail === undefined || typeof userEmail.valueOf() !== 'string') {
301 throw new Error('userEmail cannot be null or undefined and it must be of type string.');
302 }
303 } catch (error) {
304 return callback(error);
305 }
306
307 // Construct URL
308 let baseUrl = this.client.baseUri;
309 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/invitations/{user_email}';
310 requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName));
311 requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName));
312 requestUrl = requestUrl.replace('{user_email}', encodeURIComponent(userEmail));
313
314 // Create HTTP transport objects
315 let httpRequest = new WebResource();
316 httpRequest.method = 'POST';
317 httpRequest.url = requestUrl;
318 httpRequest.headers = {};
319 // Set Headers
320 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
321 if(options) {
322 for(let headerName in options['customHeaders']) {
323 if (options['customHeaders'].hasOwnProperty(headerName)) {
324 httpRequest.headers[headerName] = options['customHeaders'][headerName];
325 }
326 }
327 }
328 httpRequest.body = null;
329 // Send Request
330 return client.pipeline(httpRequest, (err, response, responseBody) => {
331 if (err) {
332 return callback(err);
333 }
334 let statusCode = response.statusCode;
335 if (statusCode < 200 || statusCode >= 300) {
336 let error = new Error(responseBody);
337 error.statusCode = response.statusCode;
338 error.request = msRest.stripRequest(httpRequest);
339 error.response = msRest.stripResponse(response);
340 if (responseBody === '') responseBody = null;
341 let parsedErrorResponse;
342 try {
343 parsedErrorResponse = JSON.parse(responseBody);
344 if (parsedErrorResponse) {
345 let internalError = null;
346 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
347 error.code = internalError ? internalError.code : parsedErrorResponse.code;
348 error.message = internalError ? internalError.message : parsedErrorResponse.message;
349 }
350 } catch (defaultError) {
351 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
352 `- "${responseBody}" for the default response.`;
353 return callback(error);
354 }
355 return callback(error);
356 }
357 // Create Result
358 let result = null;
359 if (responseBody === '') responseBody = null;
360
361 return callback(null, result, httpRequest, response);
362 });
363}
364
365/**
366 * Update pending invitation permission
367 *
368 * @param {string} appName The name of the application
369 *
370 * @param {string} ownerName The name of the owner
371 *
372 * @param {string} userEmail The email of the user to invite
373 *
374 * @param {object} [options] Optional Parameters.
375 *
376 * @param {object} [options.userInvitationPermissionsData] The value to update
377 * the user permission in the invite.
378 *
379 * @param {array} options.userInvitationPermissionsData.permissions The
380 * permissions the user has for the app in the invitation
381 *
382 * @param {object} [options.customHeaders] Headers that will be added to the
383 * request
384 *
385 * @param {function} callback - The callback.
386 *
387 * @returns {function} callback(err, result, request, response)
388 *
389 * {Error} err - The Error object if an error occurred, null otherwise.
390 *
391 * {null} [result] - The deserialized result object if an error did not occur.
392 *
393 * {object} [request] - The HTTP Request object if an error did not occur.
394 *
395 * {stream} [response] - The HTTP Response stream if an error did not occur.
396 */
397function _updatePermissions(appName, ownerName, userEmail, options, callback) {
398 /* jshint validthis: true */
399 let client = this.client;
400 if(!callback && typeof options === 'function') {
401 callback = options;
402 options = null;
403 }
404 if (!callback) {
405 throw new Error('callback cannot be null.');
406 }
407 let userInvitationPermissionsData = (options && options.userInvitationPermissionsData !== undefined) ? options.userInvitationPermissionsData : undefined;
408 // Validate
409 try {
410 if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') {
411 throw new Error('appName cannot be null or undefined and it must be of type string.');
412 }
413 if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') {
414 throw new Error('ownerName cannot be null or undefined and it must be of type string.');
415 }
416 if (userEmail === null || userEmail === undefined || typeof userEmail.valueOf() !== 'string') {
417 throw new Error('userEmail cannot be null or undefined and it must be of type string.');
418 }
419 } catch (error) {
420 return callback(error);
421 }
422
423 // Construct URL
424 let baseUrl = this.client.baseUri;
425 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/invitations/{user_email}';
426 requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName));
427 requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName));
428 requestUrl = requestUrl.replace('{user_email}', encodeURIComponent(userEmail));
429
430 // Create HTTP transport objects
431 let httpRequest = new WebResource();
432 httpRequest.method = 'PATCH';
433 httpRequest.url = requestUrl;
434 httpRequest.headers = {};
435 // Set Headers
436 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
437 if(options) {
438 for(let headerName in options['customHeaders']) {
439 if (options['customHeaders'].hasOwnProperty(headerName)) {
440 httpRequest.headers[headerName] = options['customHeaders'][headerName];
441 }
442 }
443 }
444 // Serialize Request
445 let requestContent = null;
446 let requestModel = null;
447 try {
448 if (userInvitationPermissionsData !== null && userInvitationPermissionsData !== undefined) {
449 let requestModelMapper = new client.models['UserInvitationPermissionsUpdateRequest']().mapper();
450 requestModel = client.serialize(requestModelMapper, userInvitationPermissionsData, 'userInvitationPermissionsData');
451 requestContent = JSON.stringify(requestModel);
452 }
453 } catch (error) {
454 let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
455 `payload - ${JSON.stringify(userInvitationPermissionsData, null, 2)}.`);
456 return callback(serializationError);
457 }
458 httpRequest.body = requestContent;
459 // Send Request
460 return client.pipeline(httpRequest, (err, response, responseBody) => {
461 if (err) {
462 return callback(err);
463 }
464 let statusCode = response.statusCode;
465 if (statusCode < 200 || statusCode >= 300) {
466 let error = new Error(responseBody);
467 error.statusCode = response.statusCode;
468 error.request = msRest.stripRequest(httpRequest);
469 error.response = msRest.stripResponse(response);
470 if (responseBody === '') responseBody = null;
471 let parsedErrorResponse;
472 try {
473 parsedErrorResponse = JSON.parse(responseBody);
474 if (parsedErrorResponse) {
475 let internalError = null;
476 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
477 error.code = internalError ? internalError.code : parsedErrorResponse.code;
478 error.message = internalError ? internalError.message : parsedErrorResponse.message;
479 }
480 } catch (defaultError) {
481 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
482 `- "${responseBody}" for the default response.`;
483 return callback(error);
484 }
485 return callback(error);
486 }
487 // Create Result
488 let result = null;
489 if (responseBody === '') responseBody = null;
490
491 return callback(null, result, httpRequest, response);
492 });
493}
494
495/**
496 * Removes a user's invitation to an app
497 *
498 * @param {string} appName The name of the application
499 *
500 * @param {string} ownerName The name of the owner
501 *
502 * @param {string} userEmail The email of the user to invite
503 *
504 * @param {object} [options] Optional Parameters.
505 *
506 * @param {object} [options.customHeaders] Headers that will be added to the
507 * request
508 *
509 * @param {function} callback - The callback.
510 *
511 * @returns {function} callback(err, result, request, response)
512 *
513 * {Error} err - The Error object if an error occurred, null otherwise.
514 *
515 * {null} [result] - The deserialized result object if an error did not occur.
516 *
517 * {object} [request] - The HTTP Request object if an error did not occur.
518 *
519 * {stream} [response] - The HTTP Response stream if an error did not occur.
520 */
521function _deleteMethod(appName, ownerName, userEmail, options, callback) {
522 /* jshint validthis: true */
523 let client = this.client;
524 if(!callback && typeof options === 'function') {
525 callback = options;
526 options = null;
527 }
528 if (!callback) {
529 throw new Error('callback cannot be null.');
530 }
531 // Validate
532 try {
533 if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') {
534 throw new Error('appName cannot be null or undefined and it must be of type string.');
535 }
536 if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') {
537 throw new Error('ownerName cannot be null or undefined and it must be of type string.');
538 }
539 if (userEmail === null || userEmail === undefined || typeof userEmail.valueOf() !== 'string') {
540 throw new Error('userEmail cannot be null or undefined and it must be of type string.');
541 }
542 } catch (error) {
543 return callback(error);
544 }
545
546 // Construct URL
547 let baseUrl = this.client.baseUri;
548 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/invitations/{user_email}';
549 requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName));
550 requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName));
551 requestUrl = requestUrl.replace('{user_email}', encodeURIComponent(userEmail));
552
553 // Create HTTP transport objects
554 let httpRequest = new WebResource();
555 httpRequest.method = 'DELETE';
556 httpRequest.url = requestUrl;
557 httpRequest.headers = {};
558 // Set Headers
559 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
560 if(options) {
561 for(let headerName in options['customHeaders']) {
562 if (options['customHeaders'].hasOwnProperty(headerName)) {
563 httpRequest.headers[headerName] = options['customHeaders'][headerName];
564 }
565 }
566 }
567 httpRequest.body = null;
568 // Send Request
569 return client.pipeline(httpRequest, (err, response, responseBody) => {
570 if (err) {
571 return callback(err);
572 }
573 let statusCode = response.statusCode;
574 if (statusCode < 200 || statusCode >= 300) {
575 let error = new Error(responseBody);
576 error.statusCode = response.statusCode;
577 error.request = msRest.stripRequest(httpRequest);
578 error.response = msRest.stripResponse(response);
579 if (responseBody === '') responseBody = null;
580 let parsedErrorResponse;
581 try {
582 parsedErrorResponse = JSON.parse(responseBody);
583 if (parsedErrorResponse) {
584 let internalError = null;
585 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
586 error.code = internalError ? internalError.code : parsedErrorResponse.code;
587 error.message = internalError ? internalError.message : parsedErrorResponse.message;
588 }
589 } catch (defaultError) {
590 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
591 `- "${responseBody}" for the default response.`;
592 return callback(error);
593 }
594 return callback(error);
595 }
596 // Create Result
597 let result = null;
598 if (responseBody === '') responseBody = null;
599
600 return callback(null, result, httpRequest, response);
601 });
602}
603
604/**
605 * Accepts a pending invitation for the specified user
606 *
607 * @param {string} invitationToken The app invitation token that was sent to
608 * the user
609 *
610 * @param {object} [options] Optional Parameters.
611 *
612 * @param {object} [options.customHeaders] Headers that will be added to the
613 * request
614 *
615 * @param {function} callback - The callback.
616 *
617 * @returns {function} callback(err, result, request, response)
618 *
619 * {Error} err - The Error object if an error occurred, null otherwise.
620 *
621 * {null} [result] - The deserialized result object if an error did not occur.
622 *
623 * {object} [request] - The HTTP Request object if an error did not occur.
624 *
625 * {stream} [response] - The HTTP Response stream if an error did not occur.
626 */
627function _accept(invitationToken, options, callback) {
628 /* jshint validthis: true */
629 let client = this.client;
630 if(!callback && typeof options === 'function') {
631 callback = options;
632 options = null;
633 }
634 if (!callback) {
635 throw new Error('callback cannot be null.');
636 }
637 // Validate
638 try {
639 if (invitationToken === null || invitationToken === undefined || typeof invitationToken.valueOf() !== 'string') {
640 throw new Error('invitationToken cannot be null or undefined and it must be of type string.');
641 }
642 } catch (error) {
643 return callback(error);
644 }
645
646 // Construct URL
647 let baseUrl = this.client.baseUri;
648 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/user/invitations/apps/{invitation_token}/accept';
649 requestUrl = requestUrl.replace('{invitation_token}', encodeURIComponent(invitationToken));
650
651 // Create HTTP transport objects
652 let httpRequest = new WebResource();
653 httpRequest.method = 'POST';
654 httpRequest.url = requestUrl;
655 httpRequest.headers = {};
656 // Set Headers
657 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
658 if(options) {
659 for(let headerName in options['customHeaders']) {
660 if (options['customHeaders'].hasOwnProperty(headerName)) {
661 httpRequest.headers[headerName] = options['customHeaders'][headerName];
662 }
663 }
664 }
665 httpRequest.body = null;
666 // Send Request
667 return client.pipeline(httpRequest, (err, response, responseBody) => {
668 if (err) {
669 return callback(err);
670 }
671 let statusCode = response.statusCode;
672 if (statusCode < 200 || statusCode >= 300) {
673 let error = new Error(responseBody);
674 error.statusCode = response.statusCode;
675 error.request = msRest.stripRequest(httpRequest);
676 error.response = msRest.stripResponse(response);
677 if (responseBody === '') responseBody = null;
678 let parsedErrorResponse;
679 try {
680 parsedErrorResponse = JSON.parse(responseBody);
681 if (parsedErrorResponse) {
682 let internalError = null;
683 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
684 error.code = internalError ? internalError.code : parsedErrorResponse.code;
685 error.message = internalError ? internalError.message : parsedErrorResponse.message;
686 }
687 } catch (defaultError) {
688 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
689 `- "${responseBody}" for the default response.`;
690 return callback(error);
691 }
692 return callback(error);
693 }
694 // Create Result
695 let result = null;
696 if (responseBody === '') responseBody = null;
697
698 return callback(null, result, httpRequest, response);
699 });
700}
701
702/**
703 * Rejects a pending invitation for the specified user
704 *
705 * @param {string} invitationToken The app invitation token that was sent to
706 * the user
707 *
708 * @param {object} [options] Optional Parameters.
709 *
710 * @param {object} [options.customHeaders] Headers that will be added to the
711 * request
712 *
713 * @param {function} callback - The callback.
714 *
715 * @returns {function} callback(err, result, request, response)
716 *
717 * {Error} err - The Error object if an error occurred, null otherwise.
718 *
719 * {null} [result] - The deserialized result object if an error did not occur.
720 *
721 * {object} [request] - The HTTP Request object if an error did not occur.
722 *
723 * {stream} [response] - The HTTP Response stream if an error did not occur.
724 */
725function _reject(invitationToken, options, callback) {
726 /* jshint validthis: true */
727 let client = this.client;
728 if(!callback && typeof options === 'function') {
729 callback = options;
730 options = null;
731 }
732 if (!callback) {
733 throw new Error('callback cannot be null.');
734 }
735 // Validate
736 try {
737 if (invitationToken === null || invitationToken === undefined || typeof invitationToken.valueOf() !== 'string') {
738 throw new Error('invitationToken cannot be null or undefined and it must be of type string.');
739 }
740 } catch (error) {
741 return callback(error);
742 }
743
744 // Construct URL
745 let baseUrl = this.client.baseUri;
746 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/user/invitations/apps/{invitation_token}/reject';
747 requestUrl = requestUrl.replace('{invitation_token}', encodeURIComponent(invitationToken));
748
749 // Create HTTP transport objects
750 let httpRequest = new WebResource();
751 httpRequest.method = 'POST';
752 httpRequest.url = requestUrl;
753 httpRequest.headers = {};
754 // Set Headers
755 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
756 if(options) {
757 for(let headerName in options['customHeaders']) {
758 if (options['customHeaders'].hasOwnProperty(headerName)) {
759 httpRequest.headers[headerName] = options['customHeaders'][headerName];
760 }
761 }
762 }
763 httpRequest.body = null;
764 // Send Request
765 return client.pipeline(httpRequest, (err, response, responseBody) => {
766 if (err) {
767 return callback(err);
768 }
769 let statusCode = response.statusCode;
770 if (statusCode < 200 || statusCode >= 300) {
771 let error = new Error(responseBody);
772 error.statusCode = response.statusCode;
773 error.request = msRest.stripRequest(httpRequest);
774 error.response = msRest.stripResponse(response);
775 if (responseBody === '') responseBody = null;
776 let parsedErrorResponse;
777 try {
778 parsedErrorResponse = JSON.parse(responseBody);
779 if (parsedErrorResponse) {
780 let internalError = null;
781 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
782 error.code = internalError ? internalError.code : parsedErrorResponse.code;
783 error.message = internalError ? internalError.message : parsedErrorResponse.message;
784 }
785 } catch (defaultError) {
786 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
787 `- "${responseBody}" for the default response.`;
788 return callback(error);
789 }
790 return callback(error);
791 }
792 // Create Result
793 let result = null;
794 if (responseBody === '') responseBody = null;
795
796 return callback(null, result, httpRequest, response);
797 });
798}
799
800/** Class representing a AppInvitations. */
801class AppInvitations {
802 /**
803 * Create a AppInvitations.
804 * @param {AccountClient} client Reference to the service client.
805 */
806 constructor(client) {
807 this.client = client;
808 this._create = _create;
809 this._list = _list;
810 this._createByEmail = _createByEmail;
811 this._updatePermissions = _updatePermissions;
812 this._deleteMethod = _deleteMethod;
813 this._accept = _accept;
814 this._reject = _reject;
815 }
816
817 /**
818 * Invites a new or existing user to an app
819 *
820 * @param {string} appName The name of the application
821 *
822 * @param {string} ownerName The name of the owner
823 *
824 * @param {object} [options] Optional Parameters.
825 *
826 * @param {object} [options.userEmail] The email of the user to invite
827 *
828 * @param {string} options.userEmail.userEmail The user's email address'
829 *
830 * @param {object} [options.customHeaders] Headers that will be added to the
831 * request
832 *
833 * @returns {Promise} A promise is returned
834 *
835 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
836 *
837 * @reject {Error} - The error object.
838 */
839 createWithHttpOperationResponse(appName, ownerName, options) {
840 let client = this.client;
841 let self = this;
842 return new Promise((resolve, reject) => {
843 self._create(appName, ownerName, options, (err, result, request, response) => {
844 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
845 httpOperationResponse.body = result;
846 if (err) { reject(err); }
847 else { resolve(httpOperationResponse); }
848 return;
849 });
850 });
851 }
852
853 /**
854 * Invites a new or existing user to an app
855 *
856 * @param {string} appName The name of the application
857 *
858 * @param {string} ownerName The name of the owner
859 *
860 * @param {object} [options] Optional Parameters.
861 *
862 * @param {object} [options.userEmail] The email of the user to invite
863 *
864 * @param {string} options.userEmail.userEmail The user's email address'
865 *
866 * @param {object} [options.customHeaders] Headers that will be added to the
867 * request
868 *
869 * @param {function} [optionalCallback] - The optional callback.
870 *
871 * @returns {function|Promise} If a callback was passed as the last parameter
872 * then it returns the callback else returns a Promise.
873 *
874 * {Promise} A promise is returned
875 *
876 * @resolve {null} - The deserialized result object.
877 *
878 * @reject {Error} - The error object.
879 *
880 * {function} optionalCallback(err, result, request, response)
881 *
882 * {Error} err - The Error object if an error occurred, null otherwise.
883 *
884 * {null} [result] - The deserialized result object if an error did not occur.
885 *
886 * {object} [request] - The HTTP Request object if an error did not occur.
887 *
888 * {stream} [response] - The HTTP Response stream if an error did not occur.
889 */
890 create(appName, ownerName, options, optionalCallback) {
891 let client = this.client;
892 let self = this;
893 if (!optionalCallback && typeof options === 'function') {
894 optionalCallback = options;
895 options = null;
896 }
897 if (!optionalCallback) {
898 return new Promise((resolve, reject) => {
899 self._create(appName, ownerName, options, (err, result, request, response) => {
900 if (err) { reject(err); }
901 else { resolve(result); }
902 return;
903 });
904 });
905 } else {
906 return self._create(appName, ownerName, options, optionalCallback);
907 }
908 }
909
910 /**
911 * Gets the pending invitations for the app
912 *
913 * @param {string} appName The name of the application
914 *
915 * @param {string} ownerName The name of the owner
916 *
917 * @param {object} [options] Optional Parameters.
918 *
919 * @param {object} [options.customHeaders] Headers that will be added to the
920 * request
921 *
922 * @returns {Promise} A promise is returned
923 *
924 * @resolve {HttpOperationResponse<AppInvitationDetailResponse>} - The deserialized result object.
925 *
926 * @reject {Error} - The error object.
927 */
928 listWithHttpOperationResponse(appName, ownerName, options) {
929 let client = this.client;
930 let self = this;
931 return new Promise((resolve, reject) => {
932 self._list(appName, ownerName, options, (err, result, request, response) => {
933 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
934 httpOperationResponse.body = result;
935 if (err) { reject(err); }
936 else { resolve(httpOperationResponse); }
937 return;
938 });
939 });
940 }
941
942 /**
943 * Gets the pending invitations for the app
944 *
945 * @param {string} appName The name of the application
946 *
947 * @param {string} ownerName The name of the owner
948 *
949 * @param {object} [options] Optional Parameters.
950 *
951 * @param {object} [options.customHeaders] Headers that will be added to the
952 * request
953 *
954 * @param {function} [optionalCallback] - The optional callback.
955 *
956 * @returns {function|Promise} If a callback was passed as the last parameter
957 * then it returns the callback else returns a Promise.
958 *
959 * {Promise} A promise is returned
960 *
961 * @resolve {AppInvitationDetailResponse} - The deserialized result object.
962 *
963 * @reject {Error} - The error object.
964 *
965 * {function} optionalCallback(err, result, request, response)
966 *
967 * {Error} err - The Error object if an error occurred, null otherwise.
968 *
969 * {object} [result] - The deserialized result object if an error did not occur.
970 * See {@link AppInvitationDetailResponse} for more
971 * information.
972 *
973 * {object} [request] - The HTTP Request object if an error did not occur.
974 *
975 * {stream} [response] - The HTTP Response stream if an error did not occur.
976 */
977 list(appName, ownerName, options, optionalCallback) {
978 let client = this.client;
979 let self = this;
980 if (!optionalCallback && typeof options === 'function') {
981 optionalCallback = options;
982 options = null;
983 }
984 if (!optionalCallback) {
985 return new Promise((resolve, reject) => {
986 self._list(appName, ownerName, options, (err, result, request, response) => {
987 if (err) { reject(err); }
988 else { resolve(result); }
989 return;
990 });
991 });
992 } else {
993 return self._list(appName, ownerName, options, optionalCallback);
994 }
995 }
996
997 /**
998 * Invites a new or existing user to an app
999 *
1000 * @param {string} appName The name of the application
1001 *
1002 * @param {string} ownerName The name of the owner
1003 *
1004 * @param {string} userEmail The email of the user to invite
1005 *
1006 * @param {object} [options] Optional Parameters.
1007 *
1008 * @param {object} [options.customHeaders] Headers that will be added to the
1009 * request
1010 *
1011 * @returns {Promise} A promise is returned
1012 *
1013 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
1014 *
1015 * @reject {Error} - The error object.
1016 */
1017 createByEmailWithHttpOperationResponse(appName, ownerName, userEmail, options) {
1018 let client = this.client;
1019 let self = this;
1020 return new Promise((resolve, reject) => {
1021 self._createByEmail(appName, ownerName, userEmail, options, (err, result, request, response) => {
1022 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
1023 httpOperationResponse.body = result;
1024 if (err) { reject(err); }
1025 else { resolve(httpOperationResponse); }
1026 return;
1027 });
1028 });
1029 }
1030
1031 /**
1032 * Invites a new or existing user to an app
1033 *
1034 * @param {string} appName The name of the application
1035 *
1036 * @param {string} ownerName The name of the owner
1037 *
1038 * @param {string} userEmail The email of the user to invite
1039 *
1040 * @param {object} [options] Optional Parameters.
1041 *
1042 * @param {object} [options.customHeaders] Headers that will be added to the
1043 * request
1044 *
1045 * @param {function} [optionalCallback] - The optional callback.
1046 *
1047 * @returns {function|Promise} If a callback was passed as the last parameter
1048 * then it returns the callback else returns a Promise.
1049 *
1050 * {Promise} A promise is returned
1051 *
1052 * @resolve {null} - The deserialized result object.
1053 *
1054 * @reject {Error} - The error object.
1055 *
1056 * {function} optionalCallback(err, result, request, response)
1057 *
1058 * {Error} err - The Error object if an error occurred, null otherwise.
1059 *
1060 * {null} [result] - The deserialized result object if an error did not occur.
1061 *
1062 * {object} [request] - The HTTP Request object if an error did not occur.
1063 *
1064 * {stream} [response] - The HTTP Response stream if an error did not occur.
1065 */
1066 createByEmail(appName, ownerName, userEmail, options, optionalCallback) {
1067 let client = this.client;
1068 let self = this;
1069 if (!optionalCallback && typeof options === 'function') {
1070 optionalCallback = options;
1071 options = null;
1072 }
1073 if (!optionalCallback) {
1074 return new Promise((resolve, reject) => {
1075 self._createByEmail(appName, ownerName, userEmail, options, (err, result, request, response) => {
1076 if (err) { reject(err); }
1077 else { resolve(result); }
1078 return;
1079 });
1080 });
1081 } else {
1082 return self._createByEmail(appName, ownerName, userEmail, options, optionalCallback);
1083 }
1084 }
1085
1086 /**
1087 * Update pending invitation permission
1088 *
1089 * @param {string} appName The name of the application
1090 *
1091 * @param {string} ownerName The name of the owner
1092 *
1093 * @param {string} userEmail The email of the user to invite
1094 *
1095 * @param {object} [options] Optional Parameters.
1096 *
1097 * @param {object} [options.userInvitationPermissionsData] The value to update
1098 * the user permission in the invite.
1099 *
1100 * @param {array} options.userInvitationPermissionsData.permissions The
1101 * permissions the user has for the app in the invitation
1102 *
1103 * @param {object} [options.customHeaders] Headers that will be added to the
1104 * request
1105 *
1106 * @returns {Promise} A promise is returned
1107 *
1108 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
1109 *
1110 * @reject {Error} - The error object.
1111 */
1112 updatePermissionsWithHttpOperationResponse(appName, ownerName, userEmail, options) {
1113 let client = this.client;
1114 let self = this;
1115 return new Promise((resolve, reject) => {
1116 self._updatePermissions(appName, ownerName, userEmail, options, (err, result, request, response) => {
1117 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
1118 httpOperationResponse.body = result;
1119 if (err) { reject(err); }
1120 else { resolve(httpOperationResponse); }
1121 return;
1122 });
1123 });
1124 }
1125
1126 /**
1127 * Update pending invitation permission
1128 *
1129 * @param {string} appName The name of the application
1130 *
1131 * @param {string} ownerName The name of the owner
1132 *
1133 * @param {string} userEmail The email of the user to invite
1134 *
1135 * @param {object} [options] Optional Parameters.
1136 *
1137 * @param {object} [options.userInvitationPermissionsData] The value to update
1138 * the user permission in the invite.
1139 *
1140 * @param {array} options.userInvitationPermissionsData.permissions The
1141 * permissions the user has for the app in the invitation
1142 *
1143 * @param {object} [options.customHeaders] Headers that will be added to the
1144 * request
1145 *
1146 * @param {function} [optionalCallback] - The optional callback.
1147 *
1148 * @returns {function|Promise} If a callback was passed as the last parameter
1149 * then it returns the callback else returns a Promise.
1150 *
1151 * {Promise} A promise is returned
1152 *
1153 * @resolve {null} - The deserialized result object.
1154 *
1155 * @reject {Error} - The error object.
1156 *
1157 * {function} optionalCallback(err, result, request, response)
1158 *
1159 * {Error} err - The Error object if an error occurred, null otherwise.
1160 *
1161 * {null} [result] - The deserialized result object if an error did not occur.
1162 *
1163 * {object} [request] - The HTTP Request object if an error did not occur.
1164 *
1165 * {stream} [response] - The HTTP Response stream if an error did not occur.
1166 */
1167 updatePermissions(appName, ownerName, userEmail, options, optionalCallback) {
1168 let client = this.client;
1169 let self = this;
1170 if (!optionalCallback && typeof options === 'function') {
1171 optionalCallback = options;
1172 options = null;
1173 }
1174 if (!optionalCallback) {
1175 return new Promise((resolve, reject) => {
1176 self._updatePermissions(appName, ownerName, userEmail, options, (err, result, request, response) => {
1177 if (err) { reject(err); }
1178 else { resolve(result); }
1179 return;
1180 });
1181 });
1182 } else {
1183 return self._updatePermissions(appName, ownerName, userEmail, options, optionalCallback);
1184 }
1185 }
1186
1187 /**
1188 * Removes a user's invitation to an app
1189 *
1190 * @param {string} appName The name of the application
1191 *
1192 * @param {string} ownerName The name of the owner
1193 *
1194 * @param {string} userEmail The email of the user to invite
1195 *
1196 * @param {object} [options] Optional Parameters.
1197 *
1198 * @param {object} [options.customHeaders] Headers that will be added to the
1199 * request
1200 *
1201 * @returns {Promise} A promise is returned
1202 *
1203 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
1204 *
1205 * @reject {Error} - The error object.
1206 */
1207 deleteMethodWithHttpOperationResponse(appName, ownerName, userEmail, options) {
1208 let client = this.client;
1209 let self = this;
1210 return new Promise((resolve, reject) => {
1211 self._deleteMethod(appName, ownerName, userEmail, options, (err, result, request, response) => {
1212 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
1213 httpOperationResponse.body = result;
1214 if (err) { reject(err); }
1215 else { resolve(httpOperationResponse); }
1216 return;
1217 });
1218 });
1219 }
1220
1221 /**
1222 * Removes a user's invitation to an app
1223 *
1224 * @param {string} appName The name of the application
1225 *
1226 * @param {string} ownerName The name of the owner
1227 *
1228 * @param {string} userEmail The email of the user to invite
1229 *
1230 * @param {object} [options] Optional Parameters.
1231 *
1232 * @param {object} [options.customHeaders] Headers that will be added to the
1233 * request
1234 *
1235 * @param {function} [optionalCallback] - The optional callback.
1236 *
1237 * @returns {function|Promise} If a callback was passed as the last parameter
1238 * then it returns the callback else returns a Promise.
1239 *
1240 * {Promise} A promise is returned
1241 *
1242 * @resolve {null} - The deserialized result object.
1243 *
1244 * @reject {Error} - The error object.
1245 *
1246 * {function} optionalCallback(err, result, request, response)
1247 *
1248 * {Error} err - The Error object if an error occurred, null otherwise.
1249 *
1250 * {null} [result] - The deserialized result object if an error did not occur.
1251 *
1252 * {object} [request] - The HTTP Request object if an error did not occur.
1253 *
1254 * {stream} [response] - The HTTP Response stream if an error did not occur.
1255 */
1256 deleteMethod(appName, ownerName, userEmail, options, optionalCallback) {
1257 let client = this.client;
1258 let self = this;
1259 if (!optionalCallback && typeof options === 'function') {
1260 optionalCallback = options;
1261 options = null;
1262 }
1263 if (!optionalCallback) {
1264 return new Promise((resolve, reject) => {
1265 self._deleteMethod(appName, ownerName, userEmail, options, (err, result, request, response) => {
1266 if (err) { reject(err); }
1267 else { resolve(result); }
1268 return;
1269 });
1270 });
1271 } else {
1272 return self._deleteMethod(appName, ownerName, userEmail, options, optionalCallback);
1273 }
1274 }
1275
1276 /**
1277 * Accepts a pending invitation for the specified user
1278 *
1279 * @param {string} invitationToken The app invitation token that was sent to
1280 * the user
1281 *
1282 * @param {object} [options] Optional Parameters.
1283 *
1284 * @param {object} [options.customHeaders] Headers that will be added to the
1285 * request
1286 *
1287 * @returns {Promise} A promise is returned
1288 *
1289 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
1290 *
1291 * @reject {Error} - The error object.
1292 */
1293 acceptWithHttpOperationResponse(invitationToken, options) {
1294 let client = this.client;
1295 let self = this;
1296 return new Promise((resolve, reject) => {
1297 self._accept(invitationToken, options, (err, result, request, response) => {
1298 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
1299 httpOperationResponse.body = result;
1300 if (err) { reject(err); }
1301 else { resolve(httpOperationResponse); }
1302 return;
1303 });
1304 });
1305 }
1306
1307 /**
1308 * Accepts a pending invitation for the specified user
1309 *
1310 * @param {string} invitationToken The app invitation token that was sent to
1311 * the user
1312 *
1313 * @param {object} [options] Optional Parameters.
1314 *
1315 * @param {object} [options.customHeaders] Headers that will be added to the
1316 * request
1317 *
1318 * @param {function} [optionalCallback] - The optional callback.
1319 *
1320 * @returns {function|Promise} If a callback was passed as the last parameter
1321 * then it returns the callback else returns a Promise.
1322 *
1323 * {Promise} A promise is returned
1324 *
1325 * @resolve {null} - The deserialized result object.
1326 *
1327 * @reject {Error} - The error object.
1328 *
1329 * {function} optionalCallback(err, result, request, response)
1330 *
1331 * {Error} err - The Error object if an error occurred, null otherwise.
1332 *
1333 * {null} [result] - The deserialized result object if an error did not occur.
1334 *
1335 * {object} [request] - The HTTP Request object if an error did not occur.
1336 *
1337 * {stream} [response] - The HTTP Response stream if an error did not occur.
1338 */
1339 accept(invitationToken, options, optionalCallback) {
1340 let client = this.client;
1341 let self = this;
1342 if (!optionalCallback && typeof options === 'function') {
1343 optionalCallback = options;
1344 options = null;
1345 }
1346 if (!optionalCallback) {
1347 return new Promise((resolve, reject) => {
1348 self._accept(invitationToken, options, (err, result, request, response) => {
1349 if (err) { reject(err); }
1350 else { resolve(result); }
1351 return;
1352 });
1353 });
1354 } else {
1355 return self._accept(invitationToken, options, optionalCallback);
1356 }
1357 }
1358
1359 /**
1360 * Rejects a pending invitation for the specified user
1361 *
1362 * @param {string} invitationToken The app invitation token that was sent to
1363 * the user
1364 *
1365 * @param {object} [options] Optional Parameters.
1366 *
1367 * @param {object} [options.customHeaders] Headers that will be added to the
1368 * request
1369 *
1370 * @returns {Promise} A promise is returned
1371 *
1372 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
1373 *
1374 * @reject {Error} - The error object.
1375 */
1376 rejectWithHttpOperationResponse(invitationToken, options) {
1377 let client = this.client;
1378 let self = this;
1379 return new Promise((resolve, reject) => {
1380 self._reject(invitationToken, options, (err, result, request, response) => {
1381 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
1382 httpOperationResponse.body = result;
1383 if (err) { reject(err); }
1384 else { resolve(httpOperationResponse); }
1385 return;
1386 });
1387 });
1388 }
1389
1390 /**
1391 * Rejects a pending invitation for the specified user
1392 *
1393 * @param {string} invitationToken The app invitation token that was sent to
1394 * the user
1395 *
1396 * @param {object} [options] Optional Parameters.
1397 *
1398 * @param {object} [options.customHeaders] Headers that will be added to the
1399 * request
1400 *
1401 * @param {function} [optionalCallback] - The optional callback.
1402 *
1403 * @returns {function|Promise} If a callback was passed as the last parameter
1404 * then it returns the callback else returns a Promise.
1405 *
1406 * {Promise} A promise is returned
1407 *
1408 * @resolve {null} - The deserialized result object.
1409 *
1410 * @reject {Error} - The error object.
1411 *
1412 * {function} optionalCallback(err, result, request, response)
1413 *
1414 * {Error} err - The Error object if an error occurred, null otherwise.
1415 *
1416 * {null} [result] - The deserialized result object if an error did not occur.
1417 *
1418 * {object} [request] - The HTTP Request object if an error did not occur.
1419 *
1420 * {stream} [response] - The HTTP Response stream if an error did not occur.
1421 */
1422 reject(invitationToken, options, optionalCallback) {
1423 let client = this.client;
1424 let self = this;
1425 if (!optionalCallback && typeof options === 'function') {
1426 optionalCallback = options;
1427 options = null;
1428 }
1429 if (!optionalCallback) {
1430 return new Promise((resolve, reject) => {
1431 self._reject(invitationToken, options, (err, result, request, response) => {
1432 if (err) { reject(err); }
1433 else { resolve(result); }
1434 return;
1435 });
1436 });
1437 } else {
1438 return self._reject(invitationToken, options, optionalCallback);
1439 }
1440 }
1441
1442}
1443
1444module.exports = AppInvitations;
1445