Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
fix: Remove files class (#89)
Browse files Browse the repository at this point in the history
* fix: Remove Files class

* build: Rollup
  • Loading branch information
ynnoj authored and outrunthewolf committed Jul 14, 2017
1 parent 1dfffc8 commit f3be1ac
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 277 deletions.
2 changes: 1 addition & 1 deletion dist/moltin.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/moltin.cjs.js.map

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions src/endpoints/files.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/factories/request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import StorageFactory from './storage';

import { setHeaderContentType, buildRequestBody, parseJSON } from '../utils/helpers';
import { buildRequestBody, parseJSON } from '../utils/helpers';

class RequestFactory {
constructor(config) {
Expand Down Expand Up @@ -61,7 +61,7 @@ class RequestFactory {
const req = () => {
const headers = {
Authorization: `Bearer: ${storage.get('mtoken')}`,
'Content-Type': setHeaderContentType(uri, method),
'Content-Type': 'application/json',
'X-MOLTIN-SDK-LANGUAGE': config.sdk.language,
'X-MOLTIN-SDK-VERSION': config.sdk.version,
};
Expand Down
2 changes: 0 additions & 2 deletions src/moltin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import CategoriesEndpoint from './endpoints/categories';
import CollectionsEndpoint from './endpoints/collections';
import OrdersEndpoint from './endpoints/orders';
import GatewaysEndpoint from './endpoints/gateways';
import FilesEndpoint from './endpoints/files';

export default class Moltin {
constructor(config) {
Expand All @@ -28,7 +27,6 @@ export default class Moltin {
this.Collections = new CollectionsEndpoint(config);
this.Orders = new OrdersEndpoint(config);
this.Gateways = new GatewaysEndpoint(config);
this.Files = new FilesEndpoint(config);
}

// Expose `authenticate` function on the Moltin class
Expand Down
19 changes: 6 additions & 13 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ export function parseJSON(response) {
})));
}

export function setHeaderContentType(uri, method) {
let contentType = 'application/json';

if (uri === 'files' && method === 'POST') {
contentType = 'multipart/form-data';
}

return contentType;
}

function formatFilterString(type, filter) {
const filterStringArray = Object.keys(filter).map((key) => {
const value = filter[key];
Expand Down Expand Up @@ -120,13 +110,16 @@ export function buildURL(endpoint, params) {
return endpoint;
}


export function buildRequestBody(body) {
let parsedBody = null;

if (body) {
return `{"data":${JSON.stringify(body)}}`;
parsedBody = `{
"data": ${JSON.stringify(body)}
}`;
}

return null;
return parsedBody;
}

export function buildCartItemData(product, quantity, type = 'cart_item') {
Expand Down
239 changes: 0 additions & 239 deletions test/unit/files.js

This file was deleted.

0 comments on commit f3be1ac

Please sign in to comment.