var api = api || {}; api = { metadata: [{"Method":"POST","Url":"api/Cart/GetPriceAndCurrencyForCheckout","ControllerName":"Cart","ActionName":"GetPriceAndCurrencyForCheckout","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Cart/LockCart","ControllerName":"Cart","ActionName":"LockCart","Parameters":[]},{"Method":"POST","Url":"api/Cart/LoadCart","ControllerName":"Cart","ActionName":"LoadCart","Parameters":[]},{"Method":"POST","Url":"api/Cart/GetCartRowProduct","ControllerName":"Cart","ActionName":"GetCartRowProduct","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Cart/GetNumberOfRows","ControllerName":"Cart","ActionName":"GetNumberOfRows","Parameters":[]},{"Method":"POST","Url":"api/Cart/GetTotalCartSum","ControllerName":"Cart","ActionName":"GetTotalCartSum","Parameters":[]},{"Method":"POST","Url":"api/Cart/AddToCart","ControllerName":"Cart","ActionName":"AddToCart","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Cart/RemoveFromCart","ControllerName":"Cart","ActionName":"RemoveFromCart","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Cart/RemoveCart","ControllerName":"Cart","ActionName":"RemoveCart","Parameters":[]},{"Method":"POST","Url":"api/Cart/UpdateCart","ControllerName":"Cart","ActionName":"UpdateCart","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Cart/IsProductsInStock","ControllerName":"Cart","ActionName":"IsProductsInStock","Parameters":[]},{"Method":"POST","Url":"api/Cart","ControllerName":"Cart","ActionName":"AddHistoryOrderToCart","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Compare/Properties","ControllerName":"Compare","ActionName":"GetProductsProperties","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Customer/GetAuth","ControllerName":"Customer","ActionName":"GetAuth","Parameters":[]},{"Method":"POST","Url":"api/Customer/RequestElectronicInvoice","ControllerName":"Customer","ActionName":"RequestElectronicInvoice","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Customer/GetTransportTermDescription","ControllerName":"Customer","ActionName":"GetTransportTermDescription","Parameters":[]},{"Method":"POST","Url":"api/Customer/GetCustomerData","ControllerName":"Customer","ActionName":"GetCustomerData","Parameters":[]},{"Method":"POST","Url":"api/Customer/GetCustomerInfo","ControllerName":"Customer","ActionName":"GetCustomerInfo","Parameters":[]},{"Method":"POST","Url":"api/Customer/IsRegisteredCustomer","ControllerName":"Customer","ActionName":"IsRegisteredCustomer","Parameters":[]},{"Method":"POST","Url":"api/Customer/SavePendingCustomer","ControllerName":"Customer","ActionName":"SendNewPendingCustomerRequest","Parameters":[]},{"Method":"POST","Url":"api/Customer/RequestNewUser","ControllerName":"Customer","ActionName":"RequestNewUser","Parameters":[]},{"Method":null,"Url":"api/Customer","ControllerName":"Customer","ActionName":"SendNewUserRequest","Parameters":[]},{"Method":"POST","Url":"api/DeliverySettings/GetUserReference","ControllerName":"DeliverySettings","ActionName":"GetUserReference","Parameters":[]},{"Method":"POST","Url":"api/DeliverySettings/LoadDeliverySettings","ControllerName":"DeliverySettings","ActionName":"LoadDeliverySettings","Parameters":[]},{"Method":"POST","Url":"api/DeliverySettings/GetDefaultDeliverySetting","ControllerName":"DeliverySettings","ActionName":"GetDefaultDeliverySetting","Parameters":[]},{"Method":"POST","Url":"api/DeliverySettings/GetDeliverySetting","ControllerName":"DeliverySettings","ActionName":"GetDeliverySetting","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/DeliverySettings/SaveOrderDetailsToDeliverySetting","ControllerName":"DeliverySettings","ActionName":"SaveOrderDetailsToDeliverySetting","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/DeliverySettings/SaveDeliverySetting","ControllerName":"DeliverySettings","ActionName":"SaveDeliverySetting","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/DeliverySettings/DeleteDeliverySetting","ControllerName":"DeliverySettings","ActionName":"DeleteDeliverySetting","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Language","ControllerName":"Language","ActionName":"Get","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":null,"Url":"api/Language","ControllerName":"Language","ActionName":"GetLang","Parameters":[]},{"Method":"POST","Url":"api/Navigation/GetSectors","ControllerName":"Navigation","ActionName":"GetSectors","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Navigation/GetSectorName","ControllerName":"Navigation","ActionName":"GetSectorName","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Navigation/GetFamilyName","ControllerName":"Navigation","ActionName":"GetFamilyName","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Navigation/GetGroupName","ControllerName":"Navigation","ActionName":"GetGroupName","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Navigation/GetBreadcrumb","ControllerName":"Navigation","ActionName":"GetBreadcrumb","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Navigation/GetPages","ControllerName":"Navigation","ActionName":"GetPages","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Navigation/GetFooterLinks","ControllerName":"Navigation","ActionName":"GetFooterLinks","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/OrderHistory/Orderhistory","ControllerName":"OrderHistory","ActionName":"GetOrderHistory","Parameters":[]},{"Method":"POST","Url":"api/OrderHistory/Orderhistorydetails","ControllerName":"OrderHistory","ActionName":"GetOrderHistoryDetails","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/OrderHistory/GetTop10","ControllerName":"OrderHistory","ActionName":"GetTop10","Parameters":[]},{"Method":"POST","Url":"api/OrderSummary/GetSummary","ControllerName":"OrderSummary","ActionName":"GetSummary","Parameters":[]},{"Method":"POST","Url":"api/Payment","ControllerName":"Payment","ActionName":"Init","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"GET","Url":"api/Payment/Complete","ControllerName":"Payment","ActionName":"Complete","Parameters":[]},{"Method":null,"Url":"api/Payment","ControllerName":"Payment","ActionName":"GetOrderWeightVolume","Parameters":[]},{"Method":"POST","Url":"api/PaymentTerm/GetPaymentTerms","ControllerName":"PaymentTerm","ActionName":"GetPaymentTerms","Parameters":[]},{"Method":"POST","Url":"api/Product/SendFaq","ControllerName":"Product","ActionName":"SendFaq","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/GetDisp","ControllerName":"Product","ActionName":"GetDisp","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/GetLeadTime","ControllerName":"Product","ActionName":"GetLeadTime","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/ItemBalanceStores","ControllerName":"Product","ActionName":"GetItemBalanceStores","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/AddQuickToCart","ControllerName":"Product","ActionName":"AddQuickToCart","Parameters":[]},{"Method":null,"Url":"api/Product","ControllerName":"Product","ActionName":"GetExistingQuickProductsFromCache","Parameters":[]},{"Method":null,"Url":"api/Product","ControllerName":"Product","ActionName":"GetAll","Parameters":[]},{"Method":null,"Url":"api/Product","ControllerName":"Product","ActionName":"GetQuickOrderKey","Parameters":[]},{"Method":null,"Url":"api/Product","ControllerName":"Product","ActionName":"ClearQuickOrderCache","Parameters":[]},{"Method":"POST","Url":"api/Product/GetQuickProducts","ControllerName":"Product","ActionName":"ParseQuickOrdeProducts","Parameters":[{"Name":"text","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/News","ControllerName":"Product","ActionName":"GetNews","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/Campaign","ControllerName":"Product","ActionName":"GetCampaign","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/GetFormattedPrice","ControllerName":"Product","ActionName":"GetFormattedPrice","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/Short","ControllerName":"Product","ActionName":"GetProductInfoShort","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/View","ControllerName":"Product","ActionName":"GetView","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Product/Pdf","ControllerName":"Product","ActionName":"GetPdfDocument","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Search/Suggest","ControllerName":"Search","ActionName":"Suggest","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Search/SuggestResult","ControllerName":"Search","ActionName":"SuggestResult","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Search/GetSearchResults","ControllerName":"Search","ActionName":"GetSearchResults","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Serie/Serie","ControllerName":"Serie","ActionName":"GetSerie","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/SplitOrder/GetBackorderItems","ControllerName":"SplitOrder","ActionName":"GetBackorderItems","Parameters":[]},{"Method":"POST","Url":"api/SplitOrder/HasDiscontinuedItemsWithMaxExceeded","ControllerName":"SplitOrder","ActionName":"HasDiscontinuedItemsWithMaxExceeded","Parameters":[]},{"Method":"POST","Url":"api/StartpageModules/GetModules","ControllerName":"StartpageModules","ActionName":"GetModules","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Store/GetPickupLocations","ControllerName":"Store","ActionName":"GetPickupLocations","Parameters":[]},{"Method":"POST","Url":"api/Store/GetStore","ControllerName":"Store","ActionName":"GetStore","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Store/GetStores","ControllerName":"Store","ActionName":"GetStores","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Store/GetCompanyMainOffice","ControllerName":"Store","ActionName":"GetCompanyMainOffice","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/User/IsAuthenticated","ControllerName":"User","ActionName":"IsAuthenticated","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/User/GetUserEmail","ControllerName":"User","ActionName":"GetUserEmail","Parameters":[]},{"Method":"POST","Url":"api/User/SaveUserData","ControllerName":"User","ActionName":"SaveUserData","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/User/GetUserData","ControllerName":"User","ActionName":"GetUserData","Parameters":[]},{"Method":"POST","Url":"api/User/ResetPassword","ControllerName":"User","ActionName":"ResetPassword","Parameters":[{"Name":"request","IsUriParameter":false}]},{"Method":"POST","Url":"api/Webnews/Webnews","ControllerName":"Webnews","ActionName":"GetWebnews","Parameters":[{"Name":"request","IsUriParameter":false}]}] }; $.each(api.metadata, function(i, action) { if (!api[action.ControllerName]) { api[action.ControllerName] = {}; } api[action.ControllerName][action.ActionName] = function(parameters, successCallback, _component) { var url = '/' + action.Url; var data; $.each(action.Parameters, function(j, parameter) { if (parameters[parameter.Name] === undefined) { console.log('Missing parameter: ' + parameter.Name + ' for API: ' + action.ControllerName + '/' + action.ActionName); } else if (parameter.IsUriParameter) { url = url.replace("{" + parameter.Name + "}", parameters[parameter.Name]); } else if (data === undefined) { data = parameters[parameter.Name]; } else { console.log('Detected multiple body-parameters for API: ' + action.ControllerName + '/' + action.ActionName); } }); if (data != null && data != "") data = JSON.stringify(data); return $.ajax({ type: action.Method, url: url, data: data, contentType: 'application/json', cache: false, processData: false, success: function(data, textStatus, xhr) { if (!successCallback) return; successCallback(data, _component); }, error: function(xhr, textStatus, errorThrown) { console.error(errorThrown); if(window.errorHandler){ window.errorHandler(xhr, textStatus, errorThrown); } } }); }; });