UNPKG

chargebee-typescript

Version:

A library in typescript for integrating with Chargebee.

279 lines (278 loc) 10.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Download = exports.Export = void 0; const request_wrapper_1 = require("../request_wrapper"); const model_1 = require("./model"); const chargebee_1 = require("../chargebee"); const process_wait_1 = require("../process_wait"); class Export extends model_1.Model { static wait_for_export_completion(exportId) { let count = 0; let export_retrieve = Export.retrieve(exportId); let ret = function (deferred, _self) { export_retrieve.request(function (error, result) { if (error) { deferred.reject(error); } else { let exportObj = result.export; if (exportObj.status === 'completed') { deferred.resolve(result); } else if (exportObj.status === 'in_process') { if (count++ > 30) { throw new Error("Export is taking too long"); } setTimeout(function () { ret(deferred, _self); }, _self.env.exportWaitInMillis); } else { deferred.reject(result); } } }); }; return new process_wait_1.ProcessWait(ret, chargebee_1.ChargeBee._env); } // OPERATIONS //----------- static retrieve(export_id, params) { return new request_wrapper_1.RequestWrapper([export_id, params], { 'methodName': 'retrieve', 'httpMethod': 'GET', 'urlPrefix': '/exports', 'urlSuffix': null, 'hasIdInUrl': true, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static revenue_recognition(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'revenue_recognition', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/revenue_recognition', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static deferred_revenue(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'deferred_revenue', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/deferred_revenue', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static plans(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'plans', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/plans', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static addons(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'addons', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/addons', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static coupons(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'coupons', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/coupons', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static customers(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'customers', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/customers', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static subscriptions(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'subscriptions', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/subscriptions', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static invoices(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'invoices', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/invoices', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static credit_notes(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'credit_notes', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/credit_notes', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static transactions(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'transactions', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/transactions', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static orders(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'orders', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/orders', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static item_families(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'item_families', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/item_families', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static items(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'items', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/items', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static item_prices(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'item_prices', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/item_prices', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static attached_items(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'attached_items', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/attached_items', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static differential_prices(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'differential_prices', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/differential_prices', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static price_variants(params) { return new request_wrapper_1.RequestWrapper([params], { 'methodName': 'price_variants', 'httpMethod': 'POST', 'urlPrefix': '/exports', 'urlSuffix': '/price_variants', 'hasIdInUrl': false, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } } // ~Export exports.Export = Export; class Download extends model_1.Model { } // ~Download exports.Download = Download;