This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5b62d3a
Showing
17 changed files
with
590 additions
and
0 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,4 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store |
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,34 @@ | ||
## Laravel HostFact | ||
### Installation | ||
Install this package with composer: | ||
``` | ||
composer require nickurt/laravel-hostfact:1.* | ||
``` | ||
|
||
Add the provider to config/app.php file | ||
|
||
```php | ||
'nickurt\HostFact\ServiceProvider', | ||
``` | ||
|
||
and the facade in the file | ||
|
||
```php | ||
'HostFact' => 'nickurt\HostFact\Facade', | ||
``` | ||
|
||
Copy the config files for the HostFact-plugin | ||
|
||
``` | ||
php artisan vendor:publish --provider="nickurt\HostFact\ServiceProvider" --tag="config" | ||
``` | ||
Add the HostFact credentials to your .env file | ||
``` | ||
HOSTFACT_DEFAULT_URL= | ||
HOSTFACT_DEFAULT_KEY= | ||
``` | ||
### Tests | ||
```sh | ||
phpunit | ||
``` | ||
- - - |
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,32 @@ | ||
{ | ||
"name": "nickurt/laravel-hostfact", | ||
"description": "HostFact for Laravel 5", | ||
"keywords": ["hostfact", "laravel"], | ||
"license": "MIT", | ||
"require": { | ||
"php": "^7.0", | ||
"laravel/framework": "~5.5.0|~5.6.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit" : "^6.2|^7.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"nickurt\\HostFact\\": "src/" | ||
}, | ||
"files": [ | ||
"src/helpers.php" | ||
] | ||
}, | ||
"minimum-stability": "dev", | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"nickurt\\HostFact\\ServiceProvider" | ||
], | ||
"aliases": { | ||
"HostFact": "nickurt\\HostFact\\Facade" | ||
} | ||
} | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'default' => env('HOSTFACT_CONNECTION', 'default'), | ||
|
||
'panels' => [ | ||
|
||
'default' => [ | ||
'url' => env('HOSTFACT_DEFAULT_URL'), | ||
'key' => env('HOSTFACT_DEFAULT_KEY'), | ||
], | ||
|
||
], | ||
|
||
]; |
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Laravel HostFact Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,34 @@ | ||
<?php | ||
|
||
namespace nickurt\HostFact\Api; | ||
|
||
use nickurt\HostFact\Client; | ||
|
||
abstract class AbstractApi implements ApiInterface | ||
{ | ||
/** | ||
* @var Client | ||
*/ | ||
public $client; | ||
|
||
/** | ||
* AbstractApi constructor. | ||
* @param Client $client | ||
*/ | ||
public function __construct(Client $client) | ||
{ | ||
$this->client = $client; | ||
} | ||
|
||
/** | ||
* @param $parameters | ||
* @return mixed | ||
* @throws \GuzzleHttp\Exception\GuzzleException | ||
*/ | ||
protected function post($parameters) | ||
{ | ||
return $this->client->getHttpClient()->post(array_merge([ | ||
'api_key' => $this->client->getHttpClient()->getOptions()['key'] | ||
], $parameters)); | ||
} | ||
} |
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 nickurt\HostFact\Api; | ||
|
||
interface ApiInterface | ||
{ | ||
|
||
} |
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,66 @@ | ||
<?php | ||
|
||
namespace nickurt\HostFact\Api; | ||
|
||
class Debtors extends AbstractApi | ||
{ | ||
public function add($params) | ||
{ | ||
// | ||
} | ||
|
||
public function attachmentAdd($params) | ||
{ | ||
// | ||
} | ||
|
||
public function attachmentDelete($params) | ||
{ | ||
// | ||
} | ||
|
||
public function attachmentDownload($params) | ||
{ | ||
// | ||
} | ||
|
||
public function checkLogin($params) | ||
{ | ||
// | ||
} | ||
|
||
public function edit($params) | ||
{ | ||
// | ||
} | ||
|
||
public function generatePdf($params) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* @param $params | ||
* @return mixed | ||
* @throws \GuzzleHttp\Exception\GuzzleException | ||
*/ | ||
public function list($params) | ||
{ | ||
return $this->post(array_merge(['controller' => 'debtor', 'action' => 'list'], $params)); | ||
} | ||
|
||
public function sendEmail($params) | ||
{ | ||
// | ||
} | ||
|
||
public function show($params) | ||
{ | ||
// | ||
} | ||
|
||
public function updateLoginCredentials($params) | ||
{ | ||
// | ||
} | ||
} |
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,84 @@ | ||
<?php | ||
|
||
namespace nickurt\HostFact; | ||
|
||
use \nickurt\HostFact\HttpClient\HttpClient; | ||
|
||
class Client | ||
{ | ||
/** | ||
* @var | ||
*/ | ||
protected $httpClient; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $classes = [ | ||
'debtors' => 'Debtors' | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $options = []; | ||
|
||
/** | ||
* @param $method | ||
* @param $args | ||
* @return mixed | ||
*/ | ||
public function __call($method, $args) | ||
{ | ||
try { | ||
return $this->api($method); | ||
} catch (InvalidArgumentException $e) { | ||
throw new \BadMethodCallException(sprintf('Undefined method called:"%s"', $method)); | ||
} | ||
} | ||
|
||
/** | ||
* @param $name | ||
* @return mixed | ||
*/ | ||
public function api($name) | ||
{ | ||
if (!isset($this->classes[$name])) { | ||
throw new \InvalidArgumentException(sprintf('Undefined method called:"%s"', $name)); | ||
} | ||
|
||
$class = '\\nickurt\\HostFact\\Api\\' . $this->classes[$name]; | ||
|
||
return new $class($this); | ||
} | ||
|
||
/** | ||
* @return HttpClient | ||
*/ | ||
public function getHttpClient() | ||
{ | ||
if (!isset($this->httpClient)) { | ||
$this->httpClient = new HttpClient(); | ||
} | ||
|
||
$this->httpClient->setOptions($this->getOptions()); | ||
|
||
return $this->httpClient; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getOptions() | ||
{ | ||
return $this->options; | ||
} | ||
|
||
/** | ||
* @param $options | ||
*/ | ||
public function setOptions($options) | ||
{ | ||
$this->options = $options; | ||
} | ||
} |
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 nickurt\HostFact; | ||
|
||
interface ClientInterface | ||
{ | ||
|
||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace nickurt\HostFact; | ||
|
||
class Facade extends \Illuminate\Support\Facades\Facade | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'HostFact'; | ||
} | ||
} |
Oops, something went wrong.