Skip to content

Commit

Permalink
Basic Evidencio API communication class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dansuf committed Mar 23, 2018
1 parent 3ecd597 commit 4faed2f
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

EVIDENCIO_KEY=
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A more detailed description is available in the Requirements Document under the

Follow the instructions in the [Laravel documentation](https://laravel.com/docs/5.6/installation) to install required dependencies and the Laravel package itself.

Clone the repository and create your own `.env` file by copying `.env.example` and providing necessary data. Then run these commands inside the repository:
Clone the repository and create your own `.env` file by copying `.env.example` and providing necessary data. Please provide Evidencio API key here as well. Then run these commands inside the repository:

composer install
php artisan key:generate
Expand All @@ -25,15 +25,15 @@ Run the following command:
### Troubleshooting


#### NOTE: in Windows, this server will run from a command prompt.
#### NOTE: in Windows, this server will run from a command prompt.
If you are using Apache through XAMPP (**maybe** even without XAMPP), you can change the following file:

XAMPP\apache\conf\httpd.conf
(If not through XAMPP, then in the respective apache directory)
(If not through XAMPP, then in the respective apache directory)
Under the DocumentRoot setting in the file, you need to change the line:

C:\xampp\htdocs

into:

yourDirectory\2018-Evidencio\public
Expand Down
50 changes: 50 additions & 0 deletions app/EvidencioAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App;

class EvidencioAPI
{
public static function fetch($path, $params = [])
{
$client = new \GuzzleHttp\Client(['base_uri' => 'https://www.evidencio.com/api/']);
$res = $client->post($path,
[
'headers' => [
'Accept' => 'application/json',
'Authorization' => config('app.evidencio_key')
],
'form_params' => $params
]);
return json_decode($res->getBody());
}

public static function overview()
{
return self::fetch("overview");
}

public static function search($query)
{
return self::fetch("search",["query" => $query]);
}

public static function models()
{
return self::fetch("models");
}

public static function getModel($id)
{
return self::fetch("model",["id" => "1222"]);
}

/*
* @param $values array of key-value pairs for each variable where id is the key
*/
public static function run($id,$values)
{
$values["id"] = $id;
return self::fetch("run",$values);
}

}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0"
},
Expand Down
235 changes: 233 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@

'cipher' => 'AES-256-CBC',

/*
|--------------------------------------------------------------------------
| Evidencio API key
|--------------------------------------------------------------------------
*/

'evidencio_key' => env('EVIDENCIO_KEY'),

/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
Expand Down

0 comments on commit 4faed2f

Please sign in to comment.