Skip to content

Commit

Permalink
NO-TASK: initial structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Kucmus committed May 14, 2019
1 parent 166cda6 commit 41c9176
Show file tree
Hide file tree
Showing 44 changed files with 1,797 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vsf-shopware-indexer/node_modules/
vsf-shopware-indexer/node_modules
vsf-shopware-indexer/*.log
vsf-shopware-indexer/logs/*.log
vsf-shopware-indexer/config.js
logs/*.log
.idea/*
24 changes: 24 additions & 0 deletions vsf-api-extension/address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import AbstractAddressProxy from '../abstract/address'
import {multiStoreConfig} from "./util";
import {Magento1Client} from "./module";

class AddressProxy extends AbstractAddressProxy {
constructor (config, req){
super(config, req)
this.api = Magento1Client(multiStoreConfig(config.magento1.api, req));
}
list (customerToken) {
return this.api.address.list(customerToken)
}
update (customerToken, addressData) {
return this.api.address.update(customerToken, addressData);
}
get (customerToken, addressId) {
return this.api.address.get(customerToken, addressId)
}
delete (customerToken, addressData) {
return this.api.address.delete(customerToken, addressData)
}
}

module.exports = AddressProxy
48 changes: 48 additions & 0 deletions vsf-api-extension/cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import AbstractCartProxy from '../abstract/cart';
import { multiStoreConfig } from './util';
import { ShopwareClient } from './module/index';

class CartProxy extends AbstractCartProxy {
constructor (config, req){
super(config, req)
this.api = ShopwareClient(multiStoreConfig(config.shopware.api, req));
}
create (customerToken) {
return this.api.cart.create(customerToken);
}
update (customerToken, cartId, cartItem) {
return this.api.cart.update(customerToken, cartId, cartItem);
}
delete (customerToken, cartId, cartItem) {
return this.api.cart.delete(customerToken, cartId, cartItem);
}
pull (customerToken, cartId, params) {
return this.api.cart.pull(customerToken, cartId, params);
}
totals (customerToken, cartId, params) {
return this.api.cart.totals(customerToken, cartId, params);
}
getShippingMethods (customerToken, cartId, address) {
return this.api.cart.shippingMethods(customerToken, cartId, address);
}
getPaymentMethods (customerToken, cartId) {
return this.api.cart.paymentMethods(customerToken, cartId);
}
setShippingInformation (customerToken, cartId, address) {
return this.api.cart.shippingInformation(customerToken, cartId, address);
}
collectTotals (customerToken, cartId, shippingMethod) {
return this.api.cart.collectTotals(customerToken, cartId, shippingMethod);
}
applyCoupon (customerToken, cartId, coupon) {
return this.api.cart.applyCoupon(customerToken, cartId, coupon);
}
deleteCoupon (customerToken, cartId) {
return this.api.cart.deleteCoupon(customerToken, cartId);
}
getCoupon (customerToken, cartId) {
return this.api.cart.getCoupon(customerToken, cartId);
}
}

module.exports = CartProxy;
15 changes: 15 additions & 0 deletions vsf-api-extension/contact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import AbstractContactProxy from '../abstract/contact';
import { multiStoreConfig } from './util';
import { ShopwareClient } from './module/index';

class ContactProxy extends AbstractContactProxy {
constructor (config, req){
super(config, req)
this.api = ShopwareClient(multiStoreConfig(config.shopware.api, req));
}
submit (form) {
return this.api.contact.submit(form);
}
}

module.exports = ContactProxy;
42 changes: 42 additions & 0 deletions vsf-api-extension/module/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const RestClient = require('./lib/rest_client').RestClient;
const user = require('./lib/user');
const cart = require('./lib/cart');
const order = require('./lib/order');
const stock = require('./lib/stock');
const contact = require('./lib/contact');
const wishlist = require('./lib/wishlist');
const stockAlert = require('./lib/stock_alert');
const newsletter = require('./lib/newsletter');
const address = require('./lib/address');

const SHOPWARE_API_VERSION = 'v1';

module.exports.ShopwareClient = function (options) {
let instance = {
addMethods (key, module) {
let client = RestClient(options);
if (module) {
if (this[key])
this[key] = Object.assign(this[key], module(client));
else
this[key] = module(client);
}
}
};

options.version = SHOPWARE_API_VERSION;

let client = RestClient(options);

instance.user = user(client);
instance.order = order(client);
instance.cart = cart(client);
instance.stock = stock(client);
instance.contact = contact(client);
instance.wishlist = wishlist(client);
instance.stockAlert = stockAlert(client);
instance.newsletter = newsletter(client);
instance.address = address(client);

return instance;
};
36 changes: 36 additions & 0 deletions vsf-api-extension/module/lib/address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = function (restClient) {
let module = {};
let url = 'address/';
function getResponse(data){
if (data.code === 200){
return data.result;
}

return false;
}
module.list = function (customerToken) {
url += `list?token=${customerToken}`
return restClient.get(url).then((data)=> {
return getResponse(data);
});
},
module.update = function (customerToken, addressData) {
url += `update?token=${customerToken}`
return restClient.post(url, {address: addressData}).then((data)=> {
return getResponse(data);
});
}
module.get = function (customerToken, addressId) {
url += `get?token=${customerToken}&addressId=${addressId}`
return restClient.get(url).then((data)=> {
return getResponse(data);
});
}
module.delete = function (customerToken, addressData) {
url += `delete?token=${customerToken}`
return restClient.post(url, {address: addressData}).then((data)=> {
return getResponse(data);
});
}
return module;
}
Loading

0 comments on commit 41c9176

Please sign in to comment.