AOTG API: Debtor Lookup: Difference between revisions

No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1:
==Debtor Lookup==
Get a list of customer.
{{AOTGApiMethodsSpec|GET|/api/public/v1/Lookup/DebtorLookup|Params=None$filter, $top}}
<br/>
==Code Snippets==
Line 95:
200 OK
====Response Successful Body====
*Result contains of 2 debtors.<br/>1st debtor has more data than the 2nd debtor., Asas the 1st debtor has 2 Branches.
<syntaxhighlight lang="json-object">
[
Line 209:
]
</syntaxhighlight>
 
<br/>
 
==Filter result==
Use parameter of $filter or $top to filter the result of debtor.
 
===Code Snippets===
*Below sample uses 3 conditions to '''filter''' the result
*#Debtor code that contains "300", and convert all characters to small letter.
*#Company Name that contains "abc"
*#Customer who is still active
*Result is then restricted to maximum of 15
<pre>
http://aotg.cloud:8080/api/Lookup/DebtorLookup/api/Lookup/DebtorLookup?$filter=(substringof('300',tolower(AccNo)) or substringof('abc',tolower(CompanyName))) and IsActive eq true&$top=15
</pre>
 
{{AOTGApiCodeSnippetTab
|Python=
<syntaxhighlight lang="Python">
import requests
 
url = "http://aotg.cloud:8080/api/Lookup/DebtorLookup"
 
querystring = {"$filter":"%28substringof%28%27300%27,tolower%28AccNo%29%29%20or%20substringof%28%27abc%27,tolower%28CompanyName%29%29%29%20and%20IsActive%20eq%20true","$top":"15"}
 
payload = ""
headers = {
'SOTC_AUTH': "SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
'Content-Type': "application/json",
'cache-control': "no-cache"
}
 
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
 
print(response.text)
</syntaxhighlight>
|PHPHttp=
<syntaxhighlight lang="PHP">
<?php
 
$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/Lookup/DebtorLookup');
$request->setMethod(HTTP_METH_GET);
 
$request->setQueryData(array(
'$filter' => '%28substringof%28%27300%27,tolower%28AccNo%29%29%20or%20substringof%28%27abc%27,tolower%28CompanyName%29%29%29%20and%20IsActive%20eq%20true',
'$top' => '15'
));
 
$request->setHeaders(array(
'cache-control' => 'no-cache',
'Content-Type' => 'application/json',
'SOTC_AUTH' => 'SAMs1a36d2-a139-e911-b8b3-000aa03t3d'
));
 
try {
$response = $request->send();
 
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
</syntaxhighlight>
|RestSharp=
<syntaxhighlight lang="C#">
var client = new RestClient("http://aotg.cloud:8080/api/Lookup/DebtorLookup?$filter=%28substringof%28%27300%27,tolower%28AccNo%29%29%20or%20substringof%28%27abc%27,tolower%28CompanyName%29%29%29%20and%20IsActive%20eq%20true&$top=15");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("SOTC_AUTH", "SAMs1a36d2-a139-e911-b8b3-000aa03t3d");
IRestResponse response = client.Execute(request);
</syntaxhighlight>
|PHPcURL=
<syntaxhighlight lang="PHP">
<?php
 
$curl = curl_init();
 
curl_setopt_array($curl, array(
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://aotg.cloud:8080/api/Lookup/DebtorLookup?$filter=%28substringof%28%27300%27,tolower%28AccNo%29%29%20or%20substringof%28%27abc%27,tolower%28CompanyName%29%29%29%20and%20IsActive%20eq%20true&$top=15",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"SOTC_AUTH: SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
"cache-control: no-cache"
),
));
 
$response = curl_exec($curl);
$err = curl_error($curl);
 
curl_close($curl);
 
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
</syntaxhighlight>
}}
 
<br/>