UNPKG

chargebee-typescript

Version:

A library in typescript for integrating with Chargebee.

81 lines (80 loc) 3.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeMachine = 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 TimeMachine extends model_1.Model { static wait_for_time_travel_completion() { let count = 0; let time_machine_retrieve = TimeMachine.retrieve("delorean"); let ret = function (deferred, _self) { time_machine_retrieve.request(function (error, result) { if (error) { deferred.reject(error); } else { let time_machine = result.time_machine; if (time_machine.time_travel_status === 'succeeded') { deferred.resolve(result); } else if (time_machine.time_travel_status === 'in_progress') { if (count++ > 30) { throw new Error("The time travel is taking too much time"); } setTimeout(function () { ret(deferred, _self); }, _self.env.timemachineWaitInMillis); } else { deferred.reject(result); } } }); }; return new process_wait_1.ProcessWait(ret, chargebee_1.ChargeBee._env); } // OPERATIONS //----------- static retrieve(time_machine_id, params) { return new request_wrapper_1.RequestWrapper([time_machine_id, params], { 'methodName': 'retrieve', 'httpMethod': 'GET', 'urlPrefix': '/time_machines', 'urlSuffix': null, 'hasIdInUrl': true, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static start_afresh(time_machine_id, params) { return new request_wrapper_1.RequestWrapper([time_machine_id, params], { 'methodName': 'start_afresh', 'httpMethod': 'POST', 'urlPrefix': '/time_machines', 'urlSuffix': '/start_afresh', 'hasIdInUrl': true, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } static travel_forward(time_machine_id, params) { return new request_wrapper_1.RequestWrapper([time_machine_id, params], { 'methodName': 'travel_forward', 'httpMethod': 'POST', 'urlPrefix': '/time_machines', 'urlSuffix': '/travel_forward', 'hasIdInUrl': true, 'isListReq': false, 'subDomain': null, 'isOperationNeedsJsonInput': false, 'jsonKeys': {} }, chargebee_1.ChargeBee._env); } } // ~TimeMachine exports.TimeMachine = TimeMachine;