예제 #1
0
 /**
  * Executes a service listed on ServiceEnum class.
  *
  * @param  string $action
  * @param  array  $arguments
  *
  * @throws \LeroyMerlin\ExactTarget\Exception\ActionNotFoundException
  * @throws \LeroyMerlin\ExactTarget\Exception\RequestException
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function __call($action, $arguments)
 {
     $token = $this->getToken();
     $actionInfo = ServiceEnum::toEndpoint($action);
     $parameters = count($arguments) ? $arguments[0] : [];
     $data = isset($parameters['data']) ? $parameters['data'] : [];
     return $this->requestBuilder->request($this->urlBuilder->build($actionInfo['subdomain'], $actionInfo['action'], $actionInfo['service'], $parameters), $actionInfo['method'], ['json' => $data, 'headers' => ['Authorization' => 'Bearer ' . $token]]);
 }
예제 #2
0
 /**
  * 
  * @param type $method
  * @param type $arguments
  * @return \Brognara\GoogleAPIWrapper\GoogleAPIWrapperClass
  * @throws \Exception
  */
 function __call($method, $arguments)
 {
     $norm_method = strtoupper($method);
     if (ServiceEnum::isValidName($norm_method)) {
         $this->service = strtolower($norm_method);
         $this->base_url = 'https://www.googleapis.com/' . $this->service . '/v3/' . $arguments[0];
         return $this;
     }
     throw new \Exception("Service " . $norm_method . " not enbled or invalid");
 }
예제 #3
0
 /**
  * Retrieves a new token to API authentication
  *
  * @return string
  */
 public function request()
 {
     $requestInfo = ServiceEnum::toEndpoint('requestToken');
     $parameters = ['clientId' => $this->clientId, 'clientSecret' => $this->clientSecret];
     return $this->requestBuilder->request((new UrlBuilder())->build($requestInfo['subdomain'], $requestInfo['action'], $requestInfo['service']), $requestInfo['method'], ['json' => $parameters]);
 }