#include <iostream>
#include <string>
#include <curl/curl.h>

#include "HWOcrClientToken.h"	// Token��֤
#include "HWOcrClientAKSK.h"	// AK/SK��֤

#define MAX_SIZE 100

void tokenRequest();
void akskRequest();

int main()
{
	// Token auth for ocr service
	tokenRequest();

	// aksk auth for ocr service
	akskRequest();

	system("pause");
	return 0;
}

void tokenRequest() {
	// Token for request type
	std::string username = "xxx";
	std::string password = "xxx";
	std::string domainname = "xxx"; //if the user isn't iam user, domain_name is the same with username
	std::string region = "ap-southeast-1";   //cn - north - 1, cn - east - 2 etc.
	std::string httpUri = "/v1.0/ocr/passport";
	std::string imgPath = "./data/passport-demo.jpg"; //the file path of the image or url of image to be recognized

	HWOcrClientToken ocrclient;
	ocrclient.init(domainname, username, password, region);
	Json::Value jsonOption;
	std::string strRespData1 = ocrclient.ocr_post(imgPath, httpUri, jsonOption);
	std::cout << strRespData1 << std::endl;
}

void akskRequest() {
	// AK/SK for request type
	std::string strak = "xxx"; //ak from authentication
	std::string strsk = "xxx"; //sk from authentication
	std::string region = "ap-southeast-1"; //the region selection
	std::string struri = "/v1.0/ocr/passport"; //the uri for the http request to be called
	std::string imgPath = "./data/passport-demo.jpg"; //the file path of the image or url of image to be recognized

	HWOcrClientAKSK client_aksk;
	client_aksk.init(strak, strsk, struri, region); //initialize ocr_client from //ak,sk,uri,region and endpoint information
	std::string strrespdata2 = client_aksk.request_ocr_service_base64(struri, imgPath);
	std::cout << strrespdata2 << std::endl;
}
