Skip to content

Commit

Permalink
Merge pull request #1 from igorwanbarros/master
Browse files Browse the repository at this point in the history
commit inicial
  • Loading branch information
Igor Wanderley Barros authored Nov 2, 2017
2 parents b7e807e + 3ea6bf9 commit 26ba945
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
2 changes: 0 additions & 2 deletions .gitignore/.gitignore

This file was deleted.

26 changes: 26 additions & 0 deletions composer.json
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"
}
10 changes: 10 additions & 0 deletions src/Configs/SoftsendConfigs.php
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';
}
8 changes: 8 additions & 0 deletions src/Contracts/SupportInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Softcomtecnologia\SoftsendClient\Contracts;

interface SupportInterface
{
public function support();
}
80 changes: 80 additions & 0 deletions src/Supports/StoreClient.php
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;
}
}

0 comments on commit 26ba945

Please sign in to comment.