ask-sdk-model
Version:
Model package for Alexa Skills Kit SDK
828 lines • 190 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var services;
(function (services) {
/**
* Class to be used as the base class for the generated service clients.
*/
var BaseServiceClient = /** @class */ (function () {
/**
* Creates new instance of the BaseServiceClient
* @param {ApiConfiguration} apiConfiguration configuration parameter to provide dependencies to service client instance
*/
function BaseServiceClient(apiConfiguration) {
this.requestInterceptors = [];
this.responseInterceptors = [];
this.apiConfiguration = apiConfiguration;
}
BaseServiceClient.isCodeSuccessful = function (responseCode) {
return responseCode >= 200 && responseCode < 300;
};
BaseServiceClient.buildUrl = function (endpoint, path, queryParameters, pathParameters) {
var processedEndpoint = endpoint.endsWith('/') ? endpoint.substr(0, endpoint.length - 1) : endpoint;
var pathWithParams = this.interpolateParams(path, pathParameters);
var isConstantQueryPresent = pathWithParams.includes('?');
var queryString = this.buildQueryString(queryParameters, isConstantQueryPresent);
return processedEndpoint + pathWithParams + queryString;
};
BaseServiceClient.interpolateParams = function (path, params) {
if (!params) {
return path;
}
var result = path;
params.forEach(function (paramValue, paramName) {
result = result.replace('{' + paramName + '}', encodeURIComponent(paramValue));
});
return result;
};
BaseServiceClient.buildQueryString = function (params, isQueryStart) {
if (!params) {
return '';
}
var sb = [];
if (isQueryStart) {
sb.push('&');
}
else {
sb.push('?');
}
params.forEach(function (obj) {
sb.push(encodeURIComponent(obj.key));
sb.push('=');
sb.push(encodeURIComponent(obj.value));
sb.push('&');
});
sb.pop();
return sb.join('');
};
/**
* Sets array of functions that is going to be executed before the request is send
* @param {Function} requestInterceptor request interceptor function
* @returns {BaseServiceClient}
*/
BaseServiceClient.prototype.withRequestInterceptors = function () {
var requestInterceptors = [];
for (var _i = 0; _i < arguments.length; _i++) {
requestInterceptors[_i] = arguments[_i];
}
for (var _a = 0, requestInterceptors_1 = requestInterceptors; _a < requestInterceptors_1.length; _a++) {
var interceptor = requestInterceptors_1[_a];
this.requestInterceptors.push(interceptor);
}
return this;
};
/**
* Sets array of functions that is going to be executed after the request is send
* @param {Function} responseInterceptor response interceptor function
* @returns {BaseServiceClient}
*/
BaseServiceClient.prototype.withResponseInterceptors = function () {
var responseInterceptors = [];
for (var _i = 0; _i < arguments.length; _i++) {
responseInterceptors[_i] = arguments[_i];
}
for (var _a = 0, responseInterceptors_1 = responseInterceptors; _a < responseInterceptors_1.length; _a++) {
var interceptor = responseInterceptors_1[_a];
this.responseInterceptors.push(interceptor);
}
return this;
};
/**
* Invocation wrapper to implement service operations in generated classes
* @param method HTTP method, such as 'POST', 'GET', 'DELETE', etc.
* @param endpoint base API url
* @param path the path pattern with possible placeholders for path parameters in form {paramName}
* @param pathParams path parameters collection
* @param queryParams query parameters collection
* @param headerParams headers collection
* @param bodyParam if body parameter is present it is provided here, otherwise null or undefined
* @param errors maps recognized status codes to messages
* @param nonJsonBody if the body is in JSON format
*/
BaseServiceClient.prototype.invoke = function (method, endpoint, path, pathParams, queryParams, headerParams, bodyParam, errors, nonJsonBody) {
return __awaiter(this, void 0, void 0, function () {
var request, apiClient, response, _i, _a, requestInterceptor, _b, _c, responseInterceptor, err_1, body, contentType, isJson, apiResponse, err;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
request = {
url: BaseServiceClient.buildUrl(endpoint, path, queryParams, pathParams),
method: method,
headers: headerParams,
};
if (bodyParam != null) {
request.body = nonJsonBody ? bodyParam : JSON.stringify(bodyParam);
}
apiClient = this.apiConfiguration.apiClient;
_d.label = 1;
case 1:
_d.trys.push([1, 11, , 12]);
_i = 0, _a = this.requestInterceptors;
_d.label = 2;
case 2:
if (!(_i < _a.length)) return [3 /*break*/, 5];
requestInterceptor = _a[_i];
return [4 /*yield*/, requestInterceptor(request)];
case 3:
_d.sent();
_d.label = 4;
case 4:
_i++;
return [3 /*break*/, 2];
case 5: return [4 /*yield*/, apiClient.invoke(request)];
case 6:
response = _d.sent();
_b = 0, _c = this.responseInterceptors;
_d.label = 7;
case 7:
if (!(_b < _c.length)) return [3 /*break*/, 10];
responseInterceptor = _c[_b];
return [4 /*yield*/, responseInterceptor(response)];
case 8:
_d.sent();
_d.label = 9;
case 9:
_b++;
return [3 /*break*/, 7];
case 10: return [3 /*break*/, 12];
case 11:
err_1 = _d.sent();
err_1.message = "Call to service failed: " + err_1.message;
throw err_1;
case 12:
try {
contentType = response.headers.find(function (h) { return h.key === 'content-type'; });
isJson = !contentType || contentType.value.includes('application/json');
body = response.body && isJson ? JSON.parse(response.body) : response.body;
// converting to undefined if empty string
body = body || undefined;
}
catch (err) {
throw new SyntaxError("Failed trying to parse the response body: " + response.body);
}
if (BaseServiceClient.isCodeSuccessful(response.statusCode)) {
apiResponse = {
headers: response.headers,
body: body,
statusCode: response.statusCode,
};
return [2 /*return*/, apiResponse];
}
err = new Error('Unknown error');
err.name = 'ServiceError';
err['statusCode'] = response.statusCode; // tslint:disable-line:no-string-literal
err['response'] = body; // tslint:disable-line:no-string-literal
if (errors && errors.has(response.statusCode)) {
err.message = errors.get(response.statusCode);
}
throw err;
}
});
});
};
return BaseServiceClient;
}());
services.BaseServiceClient = BaseServiceClient;
/**
* Class to be used to call Amazon LWA to retrieve access tokens.
*/
var LwaServiceClient = /** @class */ (function (_super) {
__extends(LwaServiceClient, _super);
function LwaServiceClient(options) {
var _this = _super.call(this, options.apiConfiguration) || this;
if (options.authenticationConfiguration == null) {
throw new Error('AuthenticationConfiguration cannot be null or undefined.');
}
_this.grantType = options.grantType ? options.grantType : LwaServiceClient.CLIENT_CREDENTIALS_GRANT_TYPE;
_this.authenticationConfiguration = options.authenticationConfiguration;
_this.tokenStore = {};
return _this;
}
LwaServiceClient.prototype.getAccessTokenForScope = function (scope) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (scope == null) {
throw new Error('Scope cannot be null or undefined.');
}
return [2 /*return*/, this.getAccessToken(scope)];
});
});
};
LwaServiceClient.prototype.getAccessToken = function (scope) {
return __awaiter(this, void 0, void 0, function () {
var cacheKey, accessToken, accessTokenRequest, accessTokenResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cacheKey = scope ? scope : LwaServiceClient.REFRESH_ACCESS_TOKEN;
accessToken = this.tokenStore[cacheKey];
if (accessToken && accessToken.expiry > Date.now() + LwaServiceClient.EXPIRY_OFFSET_MILLIS) {
return [2 /*return*/, accessToken.token];
}
accessTokenRequest = {
clientId: this.authenticationConfiguration.clientId,
clientSecret: this.authenticationConfiguration.clientSecret,
};
if (scope && this.authenticationConfiguration.refreshToken) {
throw new Error('Cannot support both refreshToken and scope.');
}
else if (scope == null && this.authenticationConfiguration.refreshToken == null) {
throw new Error('Either refreshToken or scope must be specified.');
}
else if (scope == null) {
accessTokenRequest.refreshToken = this.authenticationConfiguration.refreshToken;
}
else {
accessTokenRequest.scope = scope;
}
return [4 /*yield*/, this.generateAccessToken(accessTokenRequest)];
case 1:
accessTokenResponse = _a.sent();
this.tokenStore[cacheKey] = {
token: accessTokenResponse.access_token,
expiry: Date.now() + accessTokenResponse.expires_in * 1000,
};
return [2 /*return*/, accessTokenResponse.access_token];
}
});
});
};
LwaServiceClient.prototype.generateAccessToken = function (accessTokenRequest) {
return __awaiter(this, void 0, void 0, function () {
var authEndpoint, queryParams, headerParams, pathParams, paramInfo, bodyParams, errorDefinitions, apiResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
authEndpoint = this.authenticationConfiguration.authEndpoint || LwaServiceClient.AUTH_ENDPOINT;
if (accessTokenRequest == null) {
throw new Error("Required parameter accessTokenRequest was null or undefined when calling generateAccessToken.");
}
queryParams = [];
headerParams = [];
headerParams.push({ key: 'Content-type', value: 'application/x-www-form-urlencoded' });
pathParams = new Map();
paramInfo = this.grantType === LwaServiceClient.LWA_CREDENTIALS_GRANT_TYPE ? "&refresh_token=" + accessTokenRequest.refreshToken : "&scope=" + accessTokenRequest.scope;
bodyParams = "grant_type=" + this.grantType + "&client_secret=" + accessTokenRequest.clientSecret + "&client_id=" + accessTokenRequest.clientId + paramInfo;
errorDefinitions = new Map();
errorDefinitions.set(200, 'Token request sent.');
errorDefinitions.set(400, 'Bad Request');
errorDefinitions.set(401, 'Authentication Failed');
errorDefinitions.set(500, 'Internal Server Error');
return [4 /*yield*/, this.invoke('POST', authEndpoint, '/auth/O2/token', pathParams, queryParams, headerParams, bodyParams, errorDefinitions, true)];
case 1:
apiResponse = _a.sent();
return [2 /*return*/, apiResponse.body];
}
});
});
};
LwaServiceClient.EXPIRY_OFFSET_MILLIS = 60000;
LwaServiceClient.REFRESH_ACCESS_TOKEN = 'refresh_access_token';
LwaServiceClient.CLIENT_CREDENTIALS_GRANT_TYPE = 'client_credentials';
LwaServiceClient.LWA_CREDENTIALS_GRANT_TYPE = 'refresh_token';
LwaServiceClient.AUTH_ENDPOINT = 'https://api.amazon.com';
return LwaServiceClient;
}(BaseServiceClient));
services.LwaServiceClient = LwaServiceClient;
})(services = exports.services || (exports.services = {}));
/**
* function creating an AskSdk user agent.
* @param packageVersion
* @param customUserAgent
*/
function createUserAgent(packageVersion, customUserAgent) {
var customUserAgentString = customUserAgent ? (' ' + customUserAgent) : '';
return "ask-node-model/" + packageVersion + " Node/" + process.version + customUserAgentString;
}
exports.createUserAgent = createUserAgent;
(function (services) {
var datastore;
(function (datastore) {
/**
*
*/
var DatastoreServiceClient = /** @class */ (function (_super) {
__extends(DatastoreServiceClient, _super);
function DatastoreServiceClient(apiConfiguration, authenticationConfiguration, customUserAgent) {
if (customUserAgent === void 0) { customUserAgent = null; }
var _this = _super.call(this, apiConfiguration) || this;
_this.lwaServiceClient = new services.LwaServiceClient({
apiConfiguration: apiConfiguration,
authenticationConfiguration: authenticationConfiguration,
});
_this.userAgent = createUserAgent("" + require('./package.json').version, customUserAgent);
return _this;
}
/**
* Send DataStore commands to Alexa device.
* @param {services.datastore.v1.CommandsRequest} commandsRequest
*/
DatastoreServiceClient.prototype.callCommandsV1 = function (commandsRequest) {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, accessToken, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
__operationId__ = 'callCommandsV1';
// verify required parameter 'commandsRequest' is not null or undefined
if (commandsRequest == null) {
throw new Error("Required parameter commandsRequest was null or undefined when calling " + __operationId__ + ".");
}
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
if (!headerParams.find(function (param) { return param.key.toLowerCase() === 'content-type'; })) {
headerParams.push({ key: 'Content-type', value: 'application/json' });
}
pathParams = new Map();
return [4 /*yield*/, this.lwaServiceClient.getAccessTokenForScope("alexa::datastore")];
case 1:
accessToken = _a.sent();
authorizationValue = "Bearer " + accessToken;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/datastore/commands";
errorDefinitions = new Map();
errorDefinitions.set(200, "Multiple CommandsDispatchResults in response.");
errorDefinitions.set(400, "Request validation fails.");
errorDefinitions.set(401, "Not Authorized.");
errorDefinitions.set(403, "The skill is not allowed to execute commands.");
errorDefinitions.set(429, "The client has made more calls than the allowed limit.");
errorDefinitions.set(0, "Unexpected error.");
return [2 /*return*/, this.invoke("POST", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, commandsRequest, errorDefinitions)];
}
});
});
};
/**
* Send DataStore commands to Alexa device.
* @param {services.datastore.v1.CommandsRequest} commandsRequest
*/
DatastoreServiceClient.prototype.commandsV1 = function (commandsRequest) {
return __awaiter(this, void 0, void 0, function () {
var apiResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callCommandsV1(commandsRequest)];
case 1:
apiResponse = _a.sent();
return [2 /*return*/, apiResponse.body];
}
});
});
};
/**
* Cancel pending DataStore commands.
* @param {string} queuedResultId A unique identifier to query result for queued delivery for offline devices (DEVICE_UNAVAILABLE).
*/
DatastoreServiceClient.prototype.callCancelCommandsV1 = function (queuedResultId) {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, accessToken, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
__operationId__ = 'callCancelCommandsV1';
// verify required parameter 'queuedResultId' is not null or undefined
if (queuedResultId == null) {
throw new Error("Required parameter queuedResultId was null or undefined when calling " + __operationId__ + ".");
}
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
pathParams = new Map();
pathParams.set('queuedResultId', queuedResultId);
return [4 /*yield*/, this.lwaServiceClient.getAccessTokenForScope("alexa::datastore")];
case 1:
accessToken = _a.sent();
authorizationValue = "Bearer " + accessToken;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/datastore/queue/{queuedResultId}/cancel";
errorDefinitions = new Map();
errorDefinitions.set(204, "Success. No content.");
errorDefinitions.set(400, "Request validation fails.");
errorDefinitions.set(401, "Not Authorized.");
errorDefinitions.set(403, "The skill is not allowed to call this API commands.");
errorDefinitions.set(404, "Unable to find the pending request.");
errorDefinitions.set(429, "The client has made more calls than the allowed limit.");
errorDefinitions.set(0, "Unexpected error.");
return [2 /*return*/, this.invoke("POST", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, null, errorDefinitions)];
}
});
});
};
/**
* Cancel pending DataStore commands.
* @param {string} queuedResultId A unique identifier to query result for queued delivery for offline devices (DEVICE_UNAVAILABLE).
*/
DatastoreServiceClient.prototype.cancelCommandsV1 = function (queuedResultId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callCancelCommandsV1(queuedResultId)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
/**
* Query statuses of deliveries to offline devices returned by commands API.
* @param {string} queuedResultId A unique identifier to query result for queued delivery for offline devices (DEVICE_UNAVAILABLE).
* @param {number} maxResults Maximum number of CommandsDispatchResult items to return.
* @param {string} nextToken The value of nextToken in the response to fetch next page. If not specified, the request fetches result for the first page.
*/
DatastoreServiceClient.prototype.callQueuedResultV1 = function (queuedResultId, maxResults, nextToken) {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, maxResultsValues, nextTokenValues, headerParams, pathParams, accessToken, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
__operationId__ = 'callQueuedResultV1';
// verify required parameter 'queuedResultId' is not null or undefined
if (queuedResultId == null) {
throw new Error("Required parameter queuedResultId was null or undefined when calling " + __operationId__ + ".");
}
queryParams = [];
if (maxResults != null) {
maxResultsValues = Array.isArray(maxResults) ? maxResults : [maxResults];
maxResultsValues.forEach(function (val) { return queryParams.push({ key: 'maxResults', value: val.toString() }); });
}
if (nextToken != null) {
nextTokenValues = Array.isArray(nextToken) ? nextToken : [nextToken];
nextTokenValues.forEach(function (val) { return queryParams.push({ key: 'nextToken', value: val }); });
}
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
pathParams = new Map();
pathParams.set('queuedResultId', queuedResultId);
return [4 /*yield*/, this.lwaServiceClient.getAccessTokenForScope("alexa::datastore")];
case 1:
accessToken = _a.sent();
authorizationValue = "Bearer " + accessToken;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/datastore/queue/{queuedResultId}";
errorDefinitions = new Map();
errorDefinitions.set(200, "Unordered array of CommandsDispatchResult and pagination details.");
errorDefinitions.set(400, "Request validation fails.");
errorDefinitions.set(401, "Not Authorized.");
errorDefinitions.set(403, "The skill is not allowed to call this API commands.");
errorDefinitions.set(429, "The client has made more calls than the allowed limit.");
errorDefinitions.set(0, "Unexpected error.");
return [2 /*return*/, this.invoke("GET", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, null, errorDefinitions)];
}
});
});
};
/**
* Query statuses of deliveries to offline devices returned by commands API.
* @param {string} queuedResultId A unique identifier to query result for queued delivery for offline devices (DEVICE_UNAVAILABLE).
* @param {number} maxResults Maximum number of CommandsDispatchResult items to return.
* @param {string} nextToken The value of nextToken in the response to fetch next page. If not specified, the request fetches result for the first page.
*/
DatastoreServiceClient.prototype.queuedResultV1 = function (queuedResultId, maxResults, nextToken) {
return __awaiter(this, void 0, void 0, function () {
var apiResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callQueuedResultV1(queuedResultId, maxResults, nextToken)];
case 1:
apiResponse = _a.sent();
return [2 /*return*/, apiResponse.body];
}
});
});
};
return DatastoreServiceClient;
}(services.BaseServiceClient));
datastore.DatastoreServiceClient = DatastoreServiceClient;
})(datastore = services.datastore || (services.datastore = {}));
})(services = exports.services || (exports.services = {}));
(function (services) {
var deviceAddress;
(function (deviceAddress) {
/**
*
*/
var DeviceAddressServiceClient = /** @class */ (function (_super) {
__extends(DeviceAddressServiceClient, _super);
function DeviceAddressServiceClient(apiConfiguration, customUserAgent) {
if (customUserAgent === void 0) { customUserAgent = null; }
var _this = _super.call(this, apiConfiguration) || this;
_this.userAgent = createUserAgent("" + require('./package.json').version, customUserAgent);
return _this;
}
/**
* Gets the country and postal code of a device
* @param {string} deviceId The device Id for which to get the country and postal code
*/
DeviceAddressServiceClient.prototype.callGetCountryAndPostalCode = function (deviceId) {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
__operationId__ = 'callGetCountryAndPostalCode';
// verify required parameter 'deviceId' is not null or undefined
if (deviceId == null) {
throw new Error("Required parameter deviceId was null or undefined when calling " + __operationId__ + ".");
}
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
pathParams = new Map();
pathParams.set('deviceId', deviceId);
authorizationValue = "Bearer " + this.apiConfiguration.authorizationValue;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/devices/{deviceId}/settings/address/countryAndPostalCode";
errorDefinitions = new Map();
errorDefinitions.set(200, "Successfully get the country and postal code of the deviceId");
errorDefinitions.set(204, "No content could be queried out");
errorDefinitions.set(403, "The authentication token is invalid or doesn't have access to the resource");
errorDefinitions.set(405, "The method is not supported");
errorDefinitions.set(429, "The request is throttled");
errorDefinitions.set(0, "Unexpected error");
return [2 /*return*/, this.invoke("GET", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, null, errorDefinitions)];
});
});
};
/**
* Gets the country and postal code of a device
* @param {string} deviceId The device Id for which to get the country and postal code
*/
DeviceAddressServiceClient.prototype.getCountryAndPostalCode = function (deviceId) {
return __awaiter(this, void 0, void 0, function () {
var apiResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callGetCountryAndPostalCode(deviceId)];
case 1:
apiResponse = _a.sent();
return [2 /*return*/, apiResponse.body];
}
});
});
};
/**
* Gets the address of a device
* @param {string} deviceId The device Id for which to get the address
*/
DeviceAddressServiceClient.prototype.callGetFullAddress = function (deviceId) {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
__operationId__ = 'callGetFullAddress';
// verify required parameter 'deviceId' is not null or undefined
if (deviceId == null) {
throw new Error("Required parameter deviceId was null or undefined when calling " + __operationId__ + ".");
}
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
pathParams = new Map();
pathParams.set('deviceId', deviceId);
authorizationValue = "Bearer " + this.apiConfiguration.authorizationValue;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/devices/{deviceId}/settings/address";
errorDefinitions = new Map();
errorDefinitions.set(200, "Successfully get the address of the device");
errorDefinitions.set(204, "No content could be queried out");
errorDefinitions.set(403, "The authentication token is invalid or doesn't have access to the resource");
errorDefinitions.set(405, "The method is not supported");
errorDefinitions.set(429, "The request is throttled");
errorDefinitions.set(0, "Unexpected error");
return [2 /*return*/, this.invoke("GET", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, null, errorDefinitions)];
});
});
};
/**
* Gets the address of a device
* @param {string} deviceId The device Id for which to get the address
*/
DeviceAddressServiceClient.prototype.getFullAddress = function (deviceId) {
return __awaiter(this, void 0, void 0, function () {
var apiResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callGetFullAddress(deviceId)];
case 1:
apiResponse = _a.sent();
return [2 /*return*/, apiResponse.body];
}
});
});
};
return DeviceAddressServiceClient;
}(services.BaseServiceClient));
deviceAddress.DeviceAddressServiceClient = DeviceAddressServiceClient;
})(deviceAddress = services.deviceAddress || (services.deviceAddress = {}));
})(services = exports.services || (exports.services = {}));
(function (services) {
var directive;
(function (directive) {
/**
*
*/
var DirectiveServiceClient = /** @class */ (function (_super) {
__extends(DirectiveServiceClient, _super);
function DirectiveServiceClient(apiConfiguration, customUserAgent) {
if (customUserAgent === void 0) { customUserAgent = null; }
var _this = _super.call(this, apiConfiguration) || this;
_this.userAgent = createUserAgent("" + require('./package.json').version, customUserAgent);
return _this;
}
/**
* Send directives to Alexa.
* @param {services.directive.SendDirectiveRequest} sendDirectiveRequest Represents the request object to send in the payload.
*/
DirectiveServiceClient.prototype.callEnqueue = function (sendDirectiveRequest) {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
__operationId__ = 'callEnqueue';
// verify required parameter 'sendDirectiveRequest' is not null or undefined
if (sendDirectiveRequest == null) {
throw new Error("Required parameter sendDirectiveRequest was null or undefined when calling " + __operationId__ + ".");
}
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
if (!headerParams.find(function (param) { return param.key.toLowerCase() === 'content-type'; })) {
headerParams.push({ key: 'Content-type', value: 'application/json' });
}
pathParams = new Map();
authorizationValue = "Bearer " + this.apiConfiguration.authorizationValue;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/directives";
errorDefinitions = new Map();
errorDefinitions.set(204, "Directive sent successfully.");
errorDefinitions.set(400, "Directive not valid.");
errorDefinitions.set(401, "Not Authorized.");
errorDefinitions.set(403, "The skill is not allowed to send directives at the moment.");
errorDefinitions.set(0, "Unexpected error.");
return [2 /*return*/, this.invoke("POST", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, sendDirectiveRequest, errorDefinitions)];
});
});
};
/**
* Send directives to Alexa.
* @param {services.directive.SendDirectiveRequest} sendDirectiveRequest Represents the request object to send in the payload.
*/
DirectiveServiceClient.prototype.enqueue = function (sendDirectiveRequest) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callEnqueue(sendDirectiveRequest)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
return DirectiveServiceClient;
}(services.BaseServiceClient));
directive.DirectiveServiceClient = DirectiveServiceClient;
})(directive = services.directive || (services.directive = {}));
})(services = exports.services || (exports.services = {}));
(function (services) {
var endpointEnumeration;
(function (endpointEnumeration) {
/**
*
*/
var EndpointEnumerationServiceClient = /** @class */ (function (_super) {
__extends(EndpointEnumerationServiceClient, _super);
function EndpointEnumerationServiceClient(apiConfiguration, customUserAgent) {
if (customUserAgent === void 0) { customUserAgent = null; }
var _this = _super.call(this, apiConfiguration) || this;
_this.userAgent = createUserAgent("" + require('./package.json').version, customUserAgent);
return _this;
}
/**
* This API is invoked by the skill to retrieve endpoints connected to the Echo device.
*/
EndpointEnumerationServiceClient.prototype.callGetEndpoints = function () {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
__operationId__ = 'callGetEndpoints';
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
pathParams = new Map();
authorizationValue = "Bearer " + this.apiConfiguration.authorizationValue;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v1/endpoints";
errorDefinitions = new Map();
errorDefinitions.set(200, "Successfully retrieved the list of connected endpoints.");
errorDefinitions.set(400, "Bad request. Returned when a required parameter is not present or badly formatted.");
errorDefinitions.set(401, "Unauthenticated. Returned when the request is not authenticated.");
errorDefinitions.set(403, "Forbidden. Returned when the request is authenticated but does not have sufficient permission.");
errorDefinitions.set(500, "Server Error. Returned when the server encountered an error processing the request.");
errorDefinitions.set(503, "Service Unavailable. Returned when the server is not ready to handle the request.");
errorDefinitions.set(0, "Unexpected error");
return [2 /*return*/, this.invoke("GET", this.apiConfiguration.apiEndpoint, resourcePath, pathParams, queryParams, headerParams, null, errorDefinitions)];
});
});
};
/**
* This API is invoked by the skill to retrieve endpoints connected to the Echo device.
*/
EndpointEnumerationServiceClient.prototype.getEndpoints = function () {
return __awaiter(this, void 0, void 0, function () {
var apiResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callGetEndpoints()];
case 1:
apiResponse = _a.sent();
return [2 /*return*/, apiResponse.body];
}
});
});
};
return EndpointEnumerationServiceClient;
}(services.BaseServiceClient));
endpointEnumeration.EndpointEnumerationServiceClient = EndpointEnumerationServiceClient;
})(endpointEnumeration = services.endpointEnumeration || (services.endpointEnumeration = {}));
})(services = exports.services || (exports.services = {}));
(function (services) {
var listManagement;
(function (listManagement) {
/**
*
*/
var ListManagementServiceClient = /** @class */ (function (_super) {
__extends(ListManagementServiceClient, _super);
function ListManagementServiceClient(apiConfiguration, customUserAgent) {
if (customUserAgent === void 0) { customUserAgent = null; }
var _this = _super.call(this, apiConfiguration) || this;
_this.userAgent = createUserAgent("" + require('./package.json').version, customUserAgent);
return _this;
}
/**
* Retrieves the metadata for all customer lists, including the customer’s default lists.
*/
ListManagementServiceClient.prototype.callGetListsMetadata = function () {
return __awaiter(this, void 0, void 0, function () {
var __operationId__, queryParams, headerParams, pathParams, authorizationValue, resourcePath, errorDefinitions;
return __generator(this, function (_a) {
__operationId__ = 'callGetListsMetadata';
queryParams = [];
headerParams = [];
headerParams.push({ key: 'User-Agent', value: this.userAgent });
pathParams = new Map();
authorizationValue = "Bearer " + this.apiConfiguration.authorizationValue;
headerParams.push({ key: "Authorization", value: authorizationValue });
resourcePath = "/v2/householdlists";
errorDefinitions = new Map();
errorDefinitions.set(200, "Success");
errorDefinitions.set(403, "Forbidden");
errorDefinitions.set(500, "Internal Server Error");
return [2 /*return*/, this.invoke("GET", "https://api