Skip to content

Commit

Permalink
Merge pull request #10 from taciobrito/master
Browse files Browse the repository at this point in the history
Fixes and changes
  • Loading branch information
adhenrique authored Jan 7, 2021
2 parents 774d5a8 + ac4227c commit 6066267
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ class HomeController extends Controller{
'description' => 'Venda de teste, somente!',
'statement_descriptor' => 'Descrição de testes',
'on_behalf_of' => 'bb2a51f1c22a4c30b6bf6819be87ac52',
'installment_plan[mode]' => 'interest_free',
'installment_plan[number_installments]' => '1',
'customer' => 'bb2a51f1c22a4c30b6bf6819be87ac52', //buyer ud
'installment_plan' => [
'mode' => 'interest_free',
'number_installments' => '1'
],
'customer' => 'bb2a51f1c22a4c30b6bf6819be87ac52', //buyer id
]);

dd($cnp);
Expand Down
15 changes: 15 additions & 0 deletions src/Contracts/ZoopBuyers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public function __construct(APIResource $APIResource);
*/
public function create($post);

/**
* Update a created Buyer
*
* @param $buyerID string
* @param $post array
*/
public function update($buyerID, $post);

/**
* Delete a Buyer by id
*
Expand All @@ -34,6 +42,13 @@ public function delete($buyerID);
*/
public function get($buyerID);

/**
* Retrieve the details of a Buyer by taxpayer_id
*
* @param $taxpayerID string
*/
public function getByTaxpayerId($taxpayerID);

/**
* Returns a JSON object with a list of buyers accounts.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/ZoopSubscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(APIResource $APIResource);
*/
public function create($post);

/**
/**
* Update a created Subscription
*
* @param $subscriptionID string
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ZoopException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

namespace Zoop\src\Exceptions;
namespace Zoop\Exceptions;

class ZoopException extends \Exception {}
4 changes: 2 additions & 2 deletions src/Lib/APIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ private function requestWithCURL($method, $url, $headers, $data = Array()){

if (strtolower($method) == "post") {
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = http_build_query($data);
$opts[CURLOPT_POSTFIELDS] = json_encode($data);
}

if (strtolower($method) == "delete") $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';

if (strtolower($method) == "put") {
$opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
$opts[CURLOPT_POSTFIELDS] = http_build_query($data);
$opts[CURLOPT_POSTFIELDS] = json_encode($data);
}

$opts[CURLOPT_URL] = $url;
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/APIResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function fileAPI($api, $files){

if(!is_file($files)) throw new ZoopException('Looks like this is not a file...');

if(!in_array(mime_content_type($files), $mimeTypes)) throw new ZoopException('You can only send files of types "jpg, png, pdf"!');
if(!in_array($files->getClientMimeType(), $mimeTypes)) throw new ZoopException('You can only send files of types "jpg, png, pdf"!');

return $this->APIRequest->request('FILE', $url, $this->zoopBase->getHeaders(), [
'file' => new \CURLFile($files ,'' , uniqid()),
Expand Down
19 changes: 19 additions & 0 deletions src/Lib/ZoopBuyers.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public function create($post = []){
return $this->APIResource->createAPI($api, $post);
}

/**
* @param string $buyerID
* @param array $post
* @return mixed
*/
public function update($buyerID, $post){
$api = 'buyers/' . $buyerID;
return $this->APIResource->updateAPI($api, $post);
}

/**
* @param string $buyerID
* @return mixed
Expand All @@ -47,6 +57,15 @@ public function get($buyerID){
return $this->APIResource->searchAPI($api);
}

/**
* @param string $taxpayerID
* @return mixed
*/
public function getByTaxpayerId($taxpayerID){
$api = 'buyers/search?taxpayer_id='.$taxpayerID;
return $this->APIResource->searchAPI($api);
}

/**
* @return mixed
*/
Expand Down

0 comments on commit 6066267

Please sign in to comment.