Example #1
0
 /**
  * Uri constructor.
  * Overridden constructor to achieve every
  * request to the ZOHO should have Auth Token
  *
  * @param string $uri
  * @param ConfigurationInterface $configuration
  */
 public function __construct($uri = '', ConfigurationInterface $configuration)
 {
     if ($uri != null) {
         $parts = parse_url($uri);
         if ($parts === false || !array_key_exists('query', $parts)) {
             return parent::__construct($uri . '?authtoken=' . $configuration->getAuthToken());
         }
         return parent::__construct(str_replace($parts['query'], 'authtoken=' . $configuration->getAuthToken() . '&' . $parts['query'], $uri));
     }
 }
Example #2
0
 /**
  * @param string $collectionPath
  * @param string $collectionItemName
  * @param array $data
  *
  * @return array|null
  */
 public function create($collectionPath, $collectionItemName, array $data)
 {
     $uri = $this->factory->make(Uri::class, ['uri' => $this->configuration->getServiceUri() . $collectionPath]);
     $result = $this->transport->post($uri, $data);
     if (empty($result)) {
         return null;
     }
     if (empty($result->{$collectionItemName})) {
         throw new UnexpectedResponseException('Empty itemName ' . $collectionItemName . ' from ' . $collectionPath . ' after POST/create');
     }
     return (array) $result->{$collectionItemName};
 }