/**
  * Initializes a new instance of the DataService class.
  *
  * @param ServiceContext $serviceContext IPP Service Context
  */
 public function __construct($serviceContext)
 {
     if (NULL == $serviceContext) {
         throw new ArgumentNullException('Resources.ServiceContextCannotBeNull');
     }
     if (!is_object($serviceContext)) {
         throw new InvalidParameterException('Wrong arg type passed - is not an object.');
     }
     //ServiceContextValidation(serviceContext);
     $this->serviceContext = $serviceContext;
     $this->responseSerializer = CoreHelper::GetSerializer($this->serviceContext, false);
     $this->restHandler = new SyncRestHandler($serviceContext);
     // Set the Service type to either QBO or QBD by calling a method.
     $this->serviceContext->UseDataServices();
 }
 /**
  * Initializes a new instance of the PlatformService class.
  *
  * @param ServiceContext IPP Service Context
  * @throws ArgumentException:  The exception that is thrown when one of the argument(s) provided to a method  is not valid.
  * @throws InvalidTokenException:  When invalid tokens are passed.
  * @throws ArgumentNullException:  When Service context parameter sent as null.
  */
 public function __construct($serviceContext)
 {
     if (NULL == $serviceContext) {
         throw new ArgumentNullException('Resources.ServiceContextCannotBeNull');
     }
     if (!is_object($serviceContext)) {
         throw new InvalidParameterException('Wrong arg type passed - is not an object.');
     }
     if (0 !== strcmp('ServiceContext', get_class($serviceContext))) {
         throw new InvalidParameterException('Wrong arg type passed - is not the correct class.');
     }
     $this->serviceContext = $serviceContext;
     $this->restRequestHandler = new SyncRestHandler($serviceContext);
     // Set the serviceContext IPP configuration to what IPP is accepting.
     $this->serviceContext->IppConfiguration->Message->Request->SerializationFormat = SerializationFormat::Xml;
     $this->serviceContext->IppConfiguration->Message->Request->CompressionFormat = CompressionFormat::None;
     $this->serviceContext->IppConfiguration->Message->Response->SerializationFormat = SerializationFormat::Xml;
     $this->serviceContext->IppConfiguration->Message->Response->CompressionFormat = CompressionFormat::None;
     // Set the service type to IPP by calling a method
     $this->serviceContext->UsePlatformServices();
     $this->serviceContext = $serviceContext;
     $this->restRequestHandler = new SyncRestHandler($serviceContext);
 }
示例#3
0
require_once '../config.php';
require_once PATH_SDK_ROOT . 'Core/ServiceContext.php';
require_once PATH_SDK_ROOT . 'DataService/DataService.php';
require_once PATH_SDK_ROOT . 'PlatformService/PlatformService.php';
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php';
//Specify QBO or QBD
$serviceType = IntuitServicesType::QBO;
// Get App Config
$realmId = ConfigurationManager::AppSettings('RealmID');
if (!$realmId) {
    exit("Please add realm to App.Config before running this sample.\n");
}
// Prep Service Context
$requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret'));
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
$serviceContext->IppConfiguration->Message->Response->SerializationFormat = SerializationFormat::Json;
$serviceContext->IppConfiguration->Message->Request->SerializationFormat = SerializationFormat::Json;
$serviceContext->IppConfiguration->BaseUrl->Qbo = ConfigurationManager::BaseURLSettings(strtolower(IntuitServicesType::QBO));
$serviceContext->baseserviceURL = $serviceContext->GetBaseURL();
if (!$serviceContext) {
    exit("Problem while initializing ServiceContext.\n");
}
// Prep Data Services
$dataService = new DataService($serviceContext);
if (!$dataService) {
    exit("Problem while initializing DataService.\n");
}
$result = $dataService->Add(createTransfer());
echo showMe($result);
print_r($result);