/**
 * XMLRPC products for Max Havelaar
 * 
 * @author		Stijn Van Minnebruggen
 * @copyright	These Days
 * 
 * 
 * Settings
 * 
 */
	
	var api = '/lib/ajax/productsApi.php';
	
	var optionAll = '<option value="0">'+lang_all+'</option>';
	var optionLoading = '<option value="0">'+lang_loading+'</option>';
	var productURL = 'http://www.maxhavelaar.be/'+language+'/mh/product/detail/';
	var dummyImage = '/skin/img/global/blank.gif';
	
	var xmlrpc = false;
	var rpc_key, init;
	var rpc_country = domain;
	var rpc_language = language;
	var type = default_type;



/**
 * Page load
 * 
 */
 	
	$(document).ready(function() {
		
		
		/**
		 * Init and authenticate
		 * 
		 */
		
		$.rpc(api, 'xml', function(r) {
			xmlrpc = r;
			auth();
		});
		
		
		/**
		 * Init and get data
		 * 
		 */
		
		initAfterAuth = function() {
			getBrands();
			getRetailer();
			getCategories();
			canUpdateBrand = canUpdatePos = canUpdateCategory = true;
		};
		
		
		/**
		 * Submit button
		 * 
		 */
		
		$('#search').click(function() {
			if(xmlrpc) getProducts();
			return false;
		});
		
		
		
		/**
		 * Change dropdowns
		 * 
		 */
		
		$('#brand').change(function() {
			if($('#pos').val() == 0) getRetailer();
			if($('#category').val() == 0) getCategories();
		});
		
		$('#pos').change(function() {
			if($('#brand').val() == 0) getBrands();
			if($('#category').val() == 0) getCategories();
		});
		
		$('#category').change(function() {
			if($('#brand').val() == 0) getBrands();
			if($('#pos').val() == 0) getRetailer();
		});
		
		
		
		/**
		 * Change type
		 * 
		 */
		
		$('#type_1, #type_2, #type_3, #type_4').change(function() {
			type = parseFloat($(this).val());
			initAfterAuth();
		});
		
		
		
	});
	
	
	
/**
 * Brands
 * 
 */
	
	var getBrands = function() {
		
		// documentation
			/*
			
			i_am = 1
			mh.wholesale.getBrands(string, string, string, int, int, int, int) → array
			-- Get an array of brands available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			i_am = 2
			mh.wholesale.getBrandsForHoreca(string, string, string, int, int, int, int) → array
			-- Get an array of brands available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			i_am = 3
			mh.wholesale.getBrandsForInstitution(string, string, string, int, int, int, int) → array
			-- Get an array of brands available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			i_am = 4 ????
			mh.wholesale.getBrandsForRetail(string, string, string, int, int, int, int) → array
			-- Get an array of brands available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			i_am = 4 ????
			mh.retail.getBrands(string, string, string, int, int, int, int) → array
			-- Get an array of brands available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)
			
			*/
		
		// get vars
			var brand = parseFloat($('#brand').val());
			var pos = parseFloat($('#pos').val());
			var category = parseFloat($('#category').val());
			var query = $('#query').val();
			var oCountryId = 0;
		
		// make call
			switch(type) {
				case 1: xmlrpc.mh.wholesale.getBrandsForRetail(function(r) { getBrandsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
				case 2: xmlrpc.mh.wholesale.getBrandsForHoreca(function(r) { getBrandsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
				case 3: xmlrpc.mh.wholesale.getBrandsForInstitution(function(r) { getBrandsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
				default: case 4: xmlrpc.mh.wholesale.getBrands(function(r) { getBrandsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
			}
		
	};
	
	var getBrandsRes = function(r) {
		
		// settings
			var items = r.result;
			var html = '<option value="0">'+lang_all+'</option>';
			for(var i = 0; i<items.length; i++) {
				var item = items[i];
				html += '<option value="'+item.id+'">'+item.name+'</option>';
			}
		
		// add options
			$('#brand').html(html);
		
	};



/**
 * Retailers
 * 
 */
	
	var getRetailer = function() {
		
		// documentation
			/*
			
			mh.retail.getRetailers(string, string, string, int, int, int, int) → array
			-- Get an array of retailers available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)
			
			*/
		
		// get vars
			var brand = parseFloat($('#brand').val());
			var pos = parseFloat($('#pos').val());
			var category = parseFloat($('#category').val());
			var query = $('#query').val();
			var oCountryId = 0;
		
		// make call
			xmlrpc.mh.retail.getRetailers(function(r) {
				
				// settings
					var items = r.result;
					var html = optionAll;
					for(var i = 0; i<items.length; i++) {
						var item = items[i];
						html += '<option value="'+item.id+'">'+item.name+'</option>';
					}
				
				// add options
					$('#pos').html(html);
				
			}, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId);
		
	};



/**
 * Categories
 * 
 */
	
	var getCategories = function() {
		
		// documentation
			/*
			
			mh.retail.getProductCategories(string, string, string, int, int, int, int) → array
			-- Get an array of product categories available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)
			
			mh.wholesale.getProductCategories(string, string, string, int, int, int, int) → array
			-- Get an array of product categories available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			mh.wholesale.getProductCategoriesForHoreca(string, string, string, int, int, int, int) → array
			-- Get an array of product categories available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			mh.wholesale.getProductCategoriesForInstitution(string, string, string, int, int, int, int) → array
			-- Get an array of product categories available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			mh.wholesale.getProductCategoriesForRetail(string, string, string, int, int, int, int) → array
			-- Get an array of product categories available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)
			
			*/
		
		// get vars
			var brand = parseFloat($('#brand').val());
			var pos = parseFloat($('#pos').val());
			var category = parseFloat($('#category').val());
			var query = $('#query').val();
			var oCountryId = 0;
		
		// make call
			switch(type) {
				case 1: xmlrpc.mh.wholesale.getProductCategoriesForRetail(function(r) { getCategoriesRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
				case 2: xmlrpc.mh.wholesale.getProductCategoriesForHoreca(function(r) { getCategoriesRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
				case 3: xmlrpc.mh.wholesale.getProductCategoriesForInstitution(function(r) { getCategoriesRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
				default: case 4: xmlrpc.mh.wholesale.getProductCategories(function(r) { getCategoriesRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId); break;
			}
		
	};
	
	var getCategoriesRes = function(r) {
		
		// settings
			var items = r.result;
			var html = '<option value="0">'+lang_all+'</option>';
			for(var i = 0; i<items.length; i++) {
				var item = items[i];
				html += '<option value="'+item.id+'">'+item.name+'</option>';
			}
		
		// add options
			$('#category').html(html);
		
	};



/**
 * Products
 * 
 */
	
	var getProducts = function() {
		
		// documentation
			/* 
			
			mh.retail.searchProducts(string, string, string, int, int, int, int, string, int, int) → struct
			-- Search for products available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId, query, limit, limitOffset)

			mh.wholesale.searchProducts(string, string, string, int, int, int, int, string, int, int) → struct
			-- Search for products available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)
			
			mh.wholesale.searchProductsForHoreca(string, string, string, int, int, int, int, string, int, int) → struct
			-- Search for products available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)
			
			mh.wholesale.searchProductsForInstitution(string, string, string, int, int, int, int, string, int, int) → struct
			-- Search for products available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)
			
			mh.wholesale.searchProductsForRetail(string, string, string, int, int, int, int, string, int, int) → struct
			-- Search for products available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)
			
			*/
		
		// show loader
			showLoader();
		
		// get vars
			var brand = parseFloat($('#brand').val());
			var pos = parseFloat($('#pos').val());
			var category = parseFloat($('#category').val());
			var query = $('#query').val();
			var oCountryId = 0;
			var limit = 999;
			var limitOffset = 0;
		
		// make call
			switch(type) {
				case 1: xmlrpc.mh.wholesale.searchProductsForRetail(function(r) { getProductsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId, query, limit, limitOffset); break;
				case 2: xmlrpc.mh.wholesale.searchProductsForHoreca(function(r) { getProductsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId, query, limit, limitOffset); break;
				case 3: xmlrpc.mh.wholesale.searchProductsForInstitution(function(r) { getProductsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId, query, limit, limitOffset); break;
				default: case 4: xmlrpc.mh.wholesale.searchProducts(function(r) { getProductsRes(r); }, rpc_key, rpc_country, rpc_language, brand, pos, category, oCountryId, query, limit, limitOffset); break;
			}
		
	};
	
	var getProductsRes = function(r) {
		
		// settings
			var html = '';
			var prev_pos_id = -1;
			var prev_cat_id = -1;
                        
		// loop items
			for(var i in r.result) {
			
				// item
					var item = r.result[i];
				
				// generate pos html
					if(prev_pos_id != item['pos']['id']) {
						if(prev_pos_id != -1) html += '</ul></div></div>';
						html += '<div class="products_pos" id="pos_'+item['pos']['id']+'">';
						html += '<h3>'+item['pos']['name']+'</h3>';
						prev_pos_id = item['pos']['id'];
						prev_cat_id = -1;
					}
				
				// generate category html
					if(prev_cat_id != item['category']['id']) {
						if(prev_cat_id != -1) html += '</div>';
						html += '<div class="products_category" id="pos_'+item['category']['id']+'">';
						html += '<h4>'+item['category']['name']+'</h4>';
						html += '<ul class="products_products clearfix">';
						prev_cat_id = item['category']['id'];
					}
				
				// generate products html
					html += '<li id="product_'+item['id']+'">';
					html += '<a href="'+productURL+item['id']+'" target="_blank">';
				
				// image
					var image = dummyImage;
					if(item['packshot'] != '') image = item['packshot'];
					else if(item['category_image'] != '') image = item['category']['image'];
				
				// end product
					html += '<div class="imgFrame"><img src="'+image+'" alt="'+item['name']+'" /></div>';
					html += item['name'];
					html += '</a>';
					html += '</li>';
				
			}
		
		// end html
			html += '</ul></div></div>';
		
		// show results
			$('#product_results').html(html).parent('div').show();
		
	}


/**
 * Loader
 * 
 */
	
	var showLoader = function() {
		$('#product_results').html('<img src="/skin/img/load-bg-3.gif" alt="" /> '+lang_loading).parent('div').show();
	};
	
	var hideLoader = function() {
		$('#product_results').empty();
	};
	
	var auth = function() {
		$.post(api, { 'auth': true }, function(r) {
			rpc_key = $(r).find('string').text();
			initAfterAuth();
		}, 'xml');
	}




/**
 * Settings
 * 
 *

////////////////// NEW //////////////////


Enkele opmerkingen:

 
1) je zou eerst security.authenticate moeten oproepen, en met het resulterende session id kan je dan de andere methodes oproepen
2) wat land betreft kan je be of nl als parameter meegeven
3) locale is nl, fr of en
 
De XMLRPC-server bevindt zich op http://products.maxhavelaar.be/xmlrpc <http://products.maxhavelaar.be/xmlrpc> 

·        mh.coffee.getCoffeeSystem(string, string, string, int) → struct

Get the data of a coffee system by its id. (sessionId, country, locale, id)

·        mh.coffee.getCoffeeSystems(string, string, string, int, int, int, int) → array

Get an array of coffee systems. (sessionId, country, locale, sizeTypeId, serviceLevelId, coffeeTypeId, coffeeSystemId)

·        mh.coffee.getCoffeeType(string, string, string, int) → struct

Get the data of a coffee type by its id. (sessionId, country, locale, id)

·        mh.coffee.getCoffeeTypes(string, string, string, int, int, int, int) → array

Get an array of coffee types. (sessionId, country, locale, sizeTypeId, serviceLevelId, coffeeTypeId, coffeeSystemId)

·        mh.coffee.getLicensees(string, string, string, int, int, int, int, int, int) → array

Get an array of licensees who handle coffee. (sessionId, country, locale, sizeTypeId, serviceLevelId, coffeeTypeId, coffeeSystemId, limit, limitOffset)

·        mh.coffee.getServiceLevel(string, string, string, int) → struct

Get the data of a service level by its id. (sessionId, country, locale, id)

·        mh.coffee.getServiceLevels(string, string, string, int, int, int, int) → array

Get an array of service levels. (sessionId, country, locale, sizeTypeId, serviceLevelId, coffeeTypeId, coffeeSystemId)

·        mh.coffee.getSizeType(string, string, string, int) → struct

Get the data of a size type by its id. (sessionId, country, locale, id)

·        mh.coffee.getSizeTypes(string, string, string, int, int, int, int) → array

Get an array of size types. (sessionId, country, locale, sizeTypeId, serviceLevelId, coffeeTypeId, coffeeSystemId)

·        mh.common.getCountry(string, string, string, int) → struct

Get the data of a country by its id. (sessionId, country, locale, countryId)

·        mh.common.getLicensee(string, string, string, int) → struct

Get the data of a licensee by its id. (sessionId, country, locale, licenseeId)

·        mh.common.getLicenseesStartsWith(string, string, string, string) → array

Get an array of licensees whose name starts with query. (sessionId, country, locale, query)

·        mh.common.getProducer(string, string, string, int) → struct

Get the data of a producer by its id. (sessionId, country, locale, producerId)

·        mh.common.getProducerIngredients(string, string, string, int) → array

Get an array of ingredients of a producer. (sessionId, country, locale, producerId)

·        mh.product.getNewProduct(string, string, string) → struct

Get the data of a new product. (sessionId, country, locale)

·        mh.product.getNewProducts(string, string, string, int) → array

Get an array of new products. (sessionId, country, locale, limit)

·        mh.product.getProduct(string, string, string, int) → struct

Get the data of a product by its id. (sessionId, country, locale, productId)

·        mh.product.getProductRetailers(string, string, string, int) → array

Get an array of retailers for a product. (sessionId, country, locale, productId)

·        mh.product.getRandomProduct(string, string, string) → struct

Get the data of a random product. (sessionId, country, locale)

·        mh.product.getRandomProducts(string, string, string, int) → array

Get an array of random products. (sessionId, country, locale, limit)

·        mh.product.getSpotlightProduct(string, string, string) → struct

Get the data of a product in spotlight. (sessionId, country, locale)

·        mh.product.getSpotlightProducts(string, string, string, int) → struct

Get an array of products in spotlight. (sessionId, country, locale, limit)

·        mh.product.searchProducts(string, string, string, string, int) → array

Search for products. (sessionId, country, locale, query, limit)

·        mh.retail.getBrands(string, string, string, int, int, int, int) → array

Get an array of brands available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)

·        mh.retail.getCountries(string, string, string, int, int, int, int) → array

Get an array of countries of origin available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)

·        mh.retail.getProductCategories(string, string, string, int, int, int, int) → array

Get an array of product categories available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)

·        mh.retail.getRetailers(string, string, string, int, int, int, int) → array

Get an array of retailers available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId)

·        mh.retail.searchProducts(string, string, string, int, int, int, int, string, int, int) → struct

Search for products available in retail. (sessionId, country, locale, brandId, retailerId, productCategoryId, originCountryId, query, limit, limitOffset)

·        mh.story.getContinents(string, string, string, int, int, int, int) → array

Get an array of continents linked with the stories. (sessionId, country, locale, productCategoryId, producerId, countryId, continentId)

·        mh.story.getCountries(string, string, string, int, int, int, int) → array

Get an array of countries linked with the stories. (sessionId, country, locale, productCategoryId, producerId, countryId, continentId)

·        mh.story.getProducerStories(string, string, string, int) → array

Get an array of stories for a producer by its id. (sessionId, country, locale, producerId)

·        mh.story.getProducers(string, string, string, int, int, int, int) → array

Get an array of producers with stories. (sessionId, country, locale, productCategoryId, producerId, countryId, continentId)

·        mh.story.getProductCategories(string, string, string, int, int, int, int) → array

Get an array of product categories linked with the stories. (sessionId, country, locale, productCategoryId, producerId, countryId, continentId)

·        mh.story.getRandomPortrait(string, string, string) → struct

Get a random story of the portrait type. (sessionId, country, locale)

·        mh.story.getRandomPortraits(string, string, string, int) → array

Get an array of random stories of the portrait type. (sessionId, country, locale, limit)

·        mh.story.getRandomProfile(string, string, string) → struct

Get a random story of the profile type. (sessionId, country, locale)

·        mh.story.getRandomProfiles(string, string, string, int) → array

Get an array of random stories of the profile type. (sessionId, country, locale, limit)

·        mh.story.getRandomStories(string, string, string, int) → array

Get an array of random stories. (sessionId, country, locale, limit)

·        mh.story.searchProducers(string, string, string, string, int) → array

Search for producers with a story. (sessionId, country, locale, query, limit)

·        mh.story.searchStories(string, string, string, int, int, int, int, string) → struct

Search for stories. (sessionId, country, locale, productCategoryId, producerId, countryId, continentId, query)

·        mh.wholesale.getBrands(string, string, string, int, int, int, int) → array

Get an array of brands available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getBrandsForHoreca(string, string, string, int, int, int, int) → array

Get an array of brands available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getBrandsForInstitution(string, string, string, int, int, int, int) → array

Get an array of brands available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getBrandsForRetail(string, string, string, int, int, int, int) → array

Get an array of brands available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getCountries(string, string, string, int, int, int, int) → array

Get an array of countries available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getCountriesForHoreca(string, string, string, int, int, int, int) → array

Get an array of countries available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getCountriesForInstitution(string, string, string, int, int, int, int) → array

Get an array of countries available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getCountriesForRetail(string, string, string, int, int, int, int) → array

Get an array of countries available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getProductCategories(string, string, string, int, int, int, int) → array

Get an array of product categories available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getProductCategoriesForHoreca(string, string, string, int, int, int, int) → array

Get an array of product categories available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getProductCategoriesForInstitution(string, string, string, int, int, int, int) → array

Get an array of product categories available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getProductCategoriesForRetail(string, string, string, int, int, int, int) → array

Get an array of product categories available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getWholesalers(string, string, string, int, int, int, int) → array

Get an array of wholesalers available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getWholesalersForHoreca(string, string, string, int, int, int, int) → array

Get an array of wholesalers available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getWholesalersForInstitution(string, string, string, int, int, int, int) → array

Get an array of wholesalers available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.getWholesalersForRetail(string, string, string, int, int, int, int) → array

Get an array of wholesalers available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId)

·        mh.wholesale.searchProducts(string, string, string, int, int, int, int, string, int, int) → struct

Search for products available in wholesale. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)

·        mh.wholesale.searchProductsForHoreca(string, string, string, int, int, int, int, string, int, int) → struct

Search for products available in wholesale for horeca. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)

·        mh.wholesale.searchProductsForInstitution(string, string, string, int, int, int, int, string, int, int) → struct

Search for products available in wholesale for institution. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)

·        mh.wholesale.searchProductsForRetail(string, string, string, int, int, int, int, string, int, int) → struct

Search for products available in wholesale for retail. (sessionid, country, locale, brandId, wholesalerId, productCategoryId, originCountryId, query, limit, limitOffset)

·        security.authenticate(string, string) → string

Authenticate yourself with your username and password and retrieve your session id. (username, password)

·        system.listMethods() → array

This method returns a list of the methods the server has, ordered by name.

·        system.methodHelp(string) → string

This method returns a text description of a particular method. (methodName)

·        system.methodSignature(string) → array

This method returns a description of the argument format a particular method expects. (methodName)

·        system.multicall(array) → array

This method takes one parameter, an array of 'request' struct types, and calls multiple methods in one call. Each request struct must contain a methodName member of type string and a params member of type array, and corresponds to the invocation of the corresponding method. (requests)


////////////////// OLD //////////////////


url
---
http://www.maxhavelaar.be/xmlrpc.php

Overzicht methodes
------------------
mh.getBrands(languageCode)
mh.getBrandsForCategory(categoryId, languageCode)

mh.getCategories(languageCode)

mh.getProducts(categoryId, languageCode) 
mh.getProduct(langaugeCode, productId)
mh.getRandomProduct(languageCode)
mh.getNewProduct(languageCode)

mh.getRetailers(languageCode)
mh.getWholesalersForRetail(languageCode)
mh.getWholesalersForHoreca(languageCode)
mh.getWholesalersForInstitutionalConsumers(languageCode)

mh.searchProfiles(languageCode, categoryId, partnerId, country, continent)
mh.getStoryInSpotlight(languageCode)
mh.getProductInSpotlight(languageCode)

mh.searchGetBrands(iAm, brandId, posId, categoryId, languageCode)
mh.searchGetCategories(iAm, brandId, posId, categoryId, languageCode)
mh.searchGetPos(iAm, brandId, posId, categoryId, languageCode)
mh.searchGetProducts(iAm, brandId, posId, categoryId, queryString, languageCode)

Overzicht mogelijke parameters
------------------------------
language_code: nl of fr

product_id: primary key van een product
brand_id: primary key van een merk, om te negeren 0 meegeven
category_id: primary key van een category, om te negeren 0 meegeven

i_am: 1 voor winkel, 2 voor horeca, 3 voor organisatie en 4 voor particulier
pos_id: hangt af van i_am:
 i_am is 1: pos_id is primary key een wholesaler_for_retail
 i_am is 2: pos_id is primary key van een wholesaler_for_horeca
 i_am is 3: pos_id is primary key van een wholesaler_for_institutional_consumer
 i_am is 4: pos_id is primary key van een retailer om te negeren 0 meegeven

query: zoektekst, mag leeg zijn



*/

