@dotdev/locations
v0.3.0
Published
Front end store locator api wrapper
Downloads
18
Maintainers
Keywords
Readme
Store location
import Locations from '@dotdev/locations'
const locationsJS = new Locations({options})
Options - optional - object
You are able to provide options to locations that will assist with testing. The options are not intended to be used for production.
Using the following settings will send all requests to the Alice mcCall dev environment.
const locationsJS = new StoreLocations({
url: 'https://connector-dev.alicemccall.io/api/apps',
params: '?shop=alice-mccall-stage.myshopify.com',
storeKey: 'pickup_store_id',
locationsUrl: '/location-lookup',
inventoryUrl: '/inventory-lookup/locations'
})
The default url is '/apps/connector'
and there are no default parameters
Methods
locationLookup({config})
Description
Find locations near to specified coordinates.
{config}
- required - object
data - required - object
It is required that you send the location to the locationLookup
data: {
coordinates: {
latitude: lat,
longitude: long
}
}
success - optional - function
A callback function for once the stores have been located
success: function (response) {
const json = JSON.parse(response)
}
error - optional - function
A callback function fired if the API returns an error
error: function (err) {
console.error(err)
}
Example
const request = {
data: {
coordinates: {
latitude: lat,
longitude: long
}
},
success: function (response) {
const json = JSON.parse(response)
}.bind(this)
}
locationsJS.locationLookup(request)
inventoryLocationsByIds({config})
Description
Find locations that stock a specified list of variants by id.
{config}
- required - object
data - required - object
It is required that you send the location and an array of variant ids to the locationLookup
data: {
coordinates: {
latitude: lat,
longitude: long
},
variants: [16326964609081, 12445435324234, 32452344534553]
}
success - optional - function
A callback function for once the stores have been located
success: function (response) {
const json = JSON.parse(response)
}
error - optional - function
A callback function fired if the API returns an error
error: function (err) {
console.error(err)
}
Example
const request = {
data: {
coordinates: {
latitude: lat,
longitude: long
},
variants: [16326964609081]
},
error: function locationError (response) {
console.log(response)
},
success: function (response) {
const json = JSON.parse(response)
}.bind(this)
}
this.storeLocations.inventoryLocationsByIds(request)
setClickAndCollectStore({config})
{config}
- required - object
id - required - integer
The id of the localtion that you wish to us for click and collect.
id: 6
success - optional - function
A callback function for once the stores have been located
success: function (response) {
const json = JSON.parse(response)
}
error - optional - function
A callback function fired if the API returns an error
error: function (err) {
console.error(err)
}
Example
locationsJS.setClickAndCollectStore({ id: id });