def dinnerMenu(request, location): request.session['location'] = location time = "Dinner" request.session['time'] = "Dinner" site = request.session.get('location') menustring = site.lower()+time if menustring in MENUMAPPINGS: menuMapping = MENUMAPPINGS[menustring] else: return render(request, 'error.html') url = 'https://api.ncr.com/menu/v2/menu-details/' + menuMapping if site == 'Highland': conn = requests.get(url, auth=(HMACAuth(HIGHLAND))) elif site == 'Midtown': conn = requests.get(url, auth=(HMACAuth(MIDTOWN))) elif site == 'Southland': conn = requests.get(url, auth=(HMACAuth(SOUTHLAND))) results = menuParsing(conn.json()) request.session[menustring] = results context = {'items': results, 'time': time, 'site': site, 'locations': MATCHES} return render(request, 'menu.html', context)
def getOrders(): url = 'https://api.ncr.com/order/3/orders/1/find?pageNumber=0&pageSize=10' payload = "{\"customerEmail\":\"[email protected]\",\"returnFullOrders\":true}" res = requests.post(url, payload, auth=(HMACAuth())) result = res.json()
def findResturantsInRange(coordinates, radius): meters = 1609 y = coordinates['y'] x = coordinates['x'] circle = radius * meters url = 'https://api.ncr.com/site/sites/find-nearby/%s,%s' % ( coordinates['y'], coordinates['x']) payload = { 'numSites': 10, 'radius': circle, } r = requests.get(url, params=payload, auth=(HMACAuth())) temp = r.json() rjson = json.dumps(temp) rjson = json.loads(rjson) sites = [] for site in rjson['sites']: sites.append(site) return sites
def getOrder(orderId): headers = { 'content-type': 'application/json', 'nep-organization': 'burgers-unlimited', 'nep-correlation-id': '2020-0708', } url = 'https://api.ncr.com/order/3/orders/1/%s' % orderId res = requests.get(url, auth=(HMACAuth()), headers=headers) result = res.json()
def getStoreItems(storeName): url = 'https://api.ncr.com/catalog/items?merchandiseCategoryId=%s&itemStatus=ACTIVE' % storeName r = requests.get(url, auth=(HMACAuth())) tempItems = r.json() storeItems = [] for item in tempItems['pageContent']: for nestedItem in item['itemId'].values(): name = nestedItem department = item['departmentId'] result = {} result.update({'name': name, 'department': department}) storeItems.append(result) return storeItems
def getAllPrices(itemIds, enterpriseId): url = 'https://api.ncr.com/catalog/item-prices/get-multiple' itemNames = [] for i in range(len(itemIds)): itemNames.append(itemIds[i]['name']) modifiedItems = createJsonString(itemNames) payload = "{\"itemIds\":[%s]}" % modifiedItems r = requests.post(url, payload, auth=(HMACAuth(enterpriseId))) tempPrices = r.json() itemsWithPrices = [] i = 0 for item in tempPrices['itemPrices']: result = {} price = item.get('price') nested = item.get('priceId') name = nested.get('itemCode') department = -99 for collection in itemIds: if collection['name'] == name: department = collection['department'] price = addChange(price) name = addSpacesInbetweenCaptialLetters(name) if isUnique(itemsWithPrices, name): result.update({ 'name': name, 'price': price, 'department': department }) itemsWithPrices.append(result) i += 1 else: result.update({'name': name, 'price': price}) return itemsWithPrices
def createOrder(cart): results = [] for dict in range(len(cart)): results.append(createPayload(cart[dict])) modified_results = doubleQ(results) customer = { "email": "*****@*****.**", "firstName": "Testy", "lastName": "McTest Test" } modified_customer = doubleQ(customer) payload = "{\"comments\":\"This is a test4\",\"customer\":%s,\"orderLines\":%s}" % ( modified_customer, modified_results) url = 'https://api.ncr.com/order/orders' res = requests.post( url, payload, auth=(HMACAuth(settings.LOCATIONS["Burgers Unlimited Southland"]))) result = res.json() return result['id']
import requests from HMACAuth import HMACAuth if __name__ == '__main__': url = 'https://gateway.ncrplatform.com/catalog/items' r = requests.get(url, auth=(HMACAuth())) temp = r.json() print(temp)
def delete(id, siteName): url = 'https://gateway-staging.ncrcloud.com/site/sites/%s' % id payload = "{\"siteName\":\"%s\",\"enterpriseUnitName\":\"%s\",\"coordinates\":{\"latitude\":33.6407,\"longitude\":-84.4277},\"status\":\"INACTIVE\"}" % ( siteName, siteName) request = requests.put(url, payload, auth=(HMACAuth())) return request.json()
def queryById(id): url = 'https://gateway-staging.ncrcloud.com/site/sites/%s' % id request = requests.get(url, auth=(HMACAuth())) return request.json()
def queryAll(): url = 'https://gateway-staging.ncrcloud.com/site/sites/find-by-criteria?pageSize=10000' payload = "{\"criteria\":{\"status\": \"ACTIVE\"}}" request = requests.post(url, payload, auth=(HMACAuth())) return request.json()
def create(siteName, enterpriseUnitName): url = 'https://gateway-staging.ncrcloud.com/site/sites' payload = "{\"siteName\":\"%s\",\"enterpriseUnitName\":\"%s\",\"coordinates\":{\"latitude\":33.6817952,\"longitude\":-84.4239568},\"status\":\"ACTIVE\"}" % ( siteName, enterpriseUnitName) r = requests.post(url, payload, auth=(HMACAuth()))
def createPrice(itemName, itemPriceId, version, price, enterpriseId): url = 'https://api.ncr.com/catalog/item-prices/%s/%s' % (itemName, itemPriceId) payload = "{\"version\":%s,\"price\":%s,\"currency\":\"US Dollar\",\"effectiveDate\":\"2020-07-16T18:22:05.784Z\",\"status\":\"INACTIVE\"}" % ( version, price) r = requests.put(url, payload, auth=(HMACAuth(enterpriseId)))
def getItem(itemName): url = url = 'https://api.ncr.com/catalog/items/%s' % itemName r = requests.get(url, auth=(HMACAuth())) return r.json()
def createItem(itemName, version, shortDescription, location, department): url = 'https://api.ncr.com/catalog/items/%s' % (itemName) payload = "{\"version\":%s,\"shortDescription\":{\"values\":[{\"locale\":\"en-US\",\"value\":\"%s\"}]},\"status\":\"INACTIVE\",\"merchandiseCategory\":\"%s\",\"departmentId\":\"%s\"}" % ( version, shortDescription, location, department) r = requests.put(url, payload, auth=(HMACAuth())) return r.json()
def getPrice(itemName, itemPriceId, enterpriseId): url = 'https://api.ncr.com/catalog/item-prices/%s/%s' % (itemName, itemPriceId) r = requests.get(url, auth=(HMACAuth(enterpriseId))) return r.json()