This repository has been archived by the owner on May 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
7965510
commit b81d3f6
Showing
7 changed files
with
176 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 @@ | ||
/vendor/ |
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 @@ | ||
language: php | ||
|
||
php: | ||
- '5.5' | ||
- '5.6' | ||
- '7.0' | ||
|
||
before_script: | ||
- composer self-update | ||
|
||
install: | ||
- composer install --prefer-source --no-interaction --dev | ||
|
||
script: vendor/bin/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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# php-watson-api-bridge | ||
A PHP wrapper for IBM Watson API | ||
# PHP IBM Watson API Bridge | ||
|
||
A simple PHP wrapper for IBM Watson API |
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,29 @@ | ||
{ | ||
"name": "findbrok/php-watson-api-bridge", | ||
"description": "A simple PHP Wrapper around IBM Watson API", | ||
"keywords": ["php", "ibm", "watson", "api", "bridge"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Percy Mamedy", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5.0", | ||
"guzzlehttp/guzzle": "~5.3|~6.0|~6.2" | ||
}, | ||
"require-dev": { | ||
"fzaninotto/faker": "~1.4", | ||
"phpunit/phpunit": "~4.0", | ||
"mockery/mockery": "0.9.*" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"tests/TestCase.php" | ||
], | ||
"psr-4": { | ||
"FindBrok\\WatsonBridge\\" : "src/" | ||
} | ||
} | ||
} |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false"> | ||
<testsuites> | ||
<testsuite name="WatsonBridge"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</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,103 @@ | ||
<?php | ||
|
||
namespace FindBrok\WatsonBridge; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Request; | ||
|
||
/** | ||
* Class Bridge | ||
* | ||
* @package FindBrok\WatsonBridge | ||
*/ | ||
class Bridge | ||
{ | ||
/** | ||
* API Username | ||
* | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* API password | ||
* | ||
* @var string | ||
*/ | ||
protected $password; | ||
|
||
/** | ||
* API Endpoint for making request | ||
* | ||
* @var string | ||
*/ | ||
protected $endpoint; | ||
|
||
/** | ||
* Guzzle http client for performing API request | ||
* | ||
* @var \GuzzleHttp\Client | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* The request object | ||
* | ||
* @var \GuzzleHttp\Psr7\Request | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* Create a new instance of bridge | ||
* | ||
* @param string $username | ||
* @param string $password | ||
* @param string $endpoint | ||
*/ | ||
public function __construct($username = null, $password = null, $endpoint = null) | ||
{ | ||
//Set Username, Password and Endpoint | ||
$this->username = $username; | ||
$this->password = $password; | ||
$this->endpoint = $endpoint; | ||
//Set HttpClient | ||
$this->setClient(); | ||
} | ||
|
||
/** | ||
* Return the authorization for making request | ||
* | ||
* @return array | ||
*/ | ||
public function getAuth() | ||
{ | ||
//Return access authorization | ||
return [ | ||
'auth' => [$this->username, $this->password] | ||
]; | ||
} | ||
|
||
/** | ||
* Creates the http client | ||
* | ||
* @return void | ||
*/ | ||
private function setClient() | ||
{ | ||
//Create client using API endpoint | ||
$this->client = new Client([ | ||
'base_uri' => $this->endpoint, | ||
]); | ||
} | ||
|
||
/** | ||
* Return the Http client instance | ||
* | ||
* @return \GuzzleHttp\Client | ||
*/ | ||
public function getClient() | ||
{ | ||
//Return client | ||
return $this->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,9 @@ | ||
<?php | ||
|
||
/** | ||
* Class TestCase | ||
*/ | ||
class TestCase extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
} |