baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
79 lines (78 loc) • 3.77 kB
JavaScript
;
/* globals module */
/**
* @module commerceInvoiceStreamsClient
* @description Commerce Invoice Streams Client provides an easy way to consume Commerce REST API end-points. In order to obtain a needed routes `commerceInvoiceStreamsClient` uses `commerceInvoiceStreamsRoute`.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var inversify_1 = require("inversify");
;
var httpApi_1 = require("../../../httpApi");
var __1 = require("../");
var CommerceInvoiceStreamsClient = /** @class */ (function () {
function CommerceInvoiceStreamsClient(commerceInvoiceStreamsRoute, apiClient) {
this.commerceInvoiceStreamsRoute = commerceInvoiceStreamsRoute;
this.apiClient = apiClient;
}
Object.defineProperty(CommerceInvoiceStreamsClient.prototype, "routeDefinition", {
get: function () {
return this.commerceInvoiceStreamsRoute;
},
enumerable: true,
configurable: true
});
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the invoice stream if successfully completed.
* @method
* @example // commerceInvoice is a resource previously fetched using get action.
commerceInvoiceStreamsClient.get({id: commerceInvoice.id})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
CommerceInvoiceStreamsClient.prototype.get = function (data) {
return this.apiClient.get(this.routeDefinition.get(data));
};
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the invoice stream as a blob. For more information on Blob objects please see [Blob Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
* @method
* @example // Request the original blob
commerceInvoiceClient.getBlobl({id: commerceInvoice.id})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
CommerceInvoiceStreamsClient.prototype.getBlob = function (data) {
return this.apiClient.request({
url: this.commerceInvoiceStreamsRoute.get(data),
responseType: 'blob',
headers: { 'Accept': 'application/octet-stream' },
method: 'GET'
});
};
CommerceInvoiceStreamsClient = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(__1.TYPES.CommerceInvoiceStreamsRoute)),
tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)),
tslib_1.__metadata("design:paramtypes", [__1.CommerceInvoiceStreamsRoute,
httpApi_1.ApiClient])
], CommerceInvoiceStreamsClient);
return CommerceInvoiceStreamsClient;
}());
exports.CommerceInvoiceStreamsClient = CommerceInvoiceStreamsClient;
/**
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @overview
***Notes:**
- Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/