Skip to content

Commit

Permalink
feat(facets): add functions for the rest of the OFF facets
Browse files Browse the repository at this point in the history
  • Loading branch information
enioluwas authored and kozlown committed May 18, 2018
1 parent 7944550 commit 64c17f4
Showing 1 changed file with 154 additions and 0 deletions.
154 changes: 154 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,160 @@ class OFF {
.then(JSON.parse)
}

/**
* It is used to get all allergens from the API
* @return {Object} It returns a JSON with all allergens present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getAllergens().then(allergens =>{
* //use allergens
* })
*/
getAllergens () {
return request(`${this.URL}/allergens.json`)
.then(JSON.parse)
}

/**
* It is used to get all categories from the API
* @return {Object} It returns a JSON with all categories present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getCategories().then(categories =>{
* //use categories
* })
*/
getCategories () {
return request(`${this.URL}/categories.json`)
.then(JSON.parse)
}

/**
* It is used to get all countries from the API
* @return {Object} It returns a JSON with all categories present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getCountries().then(countries =>{
* //use countries
* })
*/
getCountries () {
return request(`${this.URL}/countries.json`)
.then(JSON.parse)
}

/**
* It is used to get all entry dates from the API
* @return {Object} It returns a JSON with all entry dates present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getEntryDates().then(entry_dates =>{
* //use entry_dates
* })
*/
getEntryDates () {
return request(`${this.URL}/entry-dates.json`)
.then(JSON.parse)
}

/**
* It is used to get all ingredients from the API
* @return {Object} It returns a JSON with all ingredients present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getIngredients().then(ingredients =>{
* //use ingredients
* })
*/
getIngredients () {
return request(`${this.URL}/ingredients.json`)
.then(JSON.parse)
}

/**
* It is used to get all packagings from the API
* @return {Object} It returns a JSON with all packagings present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getPackagings().then(packagings =>{
* //use packagings
* })
*/
getPackagings () {
return request(`${this.URL}/packaging.json`)
.then(JSON.parse)
}

/**
* It is used to get packaging codes from the API
* @return {Object} It returns a JSON with all packaging codes present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getPackagingCodes().then(packaging_codes =>{
* //use packaging_codes
* })
*/
getPacakgingCodes () {
return request(`${this.URL}/packager-codes.json`)
.then(JSON.parse)
}

/**
* It is used to get all purchase places from the API
* @return {Object} It returns a JSON with all purchase places present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getPurchasePlaces().then(purchase_places =>{
* //use purchase_places
* })
*/
getPurchasePlaces () {
return request(`${this.URL}/purchase-places.json`)
.then(JSON.parse)
}

/**
* It is used to get all states from the API
* @return {Object} It returns a JSON with all states present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getStates().then(states =>{
* //use states
* })
*/
getStates () {
return request(`${this.URL}/states.json`)
.then(JSON.parse)
}

/**
* It is used to get all stores from the API
* @return {Object} It returns a JSON with all stores present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getStores().then(stores =>{
* //use stores
* })
*/
getStores () {
return request(`${this.URL}/stores.json`)
.then(JSON.parse)
}

/**
* It is used to get all trace types from the API
* @return {Object} It returns a JSON with all traces present in the API
* @example
* const worldOFF = new OFF()
* worldOFF.getTraces().then(traces =>{
* //use traces
* })
*/
getTraces () {
return request(`${this.URL}/traces.json`)
.then(JSON.parse)
}

/**
* It is used to get all products beginning with the given barcode string
* @param {string} beginning - Barcode string from which if the barcode begins, then product is to be fetched
Expand Down

0 comments on commit 64c17f4

Please sign in to comment.