Snippets

Purvesh Khona Get Banners for peresonnel

Created by Purvesh Khona
/**
 * 
 */
package com.braango.virtualdealer.banners;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.braango.client.ApiCallback;
import com.braango.client.ApiClient;
import com.braango.client.ApiException;
import com.braango.client.braangoapi.BannersApi;
import com.braango.client.braangomodel.BannersInput;
import com.braango.client.braangomodel.BannersInputBody;
import com.braango.client.braangomodel.BannersOutputBodyData;
import com.braango.client.braangomodel.RequestHeader;
import com.braango.client.braangomodel.BannersOutput;

/**
 * @author braango
 * 
 *    Sample code showing how to get banners for a personnel
 *
 */
public class GetBanners {

	static String basePath = "https://testapi2.braango.com/v2/braango";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		ApiClient braangoApiClient = new ApiClient();
		// TEST auth token. Please contact
		// sales@braango.com to have one
		// created for you
		String authToken = "ISNWF0P30WM0CMK";
		braangoApiClient.setBasePath(basePath);

		// Set the auth_token for api client to
		// interact with Braango system
		braangoApiClient.setApiKey(authToken);

		// Api key is authorization to to access
		// resources within braango system
		//
		// This key is different than auth_token
		// that is used to validate the master account

		String apiKey = "ISNfTMNOumV3xYNDd2g";

		// Create personnel api. Personnel is hosted by subDealer
		BannersApi bannerApi = new BannersApi(braangoApiClient);
		
		final Boolean typeAdfCrmEmail = false;

		ApiCallback<BannersOutput> callBack = new ApiCallback<BannersOutput>() {

			@Override
			public void onUploadProgress(long bytesWritten, 
					long contentLength,
					boolean done) {

				System.out
						.println("Place holder for tracking"
								+ " request progress");

			}

			@Override
			public void onSuccess(BannersOutput result, int statusCode,
					Map<String, List<String>> responseHeaders) {

				BannersOutputBodyData bannersList = result.getBody()
						.getData();
				
				List<String> dealerBanners = bannersList.getDealerBanners();
				List<String> clientBanners = bannersList.getClientBanners();
				List<String> supervisorBanners =
						                     bannersList.getSupervisorBanners();
				
				System.out.println("Dealer banners =  " + dealerBanners);
				System.out.println("Client banners =  " + clientBanners);
				System.out.println("Supervisor banners =  " + supervisorBanners);


			}

			@Override
			public void onFailure(ApiException e, int statusCode,
					Map<String, List<String>> responseHeaders) {
				System.out.println("Error is " + statusCode + " "
						+ e.getResponseBody());

			}

			@Override
			public void onDownloadProgress(long bytesRead, long contentLength,
					boolean done) {

			}
		};

	

		try {
			String subDealerId = "subdealers1002";
			String salesPersonId = "0550c168-6117-45d5-a95f-e66593e6336b";
			String accountType = "partner";
			String bannerType = "dealer" ; // "dealer", "client", "supervisor"
			bannerApi.getBannersAsync(subDealerId, salesPersonId,bannerType, apiKey,accountType, callBack);
		} catch (ApiException e1) {
			e1.printStackTrace();
		}
	}

}

Comments (0)