-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from igorwanbarros/master
commit inicial
- Loading branch information
Showing
6 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor | ||
composer.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "softcomtecnologia/softsend-client", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Softcom", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"softcomtecnologia/softcom-api-php": "*", | ||
"guzzlehttp/guzzle": "5.*" | ||
}, | ||
"require-dev": { | ||
"fzaninotto/faker": "~1.4", | ||
"mockery/mockery": "0.9", | ||
"phpunit/phpunit": "~4.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Softcomtecnologia\\SoftsendClient\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "stable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Softcomtecnologia\SoftsendClient\Configs; | ||
|
||
class SoftsendConfigs | ||
{ | ||
const URL_DOMAIN = 'http://localhost/softcom/softcom-app-envios/public/softauth'; | ||
|
||
const URL_STORE_CLIENT = 'add-client'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Softcomtecnologia\SoftsendClient\Contracts; | ||
|
||
interface SupportInterface | ||
{ | ||
public function support(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Softcomtecnologia\SoftsendClient\Supports; | ||
|
||
use Softcomtecnologia\Api\Provider\SoftcomProvider; | ||
use Softcomtecnologia\SoftsendClient\Configs\SoftsendConfigs; | ||
use Softcomtecnologia\SoftsendClient\Contracts\SupportInterface; | ||
|
||
class StoreClient implements SupportInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $clientCnpj; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* @var SoftcomProvider | ||
*/ | ||
protected $provider; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $optionsProvider = [ | ||
'domain' => SoftsendConfigs::URL_DOMAIN, | ||
]; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $responseJson = true; | ||
|
||
|
||
/** | ||
* @param string $clientCnpj | ||
* @param string $name | ||
* @param array $optionsProvider | ||
*/ | ||
public function __construct($clientCnpj, $name, array $optionsProvider = []) | ||
{ | ||
$this->clientCnpj = $clientCnpj; | ||
$this->name = $name; | ||
|
||
if ($optionsProvider) { | ||
$this->optionsProvider = $optionsProvider; | ||
} | ||
|
||
$this->provider = new SoftcomProvider($this->optionsProvider); | ||
} | ||
|
||
|
||
public function support() | ||
{ | ||
$response = $this->provider->post( | ||
'', | ||
SoftsendConfigs::URL_STORE_CLIENT, | ||
['client_cnpj' => $this->clientCnpj, 'name' => $this->name] | ||
); | ||
|
||
return json_decode($response, $this->responseJson); | ||
} | ||
|
||
|
||
/** | ||
* @param $bool | ||
* | ||
* @return $this | ||
*/ | ||
public function responseJson($bool) | ||
{ | ||
$this->responseJson = !!$bool; | ||
|
||
return $this; | ||
} | ||
} |