Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 9f95d30

Browse files
committed
Merge branch 'develop' of https://github.com/DivanteLtd/vue-storefront-api into develop
2 parents dae12ef + f11e720 commit 9f95d30

27 files changed

+912
-0
lines changed

config/default.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@
162162
"accessTokenSecret": "7qunl3p505rubmr7u1ijt7odyialnih9"
163163
}
164164
},
165+
"magento1": {
166+
"url": "http://magento-demo.local",
167+
"imgUrl": "http://magento-demo.local/media/catalog/product",
168+
"magentoUserName": "",
169+
"magentoUserPassword": "",
170+
"httpUserName": "",
171+
"httpUserPassword": "",
172+
"api": {
173+
"url": "http://magento-demo.local/vsbridge",
174+
"consumerKey": "",
175+
"consumerSecret": "",
176+
"accessToken": "",
177+
"accessTokenSecret": ""
178+
}
179+
},
165180
"imageable": {
166181
"namespace": "",
167182
"maxListeners": 512,

src/platform/abstract/address.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class AbstractAddressProxy {
2+
constructor(config, req) {
3+
this._config = config
4+
this._request = req
5+
}
6+
7+
list (customerToken) {
8+
throw new Error('AbstractAddressProxy::list must be implemented for specific platform')
9+
}
10+
update (customerToken, addressData) {
11+
throw new Error('AbstractAddressProxy::update must be implemented for specific platform')
12+
}
13+
get (customerToken, addressId) {
14+
throw new Error('AbstractAddressProxy::get must be implemented for specific platform')
15+
}
16+
delete (customerToken, addressData) {
17+
throw new Error('AbstractAddressProxy::delete must be implemented for specific platform')
18+
}
19+
}
20+
21+
export default AbstractAddressProxy

src/platform/abstract/contact.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class AbstractContactProxy {
2+
submit (formData) {
3+
throw new Error('AbstractContactProxy::check must be implemented for specific platform')
4+
}
5+
}
6+
7+
module.exports = AbstractContactProxy

src/platform/abstract/newsletter.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AbstractNewsletterProxy {
2+
subscribe (emailAddress) {
3+
}
4+
5+
unsubscribe (customerToken) {
6+
}
7+
}
8+
9+
module.exports = AbstractNewsletterProxy

src/platform/abstract/stock_alert.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AbstractStockAlertProxy {
2+
constructor(config, req) {
3+
this._config = config
4+
this._request = req
5+
}
6+
subscribe (customerToken, productId, emailAddress) {
7+
throw new Error('AbstractContactProxy::subscribe must be implemented for specific platform')
8+
}
9+
}
10+
11+
export default AbstractStockAlertProxy

src/platform/abstract/wishlist.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class AbstractWishlistProxy {
2+
pull (customerToken) {
3+
throw new Error('AbstractWishlistProxy::pull must be implemented for specific platform')
4+
}
5+
update (customerToken, wishListItem) {
6+
throw new Error('AbstractWishlistProxy::update must be implemented for specific platform')
7+
}
8+
delete (customerToken, wishListItem) {
9+
throw new Error('AbstractWishlistProxy::delete must be implemented for specific platform')
10+
}
11+
}
12+
13+
module.exports = AbstractWishlistProxy

src/platform/magento1/address.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import AbstractAddressProxy from '../abstract/address'
2+
import {multiStoreConfig} from "./util";
3+
import {Magento1Client} from "./module";
4+
5+
class AddressProxy extends AbstractAddressProxy {
6+
constructor (config, req){
7+
super(config, req)
8+
this.api = Magento1Client(multiStoreConfig(config.magento1.api, req));
9+
}
10+
list (customerToken) {
11+
return this.api.address.list(customerToken)
12+
}
13+
update (customerToken, addressData) {
14+
return this.api.address.update(customerToken, addressData);
15+
}
16+
get (customerToken, addressId) {
17+
return this.api.address.get(customerToken, addressId)
18+
}
19+
delete (customerToken, addressData) {
20+
return this.api.address.delete(customerToken, addressData)
21+
}
22+
}
23+
24+
module.exports = AddressProxy

src/platform/magento1/cart.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import AbstractCartProxy from '../abstract/cart';
2+
import { multiStoreConfig } from './util';
3+
import { Magento1Client } from './module/index';
4+
5+
class CartProxy extends AbstractCartProxy {
6+
constructor (config, req){
7+
super(config, req)
8+
this.api = Magento1Client(multiStoreConfig(config.magento1.api, req));
9+
}
10+
create (customerToken) {
11+
return this.api.cart.create(customerToken);
12+
}
13+
update (customerToken, cartId, cartItem) {
14+
return this.api.cart.update(customerToken, cartId, cartItem);
15+
}
16+
delete (customerToken, cartId, cartItem) {
17+
return this.api.cart.delete(customerToken, cartId, cartItem);
18+
}
19+
pull (customerToken, cartId, params) {
20+
return this.api.cart.pull(customerToken, cartId, params);
21+
}
22+
totals (customerToken, cartId, params) {
23+
return this.api.cart.totals(customerToken, cartId, params);
24+
}
25+
getShippingMethods (customerToken, cartId, address) {
26+
return this.api.cart.shippingMethods(customerToken, cartId, address);
27+
}
28+
getPaymentMethods (customerToken, cartId) {
29+
return this.api.cart.paymentMethods(customerToken, cartId);
30+
}
31+
setShippingInformation (customerToken, cartId, address) {
32+
return this.api.cart.shippingInformation(customerToken, cartId, address);
33+
}
34+
collectTotals (customerToken, cartId, shippingMethod) {
35+
return this.api.cart.collectTotals(customerToken, cartId, shippingMethod);
36+
}
37+
applyCoupon (customerToken, cartId, coupon) {
38+
return this.api.cart.applyCoupon(customerToken, cartId, coupon);
39+
}
40+
deleteCoupon (customerToken, cartId) {
41+
return this.api.cart.deleteCoupon(customerToken, cartId);
42+
}
43+
getCoupon (customerToken, cartId) {
44+
return this.api.cart.getCoupon(customerToken, cartId);
45+
}
46+
}
47+
48+
module.exports = CartProxy;

src/platform/magento1/contact.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import AbstractContactProxy from '../abstract/contact';
2+
import { multiStoreConfig } from './util';
3+
import { Magento1Client } from './module/index';
4+
5+
class ContactProxy extends AbstractContactProxy {
6+
constructor (config, req){
7+
super(config, req)
8+
this.api = Magento1Client(multiStoreConfig(config.magento1.api, req));
9+
}
10+
submit (form) {
11+
return this.api.contact.submit(form);
12+
}
13+
}
14+
15+
module.exports = ContactProxy;

src/platform/magento1/module/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const RestClient = require('./lib/rest_client').RestClient;
2+
const user = require('./lib/user');
3+
const cart = require('./lib/cart');
4+
const stock = require('./lib/stock');
5+
const contact = require('./lib/contact');
6+
const wishlist = require('./lib/wishlist');
7+
const stockAlert = require('./lib/stock_alert');
8+
const newsletter = require('./lib/newsletter');
9+
const address = require('./lib/address');
10+
11+
const MAGENTO_API_VERSION = 'V1';
12+
13+
module.exports.Magento1Client = function (options) {
14+
let instance = {
15+
addMethods (key, module) {
16+
let client = RestClient(options);
17+
if (module) {
18+
if (this[key])
19+
this[key] = Object.assign(this[key], module(client));
20+
else
21+
this[key] = module(client);
22+
}
23+
}
24+
};
25+
26+
options.version = MAGENTO_API_VERSION;
27+
28+
let client = RestClient(options);
29+
30+
instance.user = user(client);
31+
instance.cart = cart(client);
32+
instance.stock = stock(client);
33+
instance.contact = contact(client);
34+
instance.wishlist = wishlist(client);
35+
instance.stockAlert = stockAlert(client);
36+
instance.newsletter = newsletter(client);
37+
instance.address = address(client);
38+
39+
return instance;
40+
};

0 commit comments

Comments
 (0)