onshape-clients
Version:
The meta package for creating the various Onshape clients
323 lines (275 loc) • 12.2 kB
text/typescript
/**
* Onshape REST API
* The Onshape REST API consumed by all clients.
*
* OpenAPI spec version: 1.93
* Contact: api-support@onshape.zendesk.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import localVarRequest = require('request');
import http = require('http');
import Promise = require('bluebird');
/* tslint:disable:no-unused-locals */
import { BTListResponseBTPurchaseInfo } from '../model/bTListResponseBTPurchaseInfo';
import { BTPurchaseInfo } from '../model/bTPurchaseInfo';
import { BTPurchaseUserParams } from '../model/bTPurchaseUserParams';
import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models';
let defaultBasePath = 'http://localhost';
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
export enum AccountsApiApiKeys {
}
export class AccountsApi {
protected _basePath = defaultBasePath;
protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false;
protected authentications = {
'default': <Authentication>new VoidAuth(),
'OAuth2': new OAuth(),
}
constructor(basePath?: string);
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
if (password) {
if (basePath) {
this.basePath = basePath;
}
} else {
if (basePathOrUsername) {
this.basePath = basePathOrUsername
}
}
}
set useQuerystring(value: boolean) {
this._useQuerystring = value;
}
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setDefaultAuthentication(auth: Authentication) {
this.authentications.default = auth;
}
public setApiKey(key: AccountsApiApiKeys, value: string) {
(this.authentications as any)[AccountsApiApiKeys[key]].apiKey = value;
}
set accessToken(token: string) {
this.authentications.OAuth2.accessToken = token;
}
/**
*
* @summary Cancel Recurring Subscription
* @param aid
* @param pid
* @param cancelImmediately
*/
public cancelPurchaseNew (aid: string, pid: string, cancelImmediately?: boolean) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/api/accounts/{aid}/purchases/{pid}'
.replace('{' + 'aid' + '}', encodeURIComponent(String(aid)))
.replace('{' + 'pid' + '}', encodeURIComponent(String(pid)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
let localVarFormParams: any = {};
// verify required parameter 'aid' is not null or undefined
if (aid === null || aid === undefined) {
throw new Error('Required parameter aid was null or undefined when calling cancelPurchaseNew.');
}
// verify required parameter 'pid' is not null or undefined
if (pid === null || pid === undefined) {
throw new Error('Required parameter pid was null or undefined when calling cancelPurchaseNew.');
}
if (cancelImmediately !== undefined) {
localVarQueryParameters['cancelImmediately'] = ObjectSerializer.serialize(cancelImmediately, "boolean");
}
let localVarUseFormData = false;
let localVarRequestOptions: localVarRequest.Options = {
method: 'DELETE',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
this.authentications.OAuth2.applyToRequest(localVarRequestOptions);
this.authentications.default.applyToRequest(localVarRequestOptions);
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
(<any>localVarRequestOptions).formData = localVarFormParams;
} else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
} else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
} else {
reject({ response: response, body: body });
}
}
});
});
}
/**
*
* @summary Mark Purchase Consumed For User
* @param pid
* @param bTPurchaseUserParams
*/
public consumePurchase (pid: string, bTPurchaseUserParams?: BTPurchaseUserParams) : Promise<{ response: http.ClientResponse; body: BTPurchaseInfo; }> {
const localVarPath = this.basePath + '/api/accounts/purchases/{pid}/consume'
.replace('{' + 'pid' + '}', encodeURIComponent(String(pid)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
let localVarFormParams: any = {};
// verify required parameter 'pid' is not null or undefined
if (pid === null || pid === undefined) {
throw new Error('Required parameter pid was null or undefined when calling consumePurchase.');
}
let localVarUseFormData = false;
let localVarRequestOptions: localVarRequest.Options = {
method: 'POST',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: ObjectSerializer.serialize(bTPurchaseUserParams, "BTPurchaseUserParams")
};
this.authentications.OAuth2.applyToRequest(localVarRequestOptions);
this.authentications.default.applyToRequest(localVarRequestOptions);
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
(<any>localVarRequestOptions).formData = localVarFormParams;
} else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.ClientResponse; body: BTPurchaseInfo; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
} else {
body = ObjectSerializer.deserialize(body, "BTPurchaseInfo");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
} else {
reject({ response: response, body: body });
}
}
});
});
}
/**
*
* @summary Get Plan Purchases
* @param planId
* @param offset
* @param limit
*/
public getPlanPurchases (planId: string, offset?: number, limit?: number) : Promise<{ response: http.ClientResponse; body: BTListResponseBTPurchaseInfo; }> {
const localVarPath = this.basePath + '/api/accounts/plans/{planId}/purchases'
.replace('{' + 'planId' + '}', encodeURIComponent(String(planId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
let localVarFormParams: any = {};
// verify required parameter 'planId' is not null or undefined
if (planId === null || planId === undefined) {
throw new Error('Required parameter planId was null or undefined when calling getPlanPurchases.');
}
if (offset !== undefined) {
localVarQueryParameters['offset'] = ObjectSerializer.serialize(offset, "number");
}
if (limit !== undefined) {
localVarQueryParameters['limit'] = ObjectSerializer.serialize(limit, "number");
}
let localVarUseFormData = false;
let localVarRequestOptions: localVarRequest.Options = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
this.authentications.default.applyToRequest(localVarRequestOptions);
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
(<any>localVarRequestOptions).formData = localVarFormParams;
} else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.ClientResponse; body: BTListResponseBTPurchaseInfo; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
} else {
body = ObjectSerializer.deserialize(body, "BTListResponseBTPurchaseInfo");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
} else {
reject({ response: response, body: body });
}
}
});
});
}
/**
*
* @summary Get User's Appstore Purchases.
* @param all
* @param ownPurchaseOnly
*/
public getPurchases (all?: boolean, ownPurchaseOnly?: boolean) : Promise<{ response: http.ClientResponse; body: Array<BTPurchaseInfo>; }> {
const localVarPath = this.basePath + '/api/accounts/purchases';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
let localVarFormParams: any = {};
if (all !== undefined) {
localVarQueryParameters['all'] = ObjectSerializer.serialize(all, "boolean");
}
if (ownPurchaseOnly !== undefined) {
localVarQueryParameters['ownPurchaseOnly'] = ObjectSerializer.serialize(ownPurchaseOnly, "boolean");
}
let localVarUseFormData = false;
let localVarRequestOptions: localVarRequest.Options = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
this.authentications.default.applyToRequest(localVarRequestOptions);
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
(<any>localVarRequestOptions).formData = localVarFormParams;
} else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.ClientResponse; body: Array<BTPurchaseInfo>; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
} else {
body = ObjectSerializer.deserialize(body, "Array<BTPurchaseInfo>");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
} else {
reject({ response: response, body: body });
}
}
});
});
}
}