@dotdev/locations
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _ajaxQueue = require('@dotdev/ajax-queue'); | ||
@@ -18,222 +20,216 @@ | ||
var StoreLocations = function LocationAjaxWrapper(config) { | ||
var settings = config || {}; | ||
var defaultSettings = { | ||
url: '/apps/connector', | ||
params: '' | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
// Merge configs | ||
};this.settings = Object.assign(defaultSettings, settings); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
this.queue = new _ajaxQueue2.default({ | ||
method: 'POST', | ||
completedAllRequestsEvent: 'locations:requestsCompleted', | ||
completedRequestEvent: 'locations:requestCompleted' | ||
}); | ||
var StoreLocations = function () { | ||
function StoreLocations(config) { | ||
_classCallCheck(this, StoreLocations); | ||
this.defaultSuccess = function locationSuccess(response) { | ||
var locations = JSON.parse(response); | ||
var foundEvent = new CustomEvent('locations:found', { detail: { response: locations } }); | ||
document.dispatchEvent(foundEvent); | ||
}; | ||
this.defaultError = function locationError(response) { | ||
var error = JSON.parse(response); | ||
var errorEvent = new CustomEvent('locations:error', { detail: { response: error } }); | ||
document.dispatchEvent(errorEvent); | ||
}; | ||
var settings = config || {}; | ||
var defaultSettings = { | ||
url: '/apps/connector', | ||
params: '', | ||
storeKey: 'pickup_store_id' | ||
this.locationLookup = this.locationLookup.bind(this); | ||
this.inventoryLocationsByIds = this.inventoryLocationsByIds.bind(this); | ||
this.sendReturnRequest = this.sendReturnRequest.bind(this); | ||
this.setHomeStore = this.setHomeStore.bind(this); | ||
this.getHomeStore = this.getHomeStore.bind(this); | ||
}; | ||
// Merge configs | ||
};this.settings = Object.assign(defaultSettings, settings); | ||
/* | ||
API functions | ||
*/ | ||
StoreLocations.prototype.locationLookup = function returnStoresBasedOnLocationData(config) { | ||
'use strict'; | ||
this.queue = new _ajaxQueue2.default({ | ||
method: 'POST', | ||
completedAllRequestsEvent: 'locations:requestsCompleted', | ||
completedRequestEvent: 'locations:requestCompleted' | ||
}); | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
var request = { | ||
url: this.settings.url + '/location-lookup' + this.settings.params, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
}; | ||
StoreLocations.prototype.inventoryLocationsByIds = function ReturnLocationsThatStockVariants(config) { | ||
'use strict'; | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
if (typeof options.data === 'undefined') { | ||
if (typeof options.data.variants === 'undefined') { | ||
return options.error('{ "message": "No variants provided" }'); | ||
} | ||
return options.error('{ "message": "No data provided" }'); | ||
} | ||
var request = { | ||
url: this.settings.url + '/inventory-lookup/locations' + this.settings.params, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
}; | ||
StoreLocations.prototype.setClickAndCollectStore = function SetACartAttributeWithTheIdOfTheLocation(config) { | ||
'use strict'; | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
options.id = options.id || {}; | ||
if (options.id !== {}) { | ||
var attributes = { | ||
pick_up_store_id: options.id | ||
this.defaultSuccess = function locationSuccess(response) { | ||
var locations = JSON.parse(response); | ||
var foundEvent = new CustomEvent('locations:found', { detail: { response: locations } }); | ||
document.dispatchEvent(foundEvent); | ||
}; | ||
var request = { | ||
url: '/cart/update.js', | ||
success: options.success, | ||
error: options.error, | ||
data: { | ||
attributes: attributes | ||
} | ||
this.defaultError = function locationError(response) { | ||
var error = JSON.parse(response); | ||
var errorEvent = new CustomEvent('locations:error', { detail: { response: error } }); | ||
document.dispatchEvent(errorEvent); | ||
}; | ||
this.queue.add(request); | ||
} | ||
return this; | ||
}; | ||
StoreLocations.prototype.removeClickAndCollectStore = function RemoveACartAttributeWithTheIdOfTheLocation(config) { | ||
'use strict'; | ||
_createClass(StoreLocations, [{ | ||
key: 'locationLookup', | ||
value: function locationLookup(config) { | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
var attributes = { | ||
pick_up_store_id: null | ||
}; | ||
var request = { | ||
url: '/cart/update.js', | ||
success: options.success, | ||
error: options.error, | ||
data: { | ||
attributes: attributes | ||
var request = { | ||
url: this.settings.url + '/location-lookup' + this.settings.params, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
} | ||
}; | ||
this.queue.add(request); | ||
}, { | ||
key: 'inventoryLocationsByIds', | ||
value: function inventoryLocationsByIds(config) { | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
if (typeof options.data === 'undefined') { | ||
if (typeof options.data.variants === 'undefined') { | ||
return options.error('{ "message": "No variants provided" }'); | ||
} | ||
return options.error('{ "message": "No data provided" }'); | ||
} | ||
var request = { | ||
url: this.settings.url + '/inventory-lookup/locations' + this.settings.params, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
} | ||
}, { | ||
key: 'setClickAndCollectStore', | ||
value: function setClickAndCollectStore(config) { | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
options.id = options.id || {}; | ||
if (options.id !== {}) { | ||
var attributes = _defineProperty({}, this.settings.storeKey, options.id); | ||
var request = { | ||
url: '/cart/update.js', | ||
success: options.success, | ||
error: options.error, | ||
data: { | ||
attributes: attributes | ||
} | ||
}; | ||
this.queue.add(request); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'removeClickAndCollectStore', | ||
value: function removeClickAndCollectStore(config) { | ||
var options = config || {}; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
return this; | ||
}; | ||
var attributes = _defineProperty({}, this.settings.storeKey, null); | ||
var request = { | ||
url: '/cart/update.js', | ||
success: options.success, | ||
error: options.error, | ||
data: { | ||
attributes: attributes | ||
} | ||
}; | ||
this.queue.add(request); | ||
StoreLocations.prototype.lookupLocationById = function ReturnASingleLocationFromId(config) { | ||
'use strict'; | ||
return this; | ||
} | ||
}, { | ||
key: 'lookupLocationById', | ||
value: function lookupLocationById(config) { | ||
var options = config || {}; | ||
var id = options.id; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
var options = config || {}; | ||
var id = options.id; | ||
options.success = options.success || this.defaultSuccess; | ||
options.error = options.error || this.defaultError; | ||
var request = { | ||
url: this.settings.url + '/locations/' + id + this.settings.params, | ||
method: 'GET', | ||
success: options.success, | ||
error: options.error | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
} | ||
}, { | ||
key: 'setHomeStore', | ||
value: function setHomeStore(config) { | ||
var options = config || {}; | ||
var locationId = options.locationId, | ||
customerId = options.customerId; | ||
var request = { | ||
url: this.settings.url + '/locations/' + id + this.settings.params, | ||
method: 'GET', | ||
success: options.success, | ||
error: options.error | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
}; | ||
StoreLocations.prototype.setHomeStore = function SetACookieAndMetafieldOfTheUsersLocation(config) { | ||
'use strict'; | ||
var data = { | ||
location_id: locationId, | ||
customer_id: customerId | ||
}; | ||
var options = config || {}; | ||
var locationId = options.locationId, | ||
customerId = options.customerId; | ||
options.success = options.success || function setHomeStore(response) { | ||
var success = JSON.parse(response); | ||
var successEvent = new CustomEvent('homestore:set', { | ||
detail: { | ||
response: success | ||
} | ||
}); | ||
document.dispatchEvent(successEvent); | ||
}; | ||
options.error = options.error || this.defaultError; | ||
_jsCookie2.default.set('HomeStore', data, { expires: 365 }); | ||
var data = { | ||
location_id: locationId, | ||
customer_id: customerId | ||
}; | ||
var request = { | ||
url: this.settings.url + '/customers/default-location' + this.settings.params, | ||
success: options.success, | ||
method: 'PUT', | ||
error: options.error, | ||
data: data | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
} | ||
}, { | ||
key: 'getHomeStore', | ||
value: function getHomeStore(data) { | ||
var homeStore = _jsCookie2.default.get('HomeStore') || '{}'; | ||
var json = JSON.parse(homeStore); | ||
return json; | ||
} | ||
}, { | ||
key: 'sendReturnRequest', | ||
value: function sendReturnRequest(config) { | ||
'use strict'; | ||
options.success = options.success || function setHomeStore(response) { | ||
var success = JSON.parse(response); | ||
var successEvent = new CustomEvent('homestore:set', { | ||
detail: { | ||
response: success | ||
} | ||
}); | ||
document.dispatchEvent(successEvent); | ||
}; | ||
options.error = options.error || this.defaultError; | ||
var options = config || {}; | ||
_jsCookie2.default.set('HomeStore', data, { expires: 365 }); | ||
options.success = options.success || function returnSuccess(response) { | ||
var success = JSON.parse(response); | ||
var successEvent = new CustomEvent('return:success', { | ||
detail: { | ||
response: success | ||
} | ||
}); | ||
document.dispatchEvent(successEvent); | ||
}; | ||
options.error = options.error || this.defaultError; | ||
var id = options.id, | ||
lineItems = options.lineItems, | ||
reasonId = options.reasonId, | ||
customerId = options.customerId; | ||
var request = { | ||
url: this.settings.url + '/customers/default-location' + this.settings.params, | ||
success: options.success, | ||
method: 'PUT', | ||
error: options.error, | ||
data: data | ||
}; | ||
this.queue.add(request); | ||
return this; | ||
}; | ||
var data = { | ||
line_items: lineItems, | ||
reason_id: reasonId, | ||
customer_id: customerId | ||
}; | ||
var request = { | ||
url: this.settings.url + '/orders/' + id + '/return' + this.settings.params, | ||
success: options.success, | ||
method: 'POST', | ||
error: options.error, | ||
data: data | ||
}; | ||
this.queue.add(request); | ||
} | ||
}]); | ||
StoreLocations.prototype.getHomeStore = function SetACookieOfTheUsersLocation(data) { | ||
'use strict'; | ||
return StoreLocations; | ||
}(); | ||
var homeStore = _jsCookie2.default.get('HomeStore') || '{}'; | ||
var json = JSON.parse(homeStore); | ||
return json; | ||
}; | ||
StoreLocations.prototype.sendReturnRequest = function SendReturnRequest(config) { | ||
'use strict'; | ||
var options = config || {}; | ||
options.success = options.success || function returnSuccess(response) { | ||
var success = JSON.parse(response); | ||
var successEvent = new CustomEvent('return:success', { | ||
detail: { | ||
response: success | ||
} | ||
}); | ||
document.dispatchEvent(successEvent); | ||
}; | ||
options.error = options.error || this.defaultError; | ||
var id = options.id, | ||
lineItems = options.lineItems, | ||
reasonId = options.reasonId, | ||
customerId = options.customerId; | ||
var data = { | ||
line_items: lineItems, | ||
reason_id: reasonId, | ||
customer_id: customerId | ||
}; | ||
var request = { | ||
url: this.settings.url + '/orders/' + id + '/return' + this.settings.params, | ||
success: options.success, | ||
method: 'POST', | ||
error: options.error, | ||
data: data | ||
}; | ||
this.queue.add(request); | ||
}; | ||
exports.default = StoreLocations; |
321
locations.js
import Q from '@dotdev/ajax-queue' | ||
import Cookie from 'js-cookie' | ||
const StoreLocations = function LocationAjaxWrapper (config) { | ||
const settings = config || {} | ||
const defaultSettings = { | ||
url: '/apps/connector', | ||
params: '' | ||
} | ||
export default class StoreLocations { | ||
constructor (config) { | ||
const settings = config || {} | ||
const defaultSettings = { | ||
url: '/apps/connector', | ||
params: '', | ||
storeKey: 'pickup_store_id' | ||
} | ||
// Merge configs | ||
this.settings = Object.assign(defaultSettings, settings) | ||
// Merge configs | ||
this.settings = Object.assign(defaultSettings, settings) | ||
this.queue = new Q({ | ||
method: 'POST', | ||
completedAllRequestsEvent: 'locations:requestsCompleted', | ||
completedRequestEvent: 'locations:requestCompleted' | ||
}) | ||
this.queue = new Q({ | ||
method: 'POST', | ||
completedAllRequestsEvent: 'locations:requestsCompleted', | ||
completedRequestEvent: 'locations:requestCompleted' | ||
}) | ||
this.defaultSuccess = function locationSuccess (response) { | ||
const locations = JSON.parse(response) | ||
const foundEvent = new CustomEvent('locations:found', { detail: { response: locations } }) | ||
document.dispatchEvent(foundEvent) | ||
this.defaultSuccess = function locationSuccess (response) { | ||
const locations = JSON.parse(response) | ||
const foundEvent = new CustomEvent('locations:found', { detail: { response: locations } }) | ||
document.dispatchEvent(foundEvent) | ||
} | ||
this.defaultError = function locationError (response) { | ||
const error = JSON.parse(response) | ||
const errorEvent = new CustomEvent('locations:error', { detail: { response: error } }) | ||
document.dispatchEvent(errorEvent) | ||
} | ||
} | ||
this.defaultError = function locationError (response) { | ||
const error = JSON.parse(response) | ||
const errorEvent = new CustomEvent('locations:error', { detail: { response: error } }) | ||
document.dispatchEvent(errorEvent) | ||
} | ||
this.locationLookup = this.locationLookup.bind(this) | ||
this.inventoryLocationsByIds = this.inventoryLocationsByIds.bind(this) | ||
this.sendReturnRequest = this.sendReturnRequest.bind(this) | ||
this.setHomeStore = this.setHomeStore.bind(this) | ||
this.getHomeStore = this.getHomeStore.bind(this) | ||
} | ||
locationLookup (config) { | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
/* | ||
API functions | ||
*/ | ||
StoreLocations.prototype.locationLookup = function returnStoresBasedOnLocationData (config) { | ||
'use strict' | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
const request = { | ||
url: `${this.settings.url}/location-lookup${this.settings.params}`, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
const request = { | ||
url: `${this.settings.url}/location-lookup${this.settings.params}`, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
inventoryLocationsByIds (config) { | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
if (typeof options.data === 'undefined') { | ||
if (typeof options.data.variants === 'undefined') { | ||
return options.error('{ "message": "No variants provided" }') | ||
} | ||
return options.error('{ "message": "No data provided" }') | ||
} | ||
const request = { | ||
url: `${this.settings.url}/inventory-lookup/locations${this.settings.params}`, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
StoreLocations.prototype.inventoryLocationsByIds = function ReturnLocationsThatStockVariants (config) { | ||
'use strict' | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
if (typeof options.data === 'undefined') { | ||
if (typeof options.data.variants === 'undefined') { | ||
return options.error('{ "message": "No variants provided" }') | ||
setClickAndCollectStore (config) { | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
options.id = options.id || {} | ||
if (options.id !== {}) { | ||
const attributes = { | ||
[this.settings.storeKey]: options.id | ||
} | ||
const request = { | ||
url: '/cart/update.js', | ||
success: options.success, | ||
error: options.error, | ||
data: { | ||
attributes: attributes | ||
} | ||
} | ||
this.queue.add(request) | ||
} | ||
return options.error('{ "message": "No data provided" }') | ||
return this | ||
} | ||
const request = { | ||
url: `${this.settings.url}/inventory-lookup/locations${this.settings.params}`, | ||
data: options.data, | ||
success: options.success, | ||
error: options.error | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
StoreLocations.prototype.setClickAndCollectStore = function SetACartAttributeWithTheIdOfTheLocation (config) { | ||
'use strict' | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
options.id = options.id || {} | ||
if (options.id !== {}) { | ||
removeClickAndCollectStore (config) { | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
const attributes = { | ||
pick_up_store_id: options.id | ||
[this.settings.storeKey]: null | ||
} | ||
@@ -97,116 +108,90 @@ const request = { | ||
this.queue.add(request) | ||
return this | ||
} | ||
return this | ||
} | ||
StoreLocations.prototype.removeClickAndCollectStore = function RemoveACartAttributeWithTheIdOfTheLocation (config) { | ||
'use strict' | ||
const options = config || {} | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
lookupLocationById (config) { | ||
const options = config || {} | ||
const id = options.id | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
const attributes = { | ||
pick_up_store_id: null | ||
} | ||
const request = { | ||
url: '/cart/update.js', | ||
success: options.success, | ||
error: options.error, | ||
data: { | ||
attributes: attributes | ||
const request = { | ||
url: `${this.settings.url}/locations/${id}${this.settings.params}`, | ||
method: 'GET', | ||
success: options.success, | ||
error: options.error | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
setHomeStore (config) { | ||
const options = config || {} | ||
const { locationId, customerId } = options | ||
StoreLocations.prototype.lookupLocationById = function ReturnASingleLocationFromId (config) { | ||
'use strict' | ||
const options = config || {} | ||
const id = options.id | ||
options.success = options.success || this.defaultSuccess | ||
options.error = options.error || this.defaultError | ||
const data = { | ||
location_id: locationId, | ||
customer_id: customerId | ||
} | ||
const request = { | ||
url: `${this.settings.url}/locations/${id}${this.settings.params}`, | ||
method: 'GET', | ||
success: options.success, | ||
error: options.error | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
options.success = options.success || function setHomeStore (response) { | ||
const success = JSON.parse(response) | ||
const successEvent = new CustomEvent('homestore:set', { | ||
detail: { | ||
response: success | ||
} | ||
}) | ||
document.dispatchEvent(successEvent) | ||
} | ||
options.error = options.error || this.defaultError | ||
StoreLocations.prototype.setHomeStore = function SetACookieAndMetafieldOfTheUsersLocation (config) { | ||
'use strict' | ||
const options = config || {} | ||
const { locationId, customerId } = options | ||
Cookie.set('HomeStore', data, { expires: 365 }) | ||
const data = { | ||
location_id: locationId, | ||
customer_id: customerId | ||
const request = { | ||
url: `${this.settings.url}/customers/default-location${this.settings.params}`, | ||
success: options.success, | ||
method: 'PUT', | ||
error: options.error, | ||
data: data | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
options.success = options.success || function setHomeStore (response) { | ||
const success = JSON.parse(response) | ||
const successEvent = new CustomEvent('homestore:set', { | ||
detail: { | ||
response: success | ||
} | ||
}) | ||
document.dispatchEvent(successEvent) | ||
getHomeStore (data) { | ||
const homeStore = Cookie.get('HomeStore') || '{}' | ||
const json = JSON.parse(homeStore) | ||
return json | ||
} | ||
options.error = options.error || this.defaultError | ||
Cookie.set('HomeStore', data, { expires: 365 }) | ||
sendReturnRequest (config) { | ||
'use strict' | ||
const options = config || {} | ||
const request = { | ||
url: `${this.settings.url}/customers/default-location${this.settings.params}`, | ||
success: options.success, | ||
method: 'PUT', | ||
error: options.error, | ||
data: data | ||
options.success = options.success || function returnSuccess (response) { | ||
const success = JSON.parse(response) | ||
const successEvent = new CustomEvent('return:success', { | ||
detail: { | ||
response: success | ||
} | ||
}) | ||
document.dispatchEvent(successEvent) | ||
} | ||
options.error = options.error || this.defaultError | ||
const { id, lineItems, reasonId, customerId } = options | ||
const data = { | ||
line_items: lineItems, | ||
reason_id: reasonId, | ||
customer_id: customerId | ||
} | ||
const request = { | ||
url: `${this.settings.url}/orders/${id}/return${this.settings.params}`, | ||
success: options.success, | ||
method: 'POST', | ||
error: options.error, | ||
data: data | ||
} | ||
this.queue.add(request) | ||
} | ||
this.queue.add(request) | ||
return this | ||
} | ||
StoreLocations.prototype.getHomeStore = function SetACookieOfTheUsersLocation (data) { | ||
'use strict' | ||
const homeStore = Cookie.get('HomeStore') || '{}' | ||
const json = JSON.parse(homeStore) | ||
return json | ||
} | ||
StoreLocations.prototype.sendReturnRequest = function SendReturnRequest (config) { | ||
'use strict' | ||
const options = config || {} | ||
options.success = options.success || function returnSuccess (response) { | ||
const success = JSON.parse(response) | ||
const successEvent = new CustomEvent('return:success', { | ||
detail: { | ||
response: success | ||
} | ||
}) | ||
document.dispatchEvent(successEvent) | ||
} | ||
options.error = options.error || this.defaultError | ||
const { id, lineItems, reasonId, customerId } = options | ||
const data = { | ||
line_items: lineItems, | ||
reason_id: reasonId, | ||
customer_id: customerId | ||
} | ||
const request = { | ||
url: `${this.settings.url}/orders/${id}/return${this.settings.params}`, | ||
success: options.success, | ||
method: 'POST', | ||
error: options.error, | ||
data: data | ||
} | ||
this.queue.add(request) | ||
} | ||
export default StoreLocations |
{ | ||
"name": "@dotdev/locations", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "Front end store locator api wrapper", | ||
@@ -29,6 +29,6 @@ "browser": "lib/locations.js", | ||
"scripts": { | ||
"lint": "./node_modules/.bin/eslint locations.js", | ||
"fix": "npm run lint -- --fix", | ||
"test": "npm run lint", | ||
"build": "./node_modules/.bin/babel locations.js -d lib" | ||
"lint": "eslint locations.js", | ||
"fix": "eslint locations.js --fix", | ||
"test": "eslint locations.js", | ||
"build": "babel locations.js -d lib" | ||
}, | ||
@@ -35,0 +35,0 @@ "repository": { |
@@ -17,3 +17,4 @@ # Store location | ||
url: 'https://connector-dev.alicemccall.io/api/apps', | ||
params: '?shop=alice-mccall-stage.myshopify.com' | ||
params: '?shop=alice-mccall-stage.myshopify.com', | ||
storeKey: 'pickup_store_id' | ||
}) | ||
@@ -20,0 +21,0 @@ ``` |
18022
168
385