diff --git a/__tests__/index.test.js b/__tests__/index.test.js index a56a699..a47c2b7 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -70,6 +70,7 @@ test('api structure', () => { expect(typeof api.orders.close).toBe('function'); expect(typeof api.orders.updateBillingAddress).toBe('function'); expect(typeof api.orders.updateShippingAddress).toBe('function'); + expect(typeof api.orders.updateSubsidiary).toBe('function'); expect(typeof api.orders.getPaymentFormSettings).toBe('function'); expect(typeof api.orders.discounts.create).toBe('function'); expect(typeof api.orders.discounts.update).toBe('function'); @@ -85,11 +86,40 @@ test('api structure', () => { expect(typeof api.orderStatuses.create).toBe('function'); expect(typeof api.orderStatuses.update).toBe('function'); expect(typeof api.orderStatuses.delete).toBe('function'); + expect(typeof api.prescriptions.list).toBe('function'); + expect(typeof api.prescriptions.retrieve).toBe('function'); + expect(typeof api.prescriptions.create).toBe('function'); + expect(typeof api.prescriptions.update).toBe('function'); + expect(typeof api.prescriptions.delete).toBe('function'); + expect(typeof api.prescriptions.estimate).toBe('function'); + expect(typeof api.prescriptions.checkout).toBe('function'); + expect(typeof api.prescriptions.cancel).toBe('function'); + expect(typeof api.prescriptions.close).toBe('function'); + expect(typeof api.prescriptions.updateBillingAddress).toBe('function'); + expect(typeof api.prescriptions.updateShippingAddress).toBe('function'); + expect(typeof api.prescriptions.updateSubsidiary).toBe('function'); + expect(typeof api.prescriptions.getPaymentFormSettings).toBe('function'); + expect(typeof api.prescriptions.transactions.create).toBe('function'); + expect(typeof api.prescriptions.transactions.update).toBe('function'); + expect(typeof api.prescriptions.transactions.delete).toBe('function'); + expect(typeof api.prescriptions.items.create).toBe('function'); + expect(typeof api.prescriptions.items.update).toBe('function'); + expect(typeof api.prescriptions.items.delete).toBe('function'); + expect(typeof api.prescriptionStatuses.list).toBe('function'); + expect(typeof api.prescriptionStatuses.retrieve).toBe('function'); + expect(typeof api.prescriptionStatuses.create).toBe('function'); + expect(typeof api.prescriptionStatuses.update).toBe('function'); + expect(typeof api.prescriptionStatuses.delete).toBe('function'); expect(typeof api.shippingMethods.list).toBe('function'); expect(typeof api.shippingMethods.retrieve).toBe('function'); expect(typeof api.shippingMethods.create).toBe('function'); expect(typeof api.shippingMethods.update).toBe('function'); expect(typeof api.shippingMethods.delete).toBe('function'); + expect(typeof api.subsidiaries.list).toBe('function'); + expect(typeof api.subsidiaries.retrieve).toBe('function'); + expect(typeof api.subsidiaries.create).toBe('function'); + expect(typeof api.subsidiaries.update).toBe('function'); + expect(typeof api.subsidiaries.delete).toBe('function'); expect(typeof api.paymentMethods.list).toBe('function'); expect(typeof api.paymentMethods.retrieve).toBe('function'); expect(typeof api.paymentMethods.create).toBe('function'); diff --git a/package-lock.json b/package-lock.json index 1103ed8..ab1229d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "cezerin-client", - "version": "0.34.0", + "name": "natal-client", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -247,6 +247,7 @@ "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -2742,7 +2743,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3157,7 +3159,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3213,6 +3216,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3256,12 +3260,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -5847,7 +5853,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true + "dev": true, + "optional": true }, "loose-envify": { "version": "1.3.1", @@ -7361,7 +7368,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7382,12 +7390,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7402,17 +7412,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7529,7 +7542,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7541,6 +7555,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7555,6 +7570,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7562,12 +7578,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7586,6 +7604,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7666,7 +7685,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7678,6 +7698,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7763,7 +7784,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -7799,6 +7821,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7818,6 +7841,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7861,12 +7885,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/package.json b/package.json index d47ff6e..ee20ce2 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,26 @@ { - "name": "cezerin-client", - "version": "0.34.0", - "description": "Cezerin API client library. Work on browser and server.", + "name": "natal-client", + "version": "1.9.2", + "description": "Natal API client library. Work on browser and server.", "keywords": [ - "cezerin", - "cezerin api", - "cezerin ajax", - "cezerin web store", + "natal", + "natal api", + "natal ajax", + "natal web store", "ecommerce api", "shopping cart api" ], - "homepage": "https://cezerin.com", - "bugs": "https://github.com/cezerin/client/issues", + "homepage": "https://natal.com.ar", + "bugs": "https://github.com/rodriperez/client/issues", "license": "MIT", "author": { - "name": "Restmount ", - "url": "https://github.com/restmount" + "name": "Rodrigo ", + "url": "https://github.com/rodriperez" }, - "contributors": [ - { - "name": "Restmount ", - "url": "https://github.com/restmount" - }, - { - "name": "Sergey Onufrienko ", - "url": "https://github.com/sonufrienko" - } - ], "main": "lib/index.js", "repository": { "type": "git", - "url": "https://github.com/cezerin/client" + "url": "https://github.com/rodriperez/client" }, "scripts": { "build": "babel src -d lib", diff --git a/src/api/ajaxCart.js b/src/api/ajaxCart.js index fb14d39..7acbf2e 100644 --- a/src/api/ajaxCart.js +++ b/src/api/ajaxCart.js @@ -23,6 +23,10 @@ export default class AjaxCart { return this.client.put(`/cart/shipping_address`, address); } + updateSubsidiary(subsidiary) { + return this.client.put(`/cart/subsidiary`, subsidiary); + } + addItem(data) { return this.client.post(`/cart/items`, data); } diff --git a/src/api/ajaxPaymentMethods.js b/src/api/ajaxPaymentMethods.js index 0db471f..cf2d401 100644 --- a/src/api/ajaxPaymentMethods.js +++ b/src/api/ajaxPaymentMethods.js @@ -6,4 +6,8 @@ export default class AjaxPaymentMethods { list() { return this.client.get('/payment_methods'); } + + prescriptions() { + return this.client.get('/payment_methods/prescriptions'); + } } diff --git a/src/api/ajaxPrescription.js b/src/api/ajaxPrescription.js new file mode 100644 index 0000000..eba5664 --- /dev/null +++ b/src/api/ajaxPrescription.js @@ -0,0 +1,41 @@ +export default class AjaxPrescription { + constructor(client) { + this.client = client; + } + + retrieve(orderId) { + return this.client.get(`/prescription/${orderId}`); + } + + create() { + return this.client.post(`/prescription`); + } + + update(orderId, data) { + return this.client.put(`/prescription/${orderId}`, data); + } + + checkout(orderId, data) { + return this.client.put(`/prescription/${orderId}/checkout`, data); + } + + confirmPrescription(orderId) { + return this.client.put(`/prescription/${orderId}/confirm`); + } + + uploadPrescription(orderId, data) { + return this.client.postFormData(`/prescription/${orderId}/items`, data); + } + + uploadLicense(orderId, data) { + return this.client.postFormData(`/prescription/${orderId}/licenses`, data); + } + + deleteLicense(orderId, fileId) { + return this.client.delete(`/prescription/${orderId}/licenses/${fileId}`); + } + + deleteFile(orderId, fileId) { + return this.client.delete(`/prescription/${orderId}/items/${fileId}`); + } +} diff --git a/src/api/ajaxShippingMethods.js b/src/api/ajaxShippingMethods.js index b4dba9c..b280035 100644 --- a/src/api/ajaxShippingMethods.js +++ b/src/api/ajaxShippingMethods.js @@ -6,4 +6,12 @@ export default class AjaxShippingMethods { list() { return this.client.get('/shipping_methods'); } + + prescriptions() { + return this.client.get('/shipping_methods/prescriptions'); + } + + getSubsidiaries() { + return this.client.get('/subsidiaries'); + } } diff --git a/src/api/orders/orders.js b/src/api/orders/orders.js index 922f57b..49b1b20 100644 --- a/src/api/orders/orders.js +++ b/src/api/orders/orders.js @@ -47,6 +47,13 @@ export default class Orders { ); } + updateAvailability(orderId, available) { + return this.client.put( + `${this.resourceUrl}/${orderId}/confim_availability`, + available + ); + } + updateShippingAddress(orderId, address) { return this.client.put( `${this.resourceUrl}/${orderId}/shipping_address`, @@ -54,9 +61,20 @@ export default class Orders { ); } + updateSubsidiary(orderId, subsidiary) { + return this.client.put( + `${this.resourceUrl}/${orderId}/subsidiary`, + subsidiary + ); + } + getPaymentFormSettings(orderId) { return this.client.get( `${this.resourceUrl}/${orderId}/payment_form_settings` ); } + + download(dates) { + return this.client.download(`${this.resourceUrl}/export`, dates); + } } diff --git a/src/api/prescriptions/items.js b/src/api/prescriptions/items.js new file mode 100644 index 0000000..ad58abf --- /dev/null +++ b/src/api/prescriptions/items.js @@ -0,0 +1,48 @@ +export default class PrescriptionItems { + constructor(client) { + this.client = client; + } + + create(prescriptionId, data) { + return this.client.post(`/prescriptions/${prescriptionId}/items`, data); + } + + update(prescriptionId, itemId, data) { + return this.client.put( + `/prescriptions/${prescriptionId}/items/${itemId}`, + data + ); + } + + delete(prescriptionId, itemId) { + return this.client.delete( + `/prescriptions/${prescriptionId}/items/${itemId}` + ); + } + + uploadPrescription(prescriptionId, data) { + return this.client.postFormData( + `/prescriptions/${prescriptionId}/medications`, + data + ); + } + + uploadLicense(prescriptionId, data) { + return this.client.postFormData( + `/prescriptions/${prescriptionId}/licenses`, + data + ); + } + + deleteLicense(prescriptionId, fileId) { + return this.client.delete( + `/prescriptions/${prescriptionId}/licenses/${fileId}` + ); + } + + deletePrescription(prescriptionId, fileId) { + return this.client.delete( + `/prescriptions/${prescriptionId}/medications/${fileId}` + ); + } +} diff --git a/src/api/prescriptions/medicines.js b/src/api/prescriptions/medicines.js new file mode 100644 index 0000000..a67704d --- /dev/null +++ b/src/api/prescriptions/medicines.js @@ -0,0 +1,34 @@ +export default class Medicines { + constructor(client) { + this.client = client; + this.resourceUrl = '/medicines'; + } + + list(filter) { + return this.client.get(this.resourceUrl, filter); + } + + retrieve(id, filter) { + return this.client.get(`${this.resourceUrl}/${id}`, filter); + } + + create(data) { + return this.client.post(this.resourceUrl, data); + } + + update(id, data) { + return this.client.put(`${this.resourceUrl}/${id}`, data); + } + + delete(id) { + return this.client.delete(`${this.resourceUrl}/${id}`); + } + + import(formData) { + return this.client.postFormData(`${this.resourceUrl}/import`, formData); + } + + download() { + return this.client.download(`${this.resourceUrl}/export`); + } +} diff --git a/src/api/prescriptions/prescriptions.js b/src/api/prescriptions/prescriptions.js new file mode 100644 index 0000000..7e3bb85 --- /dev/null +++ b/src/api/prescriptions/prescriptions.js @@ -0,0 +1,90 @@ +export default class Prescriptions { + constructor(client) { + this.client = client; + this.resourceUrl = '/prescriptions'; + } + + list(filter) { + return this.client.get(this.resourceUrl, filter); + } + + retrieve(prescriptionId, filter) { + return this.client.get(`${this.resourceUrl}/${prescriptionId}`, filter); + } + + create(data) { + return this.client.post(this.resourceUrl, data); + } + + update(prescriptionId, data) { + return this.client.put(`${this.resourceUrl}/${prescriptionId}`, data); + } + + delete(prescriptionId) { + return this.client.delete(`${this.resourceUrl}/${prescriptionId}`); + } + + estimate(prescriptionId, data) { + return this.client.put( + `${this.resourceUrl}/${prescriptionId}/estimate`, + data + ); + } + + checkout(prescriptionId, data) { + return this.client.put( + `${this.resourceUrl}/${prescriptionId}/checkout`, + data + ); + } + + cancel(prescriptionId) { + return this.client.put(`${this.resourceUrl}/${prescriptionId}/cancel`); + } + + close(prescriptionId) { + return this.client.put(`${this.resourceUrl}/${prescriptionId}/close`); + } + + updateBillingAddress(prescriptionId, address) { + return this.client.put( + `${this.resourceUrl}/${prescriptionId}/billing_address`, + address + ); + } + + updateAvailability(prescriptionId, available) { + return this.client.put( + `${this.resourceUrl}/${prescriptionId}/confim_availability`, + available + ); + } + + updateShippingAddress(prescriptionId, address) { + return this.client.put( + `${this.resourceUrl}/${prescriptionId}/shipping_address`, + address + ); + } + + updateSubsidiary(prescriptionId, subsidiary) { + return this.client.put( + `${this.resourceUrl}/${prescriptionId}/subsidiary`, + subsidiary + ); + } + + getPaymentFormSettings(prescriptionId) { + return this.client.get( + `${this.resourceUrl}/${prescriptionId}/payment_form_settings` + ); + } + + confirm(prescriptionId) { + return this.client.put(`${this.resourceUrl}/${prescriptionId}/confirm`); + } + + sendEmail(prescriptionId) { + return this.client.post(`${this.resourceUrl}/${prescriptionId}/email`); + } +} diff --git a/src/api/prescriptions/statuses.js b/src/api/prescriptions/statuses.js new file mode 100644 index 0000000..0336e61 --- /dev/null +++ b/src/api/prescriptions/statuses.js @@ -0,0 +1,26 @@ +export default class PrescriptionStatuses { + constructor(client) { + this.client = client; + this.resourceUrl = '/prescription_statuses'; + } + + list(filter) { + return this.client.get(this.resourceUrl, filter); + } + + retrieve(id, filter) { + return this.client.get(`${this.resourceUrl}/${id}`, filter); + } + + create(data) { + return this.client.post(this.resourceUrl, data); + } + + update(id, data) { + return this.client.put(`${this.resourceUrl}/${id}`, data); + } + + delete(id) { + return this.client.delete(`${this.resourceUrl}/${id}`); + } +} diff --git a/src/api/prescriptions/transactions.js b/src/api/prescriptions/transactions.js new file mode 100644 index 0000000..af10882 --- /dev/null +++ b/src/api/prescriptions/transactions.js @@ -0,0 +1,25 @@ +export default class PrescriptionTransactions { + constructor(client) { + this.client = client; + } + + create(prescriptionId, data) { + return this.client.post( + `/prescriptions/${prescriptionId}/transactions`, + data + ); + } + + update(prescriptionId, transactionId, data) { + return this.client.put( + `/prescriptions/${prescriptionId}/transactions/${transactionId}`, + data + ); + } + + delete(prescriptionId, transactionId) { + return this.client.delete( + `/prescriptions/${prescriptionId}/transactions/${transactionId}` + ); + } +} diff --git a/src/api/products/products.js b/src/api/products/products.js index 071c6e1..d444f62 100644 --- a/src/api/products/products.js +++ b/src/api/products/products.js @@ -16,6 +16,10 @@ export default class Products { return this.client.post(this.resourceUrl, data); } + import(formData) { + return this.client.postFormData(`${this.resourceUrl}/import`, formData); + } + update(id, data) { return this.client.put(`${this.resourceUrl}/${id}`, data); } diff --git a/src/api/shippingRules.js b/src/api/shippingRules.js new file mode 100644 index 0000000..273c6fe --- /dev/null +++ b/src/api/shippingRules.js @@ -0,0 +1,26 @@ +export default class ShippingRules { + constructor(client) { + this.client = client; + this.resourceUrl = '/shipping_rules'; + } + + list(filter) { + return this.client.get(this.resourceUrl, filter); + } + + retrieve(id, filter) { + return this.client.get(`${this.resourceUrl}/${id}`, filter); + } + + create(data) { + return this.client.post(`${this.resourceUrl}`, data); + } + + update(id, data) { + return this.client.put(`${this.resourceUrl}/${id}`, data); + } + + delete(id) { + return this.client.delete(`${this.resourceUrl}/${id}`); + } +} diff --git a/src/api/subsidiaries.js b/src/api/subsidiaries.js new file mode 100644 index 0000000..7cad981 --- /dev/null +++ b/src/api/subsidiaries.js @@ -0,0 +1,26 @@ +export default class Subsidiaries { + constructor(client) { + this.client = client; + this.resourceUrl = '/subsidiaries'; + } + + list(filter) { + return this.client.get(this.resourceUrl, filter); + } + + retrieve(id, filter) { + return this.client.get(`${this.resourceUrl}/${id}`, filter); + } + + create(data) { + return this.client.post(`${this.resourceUrl}`, data); + } + + update(id, data) { + return this.client.put(`${this.resourceUrl}/${id}`, data); + } + + delete(id) { + return this.client.delete(`${this.resourceUrl}/${id}`); + } +} diff --git a/src/apiClient.js b/src/apiClient.js index 2243ac7..454ab7f 100644 --- a/src/apiClient.js +++ b/src/apiClient.js @@ -2,13 +2,13 @@ import fetch from 'cross-fetch'; import RestClient from './restClient'; export default class ApiClient extends RestClient { - static authorize = (baseUrl, email) => { + static authorize = (baseUrl, email, password) => { const config = { method: 'post', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ email }) + body: JSON.stringify({ email, password }) }; return fetch(`${baseUrl}/authorize`, config).then( RestClient.returnStatusAndJson diff --git a/src/index.js b/src/index.js index da39438..f0ed3fd 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,10 @@ import CustomerGroups from './api/customerGroups'; import Customers from './api/customers'; import AjaxCart from './api/ajaxCart'; import Orders from './api/orders/orders'; +import Prescriptions from './api/prescriptions/prescriptions'; +import PrescriptionItems from './api/prescriptions/items'; +import PrescriptionStatuses from './api/prescriptions/statuses'; +import PrescriptionTransactions from './api/prescriptions/transactions'; import OrderDiscounts from './api/orders/discounts'; import OrderTransactions from './api/orders/transactions'; import OrderItems from './api/orders/items'; @@ -42,6 +46,10 @@ import WebStoreServices from './webstore/services'; import WebStoreServiceSettings from './webstore/serviceSettings'; import WebStoreServiceActions from './webstore/serviceActions'; import WebStoreServiceLogs from './webstore/serviceLogs'; +import Subsidiaries from './api/subsidiaries'; +import AjaxPrescription from './api/ajaxPrescription'; +import Medicines from './api/prescriptions/medicines'; +import ShippingRules from './api/shippingRules'; export default class Client { constructor(options = {}) { @@ -69,7 +77,16 @@ export default class Client { this.orders.transactions = new OrderTransactions(apiClient); this.orders.items = new OrderItems(apiClient); this.orderStatuses = new OrderStatuses(apiClient); + // prescriptions + this.prescriptions = new Prescriptions(apiClient); + this.prescriptions.items = new PrescriptionItems(apiClient); + this.prescriptions.transactions = new PrescriptionTransactions(apiClient); + this.prescriptionStatuses = new PrescriptionStatuses(apiClient); + this.medicines = new Medicines(apiClient); + this.shippingMethods = new ShippingMethods(apiClient); + this.shippingRules = new ShippingRules(apiClient); + this.subsidiaries = new Subsidiaries(apiClient); this.paymentMethods = new PaymentMethods(apiClient); this.paymentGateways = new PaymentGateways(apiClient); this.customerGroups = new CustomerGroups(apiClient); @@ -95,6 +112,7 @@ export default class Client { this.ajax.products = new Products(ajaxClient); this.ajax.sitemap = new Sitemap(ajaxClient); this.ajax.cart = new AjaxCart(ajaxClient); + this.ajax.prescription = new AjaxPrescription(ajaxClient); this.ajax.countries = new Countries(ajaxClient); this.ajax.currencies = new Currencies(ajaxClient); this.ajax.shippingMethods = new AjaxShippingMethods(ajaxClient); @@ -112,7 +130,8 @@ export default class Client { this.webstore.services.logs = new WebStoreServiceLogs(webstoreClient); } - static authorize = (baseUrl, email) => ApiClient.authorize(baseUrl, email); + static authorize = (baseUrl, email, password) => + ApiClient.authorize(baseUrl, email, password); static authorizeInWebStore = (email, adminUrl) => WebStoreClient.authorize(email, adminUrl); diff --git a/src/restClient.js b/src/restClient.js index 72626f6..c1d1be4 100644 --- a/src/restClient.js +++ b/src/restClient.js @@ -73,4 +73,15 @@ export default class RestClient { this.returnStatusAndJson ); } + + download(endpoint, data = {}) { + const config = { + method: 'get', + headers: { + Authorization: `Bearer ${this.token}` + }, + responseType: 'arraybuffer' + }; + return fetch(`${this.baseUrl}${endpoint}?${queryString.stringify(data)}`, config); + } }