Skip to content

Commit

Permalink
Feature/adiciona novas features (#43)
Browse files Browse the repository at this point in the history
* Adiciona pasta de configuração do PHPStorm no .gitignore

* Adiciona  opção de passar VINDI_API_URI e VINDI_API_KEY como argumentos

Opção de passar VINDI_API_URI e VINDI_API_KEY como argumentos nas instancias de classes filhas de Resource

* Atualiza versão 1.1.0 na classe Vindi

* Volta o código original

* Retira .idea do gitignore

* Adiciona  opção de passar VINDI_API_URI e VINDI_API_KEY como argumentos

Opção de passar VINDI_API_URI e VINDI_API_KEY como argumentos nas instâncias de classes filhas de Resource
Refatora código da classe Vindi para melhor adequar as mudanças realizadas nessa feature

* Refatora README para melhor entendimento da nova feature

* Refatora CHANGELOG para melhor entendimento

* Altera idioma de uma frase no CHANGELOG

* Refatora para melhor entendimento do README

* Refatora ordem de importância de VINDI_API_KEY e VINDI_API_URI

* Adiciona exemplo de API URI

* Refatora teste da classe Vindi

* Altera ênfase na explicação sobre outra instancia

* Adiciona classe Notifications e testes

* Adiciona novos métodos

* Separa os meios de autenticação do README

* Retira menção sobre .env

* Adiciona docblock do PHP

* Ajusta teste da classe Vindi
  • Loading branch information
rtakauti authored May 28, 2018
1 parent 34ae45e commit 71ed9ba
Show file tree
Hide file tree
Showing 35 changed files with 380 additions and 25 deletions.
26 changes: 18 additions & 8 deletions src/ApiRequester.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
use Vindi\Exceptions\RequestException;
use Vindi\Exceptions\RateLimitException;

/**
* Class ApiRequester
*
* @package Vindi
*/
class ApiRequester
{
/**
Expand All @@ -17,7 +22,7 @@ class ApiRequester
public $client;

/**
* @var \Psr\Http\Message\ResponseInterface
* @var ResponseInterface
*/
public $lastResponse;

Expand All @@ -40,6 +45,9 @@ public function __construct()
* @param array $options Options for the request.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function request($method, $endpoint, array $options = [])
{
Expand All @@ -54,9 +62,11 @@ public function request($method, $endpoint, array $options = [])
}

/**
* @param \Psr\Http\Message\ResponseInterface $response
* @param ResponseInterface $response
*
* @return object
* @throws RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function response(ResponseInterface $response)
{
Expand All @@ -75,10 +85,10 @@ public function response(ResponseInterface $response)
}

/**
* @param \Psr\Http\Message\ResponseInterface $response
* @param ResponseInterface $response
*
* @return $this
* @throws \Vindi\Exceptions\RateLimitException
* @throws RateLimitException
*/
private function checkRateLimit(ResponseInterface $response)
{
Expand All @@ -90,8 +100,8 @@ private function checkRateLimit(ResponseInterface $response)
}

/**
* @param \Psr\Http\Message\ResponseInterface $response
* @param mixed $data
* @param ResponseInterface $response
* @param mixed $data
*
* @return $this
* @throws \Vindi\Exceptions\RequestException
Expand All @@ -100,9 +110,9 @@ private function checkForErrors(ResponseInterface $response, $data)
{
$status = $response->getStatusCode();

$data = (array) $data;
$data = (array)$data;

$statusClass = (int) ($status / 100);
$statusClass = (int)($status / 100);

if (($statusClass === 4) || ($statusClass === 5)) {
switch ($status) {
Expand Down
38 changes: 38 additions & 0 deletions src/Bill.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Bill
*
* @package Vindi
*/
class Bill extends Resource
{
/**
Expand All @@ -20,9 +25,42 @@ public function endpoint()
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function approve($id)
{
return $this->post($id, 'approve');
}

/**
* Make a POST request to bills/{id}/charge.
*
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function charge($id)
{
return $this->post($id, 'charge');
}

/**
* Make a POST request to bills/{id}/invoice.
*
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function invoice($id)
{
return $this->post($id, 'invoice');
}
}
5 changes: 5 additions & 0 deletions src/BillItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class BillItem
*
* @package Vindi
*/
class BillItem extends Resource
{
/**
Expand Down
31 changes: 30 additions & 1 deletion src/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Charge
*
* @package Vindi
*/
class Charge extends Resource
{
/**
Expand All @@ -21,6 +26,9 @@ public function endpoint()
* @param array $form_params
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function reissue($id, array $form_params = [])
{
Expand All @@ -34,6 +42,9 @@ public function reissue($id, array $form_params = [])
* @param array $form_params
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function charge($id, array $form_params = [])
{
Expand All @@ -43,12 +54,30 @@ public function charge($id, array $form_params = [])
/**
* Make a POST request to charges/{id}/refund.
*
* @param int $id The resource's id.
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function refund($id)
{
return $this->post($id, 'refund');
}

/**
* Make a POST request to charges/{id}/fraud_review.
*
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function fraudReview($id)
{
return $this->post($id, 'fraud_review');
}
}
20 changes: 20 additions & 0 deletions src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Customer
*
* @package Vindi
*/
class Customer extends Resource
{
/**
Expand All @@ -13,4 +18,19 @@ public function endpoint()
{
return 'customers';
}

/**
* Make a POST request to customers/{id}/unarchive.
*
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function unarchive($id)
{
return $this->post($id, 'unarchive');
}
}
5 changes: 5 additions & 0 deletions src/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Discount
*
* @package Vindi
*/
class Discount extends Resource
{
/**
Expand Down
7 changes: 6 additions & 1 deletion src/Exceptions/RateLimitException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

use Exception;

/**
* Class RateLimitException
*
* @package Vindi\Exceptions
*/
class RateLimitException extends Exception
{
/**
Expand Down Expand Up @@ -45,7 +50,7 @@ public function __construct($response)
* @param mixed $response API response.
* @param string $name Header name.
*
* @returns int
* @return int
*/
private function getHeaderValue($response, $name)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Exceptions/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

use Exception;

/**
* Class RequestException
*
* @package Vindi\Exceptions
*/
class RequestException extends Exception
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php namespace Vindi\Exceptions;

/**
* Class ValidationException
*
* @package Vindi\Exceptions
*/
class ValidationException extends RequestException
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Exceptions/WebhookHandleException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php namespace Vindi\Exceptions;

/**
* Class WebhookHandleException
*
* @package Vindi\Exceptions
*/
class WebhookHandleException extends \Exception
{
}
5 changes: 5 additions & 0 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use GuzzleHttp\Client as Guzzle;
use Vindi\Vindi;

/**
* Class Client
*
* @package Vindi\Http
*/
class Client extends Guzzle
{
/**
Expand Down
10 changes: 9 additions & 1 deletion src/ImportBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class ImportBatch
*
* @package Vindi
*/
class ImportBatch extends Resource
{
/**
Expand All @@ -16,9 +21,12 @@ public function endPoint()

/**
* @param string $filePath
* @param array $options
* @param array $options
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function import($filePath, array $options)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Invoice
*
* @package Vindi
*/
class Invoice extends Resource
{
/**
Expand All @@ -20,6 +25,9 @@ public function endpoint()
* @param int $id The resource's id.
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Vindi\Exceptions\RateLimitException
* @throws \Vindi\Exceptions\RequestException
*/
public function retry($id)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Issue
*
* @package Vindi
*/
class Issue extends Resource
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Merchant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Vindi;

/**
* Class Merchant
*
* @package Vindi
*/
class Merchant extends Resource
{
/**
Expand Down
Loading

0 comments on commit 71ed9ba

Please sign in to comment.