npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amrest_helper

v1.0.1

Published

Lib which help to connect with amrest architecture. Contains helpfull builders and easy connect to endpoints

Downloads

1

Readme

AMREST HELPER

Installation

npm install amrest_helper

Usage

React

Before use any endpoints set RestaurantId

#!javascript

import Amrest from 'amrest_helper'


...
Amrest.setRestaurantId(32)
...

our endpoints it's a Promise object, every call is asynchrous

#!javascript

import Amrest from 'amrest_helper'


...
Amrest.getMenu('1488808560340').then((menu) => {
  console.log(menu)
})
...

we can catch every error

#!javascript

import Amrest from 'amrest_helper'


...
Amrest.getMenu('1488808560340').then((menu) => {
  console.log(menu)
}).catch(err => {
  console.log(err)
})
...

###Example:###

#!javascript

import React from 'react'
import Amrest, { Basket, Customer, DeliveryAddress, Order } from 'amrest_helper'

export default class Sample extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      menu: {}
    }
    this.basket = new Basket()
    this.order = new Order()
    this.submitWithOneProduct = this.submitWithOneProduct.bind(this)
  }

  submitWithOneProduct() {
    if (this.state.menu) {
      this.basket.addBasketLine(this.state.menu.menu.categories[6].products['14500251'], 2)
      this.order.setCustomer(Customer().setName('Andsafsadf').setPhoneNumber('123654234').getJSON())
      this.order.setDeliveryAddress(
            DeliveryAddress()
            .setName('Andsafsadf')
            .setCity('Warszawa')
            .setStreet('Aroniowa')
            .setHouseNumber('199')
            .getJSON())
      this.order.setBasket(this.basket.getJSON())
      Amrest.postOrderSubmit(this.order.getJSON()).then(() => {
        console.log('Order submitted!')
      })
    }
  }

  componentDidMount () {
    Amrest.setLanguage('EN')
    Amrest.setRestaurantId(21)
    Amrest.getMenu().then(menu => {
      this.setState({menu: menu})
    }
  }

  render () {
    return (
      <button onClick={() => this.submitWithOneProduct()}> Click </button>
    )
  }
}

Config

setLanguage(string) - set language (default value: 'PL'), params:

  1. lang - Language (example. 'PL', 'EN')

setDeliveryType(string) - set delivery type (default value: 'DELIVERY'), params:

  1. type - delivery type (example. 'DELIVERY', 'DINE_IN')

setRestaurantId(number) - set restaurant id required, params:

  1. restauraintId - Restaurant id (example. 512, 222)

Endpoints

getMenu(string) - The method returns the menu for the given restaurant, params:

  1. last - Last Modified, timestamp (example. '1488808560340')

getProductConfig(string, string, string) - The method returns further details for the selected product option, params:

  1. prodId - Product identifier whose details are downloaded

  2. productType - Product type

  3. configId - ID number of the selected configuration option


putProductConfig(object) - Download a new configuration for the product, params:

  1. body - ProductConfigUpdateRequest
#!json

{
  "currentProduct": {
    "id": 764334678,
    "name": "Buckets 30 hot wings",
    "price": 12.9,
    "img": "string",
    "description": "Buckets 30 hot wings",
    "productType": 2,
    "priority": 1,
    "extrasCategoryId": 20,
    "condimetsCategoryId": 20,
    "requiredCondimentsCategoryId": 20,
    "checkboxCondimentsCategoryId": 20,
    "subCategoryId": 2,
    "productConfig": [
      {
        "optionId": 12125,
        "optionNum": 0,
        "optionTitle": "Group name",
        "img": "url/to/KFCoto",
        "price": "string",
        "description": "string",
        "singleChoice": true,
        "additionalProperties": [
          {
            "key": 5,
            "value": 5
          }
        ],
        "availableItems": [
          {
            "productId": 54357688,
            "name": "Chips",
            "isDefault": false,
            "img": "http://url/to/KFCoto",
            "price": 2.55,
            "quantity": 4,
            "unitPrice": 24.3,
            "description": "crunchy wings"
          }
        ],
        "bucketGroupName": "Chickens",
        "bucketGroupPriority": 1
      }
    ],
    "additionalProperties": [
      {
        "key": 5,
        "value": 5
      }
    ],
    "promoCodeProduct": true,
    "favouriteProduct": true,
    "upsellId": 5
  },
  "choosedModification": {
    "optionId": 234311,
    "optionNum": 5,
    "optionProduct": [
      {
        "id": 5,
        "isDouble": false
      }
    ]
  }
}

postOrderSubmit(object) - Submit an order, params:

  1. body - Basket
#!json

{
  "basket": {
    "promoCode": "235gewr",
    "basketLines": [
      {
        "quantity": 1,
        "uuid": "ssddsgo-sdg235",
        "parentuuid": "sdgs",
        "positionPrice": "string",
        "product": {
          "id": 764334678,
          "name": "Buckets 30 hot wings",
          "price": 12.9,
          "img": "string",
          "description": "Buckets 30 hot wings",
          "productType": 2,
          "priority": 1,
          "extrasCategoryId": 20,
          "condimetsCategoryId": 20,
          "requiredCondimentsCategoryId": 20,
          "checkboxCondimentsCategoryId": 20,
          "subCategoryId": 2,
          "productConfig": [
            {
              "optionId": 12125,
              "optionNum": 0,
              "optionTitle": "Group name",
              "img": "url/to/KFCoto",
              "price": "string",
              "description": "string",
              "singleChoice": true,
              "additionalProperties": [
                {
                  "key": 5,
                  "value": 5
                }
              ],
              "availableItems": [
                {
                  "productId": 54357688,
                  "name": "Chips",
                  "isDefault": false,
                  "img": "http://url/to/KFCoto",
                  "price": 2.55,
                  "quantity": 4,
                  "unitPrice": 24.3,
                  "description": "crunchy wings"
                }
              ],
              "bucketGroupName": "Chickens",
              "bucketGroupPriority": 1
            }
          ],
          "additionalProperties": [
            {
              "key": 5,
              "value": 5
            }
          ],
          "promoCodeProduct": true,
          "favouriteProduct": true,
          "upsellId": 5
        }
      }
    ]
  },
  "customer": {
    "customerName": "string",
    "firstName": "string",
    "lastName": "string",
    "phoneNumber": "string",
    "emailAddress": "string"
  },
  "deliveryAddress": {
    "id": 1,
    "name": "Dom",
    "city": "Warszawa",
    "street": "Aroniowa",
    "houseNumber": 199,
    "apartNumber": 5,
    "zipCode": "02-083",
    "lat": 20.235235,
    "lng": 51.235235,
    "isDefault": false,
    "inDeliveryZone": false
  },
  "deliveryNotes": "Please bring hot",
  "deliveryTime": 690,
  "orderInvoice": {
    "name": "My invoice no 1.",
    "taxid": 11111111111,
    "addressCity": "Warszawa",
    "addressStreet": "Podbipięty 51",
    "addressPostalcode": "01-924",
    "companyName": "Budimex",
    "defaultInvoice": true
  },
  "invoice": false,
  "deliveryType": "DELIVERY",
  "orderType": "DI/TA",
  "paymentType": "CASH",
  "cashDeclared": 50,
  "restaurantId": 5,
  "takeAwayPass": "string",
  "termsOfUse": true,
  "mobileDeviceId": "sdgosdg-15125ss-dgsd",
  "reorder": true
}

Builders

Order

getJSON() - The method returns the order json


setBasket(object) - The method set basket, params:

  1. basket - Basket object (example. in Basket builder)

setCustomer(object) - The method set customer, params:

  1. customer - Customer object (example. in Customer builder)

setDeliveryAddress(object) - The method set delivery address, params:

  1. deliveryAddress - Delivery address object (example. in DeliveryAddress builder)

setDeliveryTime(number) - The method set delivery time (default: 30), params:

  1. deliveryTime - Delivery time as minutes (example. 30)

setPaymentType(string) - The method set payment type (default: 'CASH'), params:

  1. paymentType - Payment type (example. 'CASH', 'CARD')

setCashDeclared(number) - The method set declared cash from customer (default: 0), params:

  1. cashDeclared - Cash declared (example. 50, 100)

setInvoice(boolean) - The method set if the customer wants invoice, params:

  1. invoice - Invoice (example. true, false)

setOrderInvoice(object) - The method set order Invoice, params:

  1. orderInvoice - Order Invoice object (example. in OrderInvoice builder)

setTermsOfUse(boolean) - The method set if the customer accept terms of use, params:

  1. termsOfUse - Terms of use (example. true, false)

Basket

getJSON() - The method returns the basket json


setPromoCode(string) - The method set promo code, params:

  1. code - Promo Code (example. '14sdA8856C40')

setBasketLines(string) - The method set Basket Lines, params:

  1. basketLines - Promo Code (example look submit endpoint)

addBasketLine(string, number, string) - The method add basket line to basket lines, params:

  1. product - Product (example look submit endpoint)

  2. quantity (default: 1) - Quantity (example 1, 2)

  3. parentUuid - required for products from 'extrasCategories' ( get uuid from added products )


removeBasketLine(number) - The method remove product from basket lines, params:

  1. index - line index to remove (example. 2, 0)

setCustomer(object) - The method set customer, params:

  1. customer - Customer object (example. in Customer builder)

setDeliveryAddress(object) - The method set delivery address, params:

  1. deliveryAddress - Delivery address object (example. in DeliveryAddress builder)

setDeliveryTime(number) - The method set delivery time (default: 30), params:

  1. deliveryTime - Delivery time as minutes (example. 30)

setPaymentType(string) - The method set payment type (default: 'CASH'), params:

  1. paymentType - Payment type (example. 'CASH', 'CARD')

setCashDeclared(number) - The method set declared cash from customer (default: 0), params:

  1. cashDeclared - Cash declared (example. 50, 100)

setInvoice(boolean) - The method set if the customer wants invoice, params:

  1. invoice - Invoice (example. true, false)

setOrderInvoice(object) - The method set order Invoice, params:

  1. orderInvoice - Order Invoice object (example. in OrderInvoice builder)

setTermsOfUse(boolean) - The method set if the customer accept terms of use, params:

  1. termsOfUse - Terms of use (example. true, false)

Customer

getJSON() - The method returns the customer json


setName(string) - The method set name for customer, params:

  1. name - Customer name (example. 'Andrjew Sakasvili')

setPhoneNumber(string) - The method set customer phone number, params:

  1. phoneNumber - Phone number (example '669359630')

DeliveryAddress

getJSON() - The method returns the delivery address json


setName(string) - The method set name for delivery address, params:

  1. name - Delivery address name (example. 'dom')

setCity(string) - The method set city, params:

  1. city - City (example 'Warsaw')

setStreet(string) - The method set street, params:

  1. street - Street (example 'Bonifacego')

setHouseNumber(string) - The method set house number, params:

  1. number - House number (example '43', '54b')

setApartNumber(string) - The method set apart number, params:

  1. number - Apart number (example '12', '54a)

OrderInvoice

getJSON() - The method returns the order invoice json


setAddressCity(string) - The method set invoice city, params:

  1. addressCity - invoice city (example 'Warsaw')

setAddressPostalcode(string) - The method set postal code, params:

  1. addressPostalcode - invoice postal code (example '02-563')

setName(string) - The method set name for invoice, params:

  1. name - Invoice name (example. 'dom')

setAddressStreet(string) - The method set address street and number, params:

  1. addressStreet - Address street and number (example '43', '54b')

setCompanyName(string) - The method set company name, params:

  1. companyName - Company name (example 'Texeldon Sp.z.o.o')

setTaxid(number) - The method set tax id, params:

  1. taxid - tax number (example 11111111111)