{"_id":"amrest_helper","_rev":"29-bc5546444554be8088591a8c0af753ae","name":"amrest_helper","description":"Lib which help to connect with amrest architecture. Contains helpfull builders and easy connect to endpoints","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"amrest_helper","version":"1.0.1","description":"Lib which help to connect with amrest architecture. Contains helpfull builders and easy connect to endpoints","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://arturszady@bitbucket.org/arturszady/amrestjslib.git"},"keywords":["amrest"],"author":{"name":"Artur Szady & Bartłomiej Bocian"},"license":"ISC","homepage":"https://bitbucket.org/arturszady/amrestjslib#readme","gitHead":"6a759c2bbac81d2e8d0d790aa39ebc4eb6462b30","_id":"amrest_helper@1.0.1","_shasum":"0638ae571d4c3fa96f9f979d545d7ed25eab2104","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.1","_npmUser":{"name":"goodgulf","email":"artur.szady@3e.pl"},"dist":{"shasum":"0638ae571d4c3fa96f9f979d545d7ed25eab2104","tarball":"https://registry.npmjs.org/amrest_helper/-/amrest_helper-1.0.1.tgz","integrity":"sha512-/m5DGSuAQGxLwZNu7Do1R/0ornBrX/S8sj2iGOP7N5IimHZDSNiDfsCB3JTJhIWf7e82QJ88vPWtnH6X9B0LEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDs2Q9iq0KiLEfhMVmXHFVeHbHm9jRVE+6Jc+Hfh8dMmwIhAISYJEMB9fqTperDgG2CAmnySX1qfJEmSc0f/kWT7wVn"}]},"maintainers":[{"name":"goodgulf","email":"artur.szady@3e.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/amrest_helper-1.0.1.tgz_1497251580549_0.5721482429653406"},"directories":{}}},"readme":"# **AMREST HELPER** #\n\n## Installation ##\n\nnpm install amrest_helper\n\n\n## Usage ##\n\n### React ###\n\nBefore use any endpoints set **RestaurantId**\n\n```\n#!javascript\n\nimport Amrest from 'amrest_helper'\n\n\n...\nAmrest.setRestaurantId(32)\n...\n\n\n```\n\nour endpoints it's a Promise object, every call is asynchrous\n\n\n```\n#!javascript\n\nimport Amrest from 'amrest_helper'\n\n\n...\nAmrest.getMenu('1488808560340').then((menu) => {\n  console.log(menu)\n})\n...\n\n\n```\nwe can catch every error \n\n\n\n```\n#!javascript\n\nimport Amrest from 'amrest_helper'\n\n\n...\nAmrest.getMenu('1488808560340').then((menu) => {\n  console.log(menu)\n}).catch(err => {\n  console.log(err)\n})\n...\n\n\n```\n###Example:###\n\n```\n#!javascript\n\nimport React from 'react'\nimport Amrest, { Basket, Customer, DeliveryAddress, Order } from 'amrest_helper'\n\nexport default class Sample extends React.Component {\n  constructor (props) {\n    super(props)\n    this.state = {\n      menu: {}\n    }\n    this.basket = new Basket()\n    this.order = new Order()\n    this.submitWithOneProduct = this.submitWithOneProduct.bind(this)\n  }\n\n  submitWithOneProduct() {\n    if (this.state.menu) {\n      this.basket.addBasketLine(this.state.menu.menu.categories[6].products['14500251'], 2)\n      this.order.setCustomer(Customer().setName('Andsafsadf').setPhoneNumber('123654234').getJSON())\n      this.order.setDeliveryAddress(\n            DeliveryAddress()\n            .setName('Andsafsadf')\n            .setCity('Warszawa')\n            .setStreet('Aroniowa')\n            .setHouseNumber('199')\n            .getJSON())\n      this.order.setBasket(this.basket.getJSON())\n      Amrest.postOrderSubmit(this.order.getJSON()).then(() => {\n        console.log('Order submitted!')\n      })\n    }\n  }\n\n  componentDidMount () {\n    Amrest.setLanguage('EN')\n    Amrest.setRestaurantId(21)\n    Amrest.getMenu().then(menu => {\n      this.setState({menu: menu})\n    }\n  }\n\n  render () {\n    return (\n      <button onClick={() => this.submitWithOneProduct()}> Click </button>\n    )\n  }\n}\n\n\n```\n\n\n## Config ##\n\n\n**setLanguage(string)** - set language (default value: 'PL'), params:\n\n1) lang - Language (example. 'PL', 'EN')\n\n------\n\n\n**setDeliveryType(string)** - set delivery type (default value: 'DELIVERY'), params:\n\n1) type - delivery type (example. 'DELIVERY', 'DINE_IN')\n\n------\n\n\n**setRestaurantId(number)** - set restaurant id **required**, params:\n\n1) restauraintId - Restaurant id (example. 512, 222)\n\n\n\n## Endpoints ##\n\n**getMenu(string)** - The method returns the menu for the given restaurant, params:\n\n1) last - Last Modified, timestamp (example. '1488808560340')\n\n------\n\n**getProductConfig(string, string, string)** - The method returns further details for the selected product option, \nparams:\n\n1) prodId - Product identifier whose details are downloaded\n\n2) productType - Product type\n\n3) configId - ID number of the selected configuration option\n\n------\n\n**putProductConfig(object)** - Download a new configuration for the product, \nparams:\n\n1) body - ProductConfigUpdateRequest\n\n\n```\n#!json\n\n{\n  \"currentProduct\": {\n    \"id\": 764334678,\n    \"name\": \"Buckets 30 hot wings\",\n    \"price\": 12.9,\n    \"img\": \"string\",\n    \"description\": \"Buckets 30 hot wings\",\n    \"productType\": 2,\n    \"priority\": 1,\n    \"extrasCategoryId\": 20,\n    \"condimetsCategoryId\": 20,\n    \"requiredCondimentsCategoryId\": 20,\n    \"checkboxCondimentsCategoryId\": 20,\n    \"subCategoryId\": 2,\n    \"productConfig\": [\n      {\n        \"optionId\": 12125,\n        \"optionNum\": 0,\n        \"optionTitle\": \"Group name\",\n        \"img\": \"url/to/KFCoto\",\n        \"price\": \"string\",\n        \"description\": \"string\",\n        \"singleChoice\": true,\n        \"additionalProperties\": [\n          {\n            \"key\": 5,\n            \"value\": 5\n          }\n        ],\n        \"availableItems\": [\n          {\n            \"productId\": 54357688,\n            \"name\": \"Chips\",\n            \"isDefault\": false,\n            \"img\": \"http://url/to/KFCoto\",\n            \"price\": 2.55,\n            \"quantity\": 4,\n            \"unitPrice\": 24.3,\n            \"description\": \"crunchy wings\"\n          }\n        ],\n        \"bucketGroupName\": \"Chickens\",\n        \"bucketGroupPriority\": 1\n      }\n    ],\n    \"additionalProperties\": [\n      {\n        \"key\": 5,\n        \"value\": 5\n      }\n    ],\n    \"promoCodeProduct\": true,\n    \"favouriteProduct\": true,\n    \"upsellId\": 5\n  },\n  \"choosedModification\": {\n    \"optionId\": 234311,\n    \"optionNum\": 5,\n    \"optionProduct\": [\n      {\n        \"id\": 5,\n        \"isDouble\": false\n      }\n    ]\n  }\n}\n```\n\n\n------\n\n**postOrderSubmit(object)** - Submit an order, params:\n\n1) body - Basket\n\n```\n#!json\n\n{\n  \"basket\": {\n    \"promoCode\": \"235gewr\",\n    \"basketLines\": [\n      {\n        \"quantity\": 1,\n        \"uuid\": \"ssddsgo-sdg235\",\n        \"parentuuid\": \"sdgs\",\n        \"positionPrice\": \"string\",\n        \"product\": {\n          \"id\": 764334678,\n          \"name\": \"Buckets 30 hot wings\",\n          \"price\": 12.9,\n          \"img\": \"string\",\n          \"description\": \"Buckets 30 hot wings\",\n          \"productType\": 2,\n          \"priority\": 1,\n          \"extrasCategoryId\": 20,\n          \"condimetsCategoryId\": 20,\n          \"requiredCondimentsCategoryId\": 20,\n          \"checkboxCondimentsCategoryId\": 20,\n          \"subCategoryId\": 2,\n          \"productConfig\": [\n            {\n              \"optionId\": 12125,\n              \"optionNum\": 0,\n              \"optionTitle\": \"Group name\",\n              \"img\": \"url/to/KFCoto\",\n              \"price\": \"string\",\n              \"description\": \"string\",\n              \"singleChoice\": true,\n              \"additionalProperties\": [\n                {\n                  \"key\": 5,\n                  \"value\": 5\n                }\n              ],\n              \"availableItems\": [\n                {\n                  \"productId\": 54357688,\n                  \"name\": \"Chips\",\n                  \"isDefault\": false,\n                  \"img\": \"http://url/to/KFCoto\",\n                  \"price\": 2.55,\n                  \"quantity\": 4,\n                  \"unitPrice\": 24.3,\n                  \"description\": \"crunchy wings\"\n                }\n              ],\n              \"bucketGroupName\": \"Chickens\",\n              \"bucketGroupPriority\": 1\n            }\n          ],\n          \"additionalProperties\": [\n            {\n              \"key\": 5,\n              \"value\": 5\n            }\n          ],\n          \"promoCodeProduct\": true,\n          \"favouriteProduct\": true,\n          \"upsellId\": 5\n        }\n      }\n    ]\n  },\n  \"customer\": {\n    \"customerName\": \"string\",\n    \"firstName\": \"string\",\n    \"lastName\": \"string\",\n    \"phoneNumber\": \"string\",\n    \"emailAddress\": \"string\"\n  },\n  \"deliveryAddress\": {\n    \"id\": 1,\n    \"name\": \"Dom\",\n    \"city\": \"Warszawa\",\n    \"street\": \"Aroniowa\",\n    \"houseNumber\": 199,\n    \"apartNumber\": 5,\n    \"zipCode\": \"02-083\",\n    \"lat\": 20.235235,\n    \"lng\": 51.235235,\n    \"isDefault\": false,\n    \"inDeliveryZone\": false\n  },\n  \"deliveryNotes\": \"Please bring hot\",\n  \"deliveryTime\": 690,\n  \"orderInvoice\": {\n    \"name\": \"My invoice no 1.\",\n    \"taxid\": 11111111111,\n    \"addressCity\": \"Warszawa\",\n    \"addressStreet\": \"Podbipięty 51\",\n    \"addressPostalcode\": \"01-924\",\n    \"companyName\": \"Budimex\",\n    \"defaultInvoice\": true\n  },\n  \"invoice\": false,\n  \"deliveryType\": \"DELIVERY\",\n  \"orderType\": \"DI/TA\",\n  \"paymentType\": \"CASH\",\n  \"cashDeclared\": 50,\n  \"restaurantId\": 5,\n  \"takeAwayPass\": \"string\",\n  \"termsOfUse\": true,\n  \"mobileDeviceId\": \"sdgosdg-15125ss-dgsd\",\n  \"reorder\": true\n}\n```\n\n\n## Builders ##\n\n\n# Order #\n\n\n**getJSON()** - The method returns the order json\n\n------\n\n**setBasket(object)** - The method set basket, params:\n\n1) basket - Basket object (example. in Basket builder)\n\n------\n\n**setCustomer(object)** - The method set customer, params:\n\n1) customer - Customer object (example. in Customer builder)\n\n------\n\n**setDeliveryAddress(object)** - The method set delivery address, params:\n\n1) deliveryAddress - Delivery address object (example. in DeliveryAddress builder)\n\n------\n\n\n**setDeliveryTime(number)** - The method set delivery time (default: 30), params:\n\n1) deliveryTime - Delivery time as minutes (example. 30)\n\n------\n\n**setPaymentType(string)** - The method set payment type (default: 'CASH'), params:\n\n1) paymentType - Payment type (example. 'CASH', 'CARD')\n\n------\n\n**setCashDeclared(number)** - The method set declared cash from customer (default: 0), params:\n\n1) cashDeclared - Cash declared (example. 50, 100)\n\n------\n\n**setInvoice(boolean)** - The method set if the customer wants invoice, params:\n\n1) invoice - Invoice (example. true, false)\n\n------\n\n**setOrderInvoice(object)** - The method set order Invoice, params:\n\n1) orderInvoice - Order Invoice object (example. in OrderInvoice builder)\n\n------\n\n**setTermsOfUse(boolean)** - The method set if the customer accept terms of use, params:\n\n1) termsOfUse - Terms of use (example. true, false)\n\n\n\n\n# Basket #\n\n\n**getJSON()** - The method returns the basket json\n\n------\n\n\n**setPromoCode(string)** - The method set promo code, params:\n\n1) code - Promo Code (example. '14sdA8856C40')\n\n------\n\n\n\n**setBasketLines(string)** - The method set Basket Lines, params:\n\n1) basketLines - Promo Code (example look submit endpoint)\n\n------\n\n**addBasketLine(string, number, string)** - The method add basket line to basket lines, params:\n\n1) product - Product (example look submit endpoint)\n\n2) quantity (default: 1) - Quantity (example 1, 2)\n\n3) parentUuid - required for products from 'extrasCategories' ( get uuid from added products )\n\n\n------\n\n\n**removeBasketLine(number)** - The method remove product from basket lines, params:\n\n1) index - line index to remove (example. 2, 0)\n\n------\n\n**setCustomer(object)** - The method set customer, params:\n\n1) customer - Customer object (example. in Customer builder)\n\n------\n\n**setDeliveryAddress(object)** - The method set delivery address, params:\n\n1) deliveryAddress - Delivery address object (example. in DeliveryAddress builder)\n\n------\n\n\n**setDeliveryTime(number)** - The method set delivery time (default: 30), params:\n\n1) deliveryTime - Delivery time as minutes (example. 30)\n\n------\n\n**setPaymentType(string)** - The method set payment type (default: 'CASH'), params:\n\n1) paymentType - Payment type (example. 'CASH', 'CARD')\n\n------\n\n**setCashDeclared(number)** - The method set declared cash from customer (default: 0), params:\n\n1) cashDeclared - Cash declared (example. 50, 100)\n\n------\n\n**setInvoice(boolean)** - The method set if the customer wants invoice, params:\n\n1) invoice - Invoice (example. true, false)\n\n------\n\n**setOrderInvoice(object)** - The method set order Invoice, params:\n\n1) orderInvoice - Order Invoice object (example. in OrderInvoice builder)\n\n------\n\n**setTermsOfUse(boolean)** - The method set if the customer accept terms of use, params:\n\n1) termsOfUse - Terms of use (example. true, false)\n\n\n# Customer #\n\n\n**getJSON()** - The method returns the customer json\n\n------\n\n\n**setName(string)** - The method set name for customer, params:\n\n1) name - Customer name (example. 'Andrjew Sakasvili')\n\n------\n\n\n\n**setPhoneNumber(string)** - The method set customer phone number, params:\n\n1) phoneNumber - Phone number (example '669359630')\n\n\n# DeliveryAddress #\n\n\n**getJSON()** - The method returns the delivery address json\n\n------\n\n\n**setName(string)** - The method set name for delivery address, params:\n\n1) name - Delivery address name (example. 'dom')\n\n------\n\n\n\n**setCity(string)** - The method set city, params:\n\n1) city - City (example 'Warsaw')\n\n------\n\n\n**setStreet(string)** - The method set street, params:\n\n1) street - Street (example 'Bonifacego')\n\n------\n\n\n**setHouseNumber(string)** - The method set house number, params:\n\n1) number - House number (example '43', '54b')\n\n------\n\n\n**setApartNumber(string)** - The method set apart number, params:\n\n1) number - Apart number (example '12', '54a)\n\n\n# OrderInvoice #\n\n\n**getJSON()** - The method returns the order invoice json\n\n------\n\n**setAddressCity(string)** - The method set invoice city, params:\n\n1) addressCity - invoice city (example 'Warsaw')\n\n------\n\n\n**setAddressPostalcode(string)** - The method set postal code, params:\n\n1) addressPostalcode - invoice postal code (example '02-563')\n\n------\n\n**setName(string)** - The method set name for invoice, params:\n\n1) name - Invoice name (example. 'dom')\n\n------\n\n\n**setAddressStreet(string)** - The method set address street and number, params:\n\n1) addressStreet - Address street and number (example '43', '54b')\n\n------\n\n\n**setCompanyName(string)** - The method set company name, params:\n\n1) companyName - Company name (example 'Texeldon Sp.z.o.o')\n\n\n------\n\n**setTaxid(number)** - The method set tax id, params:\n\n1) taxid - tax number (example 11111111111)","maintainers":[{"name":"goodgulf","email":"artur.szady@3e.pl"}],"time":{"modified":"2022-06-13T02:46:57.624Z","created":"2017-06-12T07:05:23.674Z","1.0.0":"2017-06-12T07:05:23.674Z","1.0.1":"2017-06-19T09:00:14.065Z","1.0.2":"2017-06-12T07:53:32.828Z","1.0.3":"2017-06-12T11:21:15.618Z","1.0.4":"2017-06-12T11:29:29.551Z","1.0.5":"2017-06-12T11:51:11.861Z","1.0.6":"2017-06-13T06:11:57.193Z","1.0.7":"2017-06-13T06:22:01.430Z","1.0.8":"2017-06-13T08:05:14.537Z","1.0.9":"2017-06-13T09:38:31.611Z","1.1.0":"2017-06-14T08:07:32.516Z","1.1.1":"2017-06-14T13:13:32.715Z","1.1.2":"2017-06-16T06:41:26.074Z","1.1.3":"2017-06-19T06:24:02.800Z"},"homepage":"https://bitbucket.org/arturszady/amrestjslib#readme","keywords":["amrest"],"repository":{"type":"git","url":"git+https://arturszady@bitbucket.org/arturszady/amrestjslib.git"},"author":{"name":"Artur Szady & Bartłomiej Bocian"},"license":"ISC","readmeFilename":"README.md"}