Exemple #1
0
 /**
  * @param IApiConnection     $connection
  * @param SecurityDefinition $definition
  *
  * @return IToken
  */
 public function getToken(IApiConnection $connection, SecurityDefinition $definition)
 {
     if ($definition->getType() !== 'oauth2') {
         throw new \InvalidArgumentException('The security definition provided is not a valid oAuth2 definition');
     }
     $params = [];
     $params['grant_type'] = $this->getGrantType();
     $params['api_user'] = $this->getApiUser();
     $params['api_key'] = $this->getApiSecret();
     $request = new ApiRequest();
     $request->setConnection($connection);
     $detail = new ApiRequestDetail();
     $detail->setMethod('POST');
     $detail->setUrl($definition->getTokenUrl());
     $detail->setPostFields($params);
     $request->setRequestDetail($detail);
     $connection->load($request);
     $tokenResponse = $request->getDecodedResponse();
     $token = new AccessToken();
     $token->setToken(Objects::property($tokenResponse, 'access_token'));
     $token->setType(Objects::property($tokenResponse, 'token_type', 'Bearer'));
     $token->setExpirySeconds(Objects::property($tokenResponse, 'expires_in'));
     $token->setExpiryTime(Objects::property($tokenResponse, 'expiry_time'));
     $token->setUserId(Objects::property($tokenResponse, 'uid'));
     $token->setSessionSecret(Objects::property($tokenResponse, 'session_secret'));
     return $token;
 }
 /**
  * @summary Remove a product from an order
  *
  * @return ApiRequest
  */
 public function delete()
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'orders/{orderFid}/products/{orderProductFid}')));
     $detail->setMethod('DELETE');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Disable auto charge on specific subscription
  *
  * @return ApiRequest
  */
 public function setDisableAutoCharge()
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'customers/{customerFid}/subscriptions/{subscriptionFid}/disableAutoCharge')));
     $detail->setMethod('PUT');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Retrieve pending pixels for this visitor
  *
  * This call will release pixels from the pending queue on read
  *
  * @return ApiRequest
  */
 public function pixels()
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'visitors/{visitorId}/pixels')));
     $detail->setMethod('GET');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Decrement an entity counter
  *
  * @param PropertyCounterPayload $payload
  *
  * @return ApiRequest
  */
 public function decrement(PropertyCounterPayload $payload)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'entities/{entityFid}/properties/counters/{propertyName}/decrement')));
     $detail->setBody(json_encode($payload));
     $detail->setMethod('PUT');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Trigger a new event
  *
  * @param TriggerActionPayload $payload
  *
  * @return ApiRequest
  */
 public function createEvent(TriggerActionPayload $payload)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'entities/{entityFid}/events')));
     $detail->setBody(json_encode($payload));
     $detail->setMethod('POST');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Update a card
  *
  * @param CardUpdatePayload $payload
  *
  * @return ApiRequest
  */
 public function update(CardUpdatePayload $payload)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'customers/{customerFid}/paymentMethods/cards/{cardFid}')));
     $detail->setBody(json_encode($payload));
     $detail->setMethod('PUT');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Unsubscribe an email address
  *
  * @param $brandFid
  *
  * @return ApiRequest
  */
 public function setUnsubscribe($brandFid = null)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'contacts/emails/{emailAddress}/unsubscribe')));
     $detail->addPostField('brandFid', $brandFid);
     $detail->setMethod('PUT');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Write a config item
  *
  * @param $itemName
  * @param $value
  *
  * @return ApiRequest
  */
 public function create($itemName, $value)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'entities/{entityFid}/config/{sectionName}')));
     $detail->addPostField('itemName', $itemName);
     $detail->addPostField('value', $value);
     $detail->setMethod('POST');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Unsubscribe an email based on the delivery fid
  *
  * @param $userAgent
  * @param $encoding
  * @param $language
  * @param $clientIp
  *
  * @return ApiRequest
  */
 public function setUnsubscribe($userAgent = null, $encoding = null, $language = null, $clientIp = null)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'messenger/deliveries/{deliveryFid}/unsubscribe')));
     $detail->addPostField('userAgent', $userAgent);
     $detail->addPostField('encoding', $encoding);
     $detail->addPostField('language', $language);
     $detail->addPostField('clientIp', $clientIp);
     $detail->setMethod('PUT');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Add an offer to an order
  *
  * @param $offerFid
  * @param $productFid
  * @param $orderItemFid
  * @param $replace
  *
  * @return ApiRequest
  */
 public function create($offerFid, $productFid = null, $orderItemFid = null, $replace = null)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'orders/{orderFid}/offers')));
     $detail->addPostField('offerFid', $offerFid);
     $detail->addPostField('productFid', $productFid);
     $detail->addPostField('orderItemFid', $orderItemFid);
     $detail->addPostField('replace', $replace);
     $detail->setMethod('POST');
     $request->setRequestDetail($detail);
     return $request;
 }
Exemple #12
0
 /**
  * @summary Your Brand
  *
  * Retrieve a list of all the brands within your Fortifi account
  *
  * @return ApiRequest
  */
 public function brands()
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl('brands'));
     $detail->setMethod('GET');
     $request->setRequestDetail($detail);
     return $request;
 }
 /**
  * @summary Add a phone number to a customer
  *
  * @param $phoneNumber
  * @param $displayName
  *
  * @return ApiRequest
  */
 public function createPhone($phoneNumber, $displayName = null)
 {
     $request = new ApiRequest();
     $request->setConnection($this->_getConnection());
     $request->setEndpoint($this);
     $detail = new ApiRequestDetail();
     $detail->setRequireAuth(true);
     $detail->setUrl($this->_buildUrl(str_replace(array_keys($this->_replacements), array_values($this->_replacements), 'customers/{customerFid}/phones')));
     $detail->addPostField('phoneNumber', $phoneNumber);
     $detail->addPostField('displayName', $displayName);
     $detail->setMethod('POST');
     $request->setRequestDetail($detail);
     return $request;
 }