Snippets

Monil Gandhi Get Banners for peresonnel

Created by Monil Gandhi

File GetBanners.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+require_once (__DIR__ . '/../../vendor/autoload.php');
+/**
+ *
+ * @author braango
+ *        
+ *         Sample code showing how to get banners for a personnel
+ *        
+ */
+
+// TEST auth token. Please contact
+// sales@braango.com to have one
+// created for you
+Braango\Configuration::getDefaultConfiguration()->setApiKey('auth_token', 'ISNWF0P30WM0CMK');
+
+$api_instance = new Braango\braangoapi\BannersApi();
+
+// string | id of _sub_dealer_
+$subdealerid = "subdealers2002";
+
+// string | id of _personnel_
+$salespersonid = "d1e5cb9c-def7-4273-85c7-46a1b5e46869";
+
+// string | Banner type - `client` , `dealer` , `supervisor`
+$bannertype = "supervisor";
+
+// string | API Key to access this dealer's resources. 
+// Value was returned when create_account api was 
+// called and dealer was created first time
+$apiKey = "ISNMdzuNiKG7jhl9d9v";
+
+// string | Dealer or partner is accessing this API
+$accountType = "partner";
+
+try {
+    $result = $api_instance->getBanners($subdealerid, $salespersonid, $bannertype, $apiKey, $accountType);
+    if ($result != null) {
+        // Extract out response hdr and bdy
+        $rspHdr = $result->getHeader();
+        
+        if ($requestHdr = ! null) {
+            $rspId = $rspHdr->getId();
+            $braangoRequestId = $rspHdr->getIsnRequestId();
+            print_r("Response ID = " . $rspId . ", API Request Id = " . $braangoRequestId . "\n");
+            
+        }
+        
+        $rspBdy = $result->getBody();
+        if ($rspBdy != null) {
+            $status = $rspBdy->getStatus();
+            
+            // Typically this value should be always SUCCESS else exception will be thrown
+            // Sometimes, this can be WARNING to indicate if any resource conflicted or not
+            // In case of SUCCESS or WARNING, resources are always created (excepting warned sub-resources)
+            print_r("Status = " . $status . "\n");
+            
+            $bannersOutPutBodyData = $rspBdy->getData();
+            
+            $bannersDealer = $bannersOutPutBodyData->getDealerBanners();
+            $bannersClient = $bannersOutPutBodyData->getClientBanners();
+            $bannersSupervisor = $bannersOutPutBodyData->getSupervisorBanners();
+            
+            // Prints either the Client, Dealer, and Supervisor Banners
+            if ($bannertype == "client") {
+                print "Client Banners = ";
+                print_r($bannersClient);
+            } else if ($bannertype == "dealer") {
+                print "Dealer Banners = ";
+                print_r($bannersDealer);
+            } else {
+                print "Supervisor Banners = ";
+                print_r($bannersSupervisor);
+            }
+        }
+    }
+} catch (Exception $e) {
+    echo 'Exception when calling BannersApi->getBanners: ', $e->getMessage(), PHP_EOL;
+}
+?>
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.