UNPKG

@openweb3-io/wallet-pay

Version:

Wallet Pay API client and wallet pay verification library

282 lines 19.5 kB
"use strict"; 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.WebhookEndpointApiResponseProcessor = exports.WebhookEndpointApiRequestFactory = void 0; const baseapi_1 = require("./baseapi"); const http_1 = require("../http/http"); const ObjectSerializer_1 = require("../models/ObjectSerializer"); const exception_1 = require("./exception"); const util_1 = require("../util"); class WebhookEndpointApiRequestFactory extends baseapi_1.BaseAPIRequestFactory { v1EndpointCreate(endpointIn, _options) { return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (endpointIn === null || endpointIn === undefined) { throw new baseapi_1.RequiredError('Required parameter endpointIn was null or undefined when calling v1EndpointCreate.'); } const localVarPath = '/api/v1/webhooks/endpoints'; const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const randomId = Math.floor(Math.random() * Math.pow(2, 32)); requestContext.setHeaderParam("pay-req-id", randomId.toString()); const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(endpointIn, "EndpointIn", ""), contentType); requestContext.setBody(serializedBody); let authMethod = null; authMethod = _config.authMethods["ApiKeyAuth"]; if (authMethod) { yield authMethod.applySecurityAuthentication(requestContext); } return requestContext; }); } v1EndpointDelete(endpointId, _options) { return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (endpointId === null || endpointId === undefined) { throw new baseapi_1.RequiredError('Required parameter endpointId was null or undefined when calling v1EndpointDelete.'); } const localVarPath = '/api/v1/webhooks/endpoints/{endpointId}' .replace('{' + 'endpointId' + '}', encodeURIComponent(String(endpointId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const randomId = Math.floor(Math.random() * Math.pow(2, 32)); requestContext.setHeaderParam("pay-req-id", randomId.toString()); let authMethod = null; authMethod = _config.authMethods["ApiKeyAuth"]; if (authMethod) { yield authMethod.applySecurityAuthentication(requestContext); } return requestContext; }); } v1EndpointGet(endpointId, _options) { return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (endpointId === null || endpointId === undefined) { throw new baseapi_1.RequiredError('Required parameter endpointId was null or undefined when calling v1EndpointGet.'); } const localVarPath = '/api/v1/webhooks/endpoints/{endpointId}' .replace('{' + 'endpointId' + '}', encodeURIComponent(String(endpointId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const randomId = Math.floor(Math.random() * Math.pow(2, 32)); requestContext.setHeaderParam("pay-req-id", randomId.toString()); let authMethod = null; authMethod = _config.authMethods["ApiKeyAuth"]; if (authMethod) { yield authMethod.applySecurityAuthentication(requestContext); } return requestContext; }); } v1EndpointList(limit, cursor, ordering, _options) { return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; const localVarPath = '/api/v1/webhooks/endpoints'; const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const randomId = Math.floor(Math.random() * Math.pow(2, 32)); requestContext.setHeaderParam("pay-req-id", randomId.toString()); if (limit !== undefined) { requestContext.setQueryParam("limit", ObjectSerializer_1.ObjectSerializer.serialize(limit, "number", "uint64")); } if (cursor !== undefined) { requestContext.setQueryParam("cursor", ObjectSerializer_1.ObjectSerializer.serialize(cursor, "string", "")); } if (ordering !== undefined) { requestContext.setQueryParam("ordering", ObjectSerializer_1.ObjectSerializer.serialize(ordering, "Ordering", "")); } let authMethod = null; authMethod = _config.authMethods["ApiKeyAuth"]; if (authMethod) { yield authMethod.applySecurityAuthentication(requestContext); } return requestContext; }); } } exports.WebhookEndpointApiRequestFactory = WebhookEndpointApiRequestFactory; class WebhookEndpointApiResponseProcessor { v1EndpointCreate(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (util_1.isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } if (util_1.isCodeInRange("201", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } if (util_1.isCodeInRange("400", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(400, body); } if (util_1.isCodeInRange("401", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(401, body); } if (util_1.isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(403, body); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(404, body); } if (util_1.isCodeInRange("409", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(409, body); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(429, body); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(500, body); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } let body = yield response.body.text(); throw new exception_1.ApiException(response.httpStatusCode, body); }); } v1EndpointDelete(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (util_1.isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } if (util_1.isCodeInRange("201", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } if (util_1.isCodeInRange("401", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(401, body); } if (util_1.isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(403, body); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(404, body); } if (util_1.isCodeInRange("409", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(409, body); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(429, body); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(500, body); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } let body = yield response.body.text(); throw new exception_1.ApiException(response.httpStatusCode, body); }); } v1EndpointGet(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (util_1.isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } if (util_1.isCodeInRange("201", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } if (util_1.isCodeInRange("401", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(401, body); } if (util_1.isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(403, body); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(404, body); } if (util_1.isCodeInRange("409", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(409, body); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(429, body); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(500, body); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseEndpointOut", ""); return body; } let body = yield response.body.text(); throw new exception_1.ApiException(response.httpStatusCode, body); }); } v1EndpointList(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (util_1.isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseListEndpointOut", ""); return body; } if (util_1.isCodeInRange("401", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(401, body); } if (util_1.isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(403, body); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(404, body); } if (util_1.isCodeInRange("409", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(409, body); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseError", ""); throw new exception_1.ApiException(429, body); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "ResponseListEndpointOut", ""); return body; } let body = yield response.body.text(); throw new exception_1.ApiException(response.httpStatusCode, body); }); } } exports.WebhookEndpointApiResponseProcessor = WebhookEndpointApiResponseProcessor; //# sourceMappingURL=WebhookEndpointApi.js.map