PDA

View Full Version : Mandatory Parameters


the-ferret
18-12-07, 17:58
Hi guys, having played with the shopwindow client, I am now ready to delve into the mysterious world of the API and start coding more myself but have a real simple question that I have not found an answer to in the documentation;

Which parameters are mandatory?

for example the doc tells me that searchproduct has 11 parameters but do I need to populate them all?

If I do not include an array of merchant ids does it return all?

What if I do not specify a sort option, is there a default?

I guess that I coudl find the answer eventually by trying each different permutation but wondered if there is any beter documentation that I have missed.

thanks
Graham

authcode
18-12-07, 22:39
Hi Graham,

Although I built my sites from scratch using the API and what I could gleen from the client I can't provide a conclusive answer and would love to hear from anyone with more experience.

What I did find out is that there are two main ways of requesting data - through a generic client object or through a specific class object.

The first takes the form of:

$oClient = new api_client();
$aHotPicksParams = array('iCategoryId'=> 61, 'sSort'=> 'popular', 'iLimit'=> 6);
$oHotPicks = $oClient->call('getHotPickProductList', $aHotPicksParams);
$aProducts = $oHotPicks->getHotPickProductListReturn;

and as far as I remember only works when all of the expected parameters are passed.

The second takes the form of:

$oMerchant = new api_merchant();
$aMerchants = $oMerchant->getMerchant($oMerchantParams);

and as you will see if you look through the class defintions in the classes folder each specific class has default values for each parameter. The client doesn't have defaults because it doesn't know which call you are going to make.

I've used a mixture of client and specific calls but really can't say why or what the differences are. I just made it up as I went along and left what worked well alone. :)

Hope that helps.