xero-node
Version:
Xero NodeJS OAuth 2.0 client for xero-node
132 lines • 5.83 kB
JavaScript
;
/**
* Xero AppStore API
* These endpoints are for Xero Partners to interact with the App Store Billing platform
*
* The version of the OpenAPI document: 2.17.1
* Contact: api@xero.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppStoreApi = exports.AppStoreApiApiKeys = void 0;
const localVarRequest = require("request");
const models_1 = require("../model/appstore/models");
const models_2 = require("../model/appstore/models");
let defaultBasePath = 'https://api.xero.com/appstore/2.0';
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
var AppStoreApiApiKeys;
(function (AppStoreApiApiKeys) {
})(AppStoreApiApiKeys = exports.AppStoreApiApiKeys || (exports.AppStoreApiApiKeys = {}));
class AppStoreApi {
constructor(basePathOrUsername, password, basePath) {
this._basePath = defaultBasePath;
this.defaultHeaders = { 'user-agent': 'xero-node-4.16.0' };
this._useQuerystring = false;
this.binaryHeaders = {};
this.authentications = {
'default': new models_1.VoidAuth(),
'OAuth2': new models_2.OAuth(),
};
if (password) {
if (basePath) {
this.basePath = basePath;
}
}
else {
if (basePathOrUsername) {
this.basePath = basePathOrUsername;
}
}
}
set useQuerystring(value) {
this._useQuerystring = value;
}
set basePath(basePath) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
setDefaultAuthentication(auth) {
this.authentications.default = auth;
}
setApiKey(key, value) {
this.authentications[AppStoreApiApiKeys[key]].apiKey = value;
}
set accessToken(token) {
this.authentications.OAuth2.accessToken = token;
}
/**
*
* @summary Retrieves a subscription for a given subscriptionId
* @param subscriptionId Unique identifier for Subscription object
*/
getSubscription(subscriptionId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/subscriptions/{subscriptionId}'
.replace('{' + 'subscriptionId' + '}', encodeURIComponent(String(subscriptionId)));
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this.defaultHeaders);
let localVarFormParams = {};
// verify required parameter 'subscriptionId' is not null or undefined
if (subscriptionId === null || subscriptionId === undefined) {
throw new Error('Required parameter subscriptionId was null or undefined when calling getSubscription.');
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
let authenticationPromise = Promise.resolve();
authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
return authenticationPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
body = models_1.ObjectSerializer.deserialize(body, "Subscription");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
}
exports.AppStoreApi = AppStoreApi;
//# sourceMappingURL=appStoreApi.js.map