Example #1
0
 /**
  * refundCreditCardCharge
  *
  * Try to refund a CreditCardCharge to a Customer's CreditCard
  *
  * @param \Tpaga\Model\CreditCardRefund $body - **id** It is the id of the `CreditCardCharge` thats going to be refunded. (required)
  * @return \Tpaga\Model\CreditCardCharge
  * @throws \Tpaga\ApiException on non-2xx response
  */
 public function refundCreditCardCharge($body)
 {
     // verify the required parameter 'body' is set
     if ($body === null) {
         throw new \InvalidArgumentException('Missing the required parameter $body when calling refundCreditCardCharge');
     }
     // parse inputs
     $resourcePath = "/refund/credit_card";
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     $method = "POST";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
     // body params
     $_tempBody = null;
     if (isset($body)) {
         $_tempBody = $body;
     }
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } else {
         if (count($formParams) > 0) {
             $httpBody = $formParams;
             // for HTTP post (form)
         }
     }
     $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword());
     // make the API Call
     try {
         list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams, '\\Tpaga\\Model\\CreditCardCharge');
         if (!$response) {
             return null;
         }
         return $this->apiClient->getSerializer()->deserialize($response, '\\Tpaga\\Model\\CreditCardCharge', $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 202:
                 $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Tpaga\\Model\\CreditCardCharge', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
             case 406:
                 $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Tpaga\\Model\\CreditCardCharge', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
             case 422:
                 $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Tpaga\\Model\\ApiError', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
     return null;
 }
Example #2
0
 /**
  * getDaviPlataChargeById
  *
  * Retrieve a DaviPlataCharge by ID
  *
  * @param string $id Identification of `DaviPlataCharge` that needs to be retrieved (required)
  * @return Tpaga\Model\DaviPlataCharge
  * @throws Tpaga\ApiException on non-2xx response
  */
 public function getDaviPlataChargeById($id)
 {
     // verify the required parameter 'id' is set
     if ($id === null) {
         throw new \InvalidArgumentException('Missing the required parameter $id when calling getDaviPlataChargeById');
     }
     // parse inputs
     $resourcePath = "/charge/daviplata/{id}";
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     $method = "GET";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
     // path params
     if ($id !== null) {
         $resourcePath = str_replace("{" . "id" . "}", $this->apiClient->getSerializer()->toPathValue($id), $resourcePath);
     }
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } else {
         if (count($formParams) > 0) {
             $httpBody = $formParams;
             // for HTTP post (form)
         }
     }
     $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword());
     // make the API Call
     try {
         list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams, 'Tpaga\\Model\\DaviPlataCharge');
         if (!$response) {
             return null;
         }
         return $this->apiClient->getSerializer()->deserialize($response, 'Tpaga\\Model\\DaviPlataCharge', $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'Tpaga\\Model\\DaviPlataCharge', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
     return null;
 }