Skip to content

Commit

Permalink
Added improvement to classes returned data
Browse files Browse the repository at this point in the history
  • Loading branch information
Huberson D committed Feb 11, 2021
1 parent 0fdb9df commit d7b04f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
16 changes: 8 additions & 8 deletions src/Daxko.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@

class Daxko
{
protected string $baseURL = 'https://api.partners.daxko.com/api/';
protected string $apiVersion = 'v1';
const BASE_URL = 'https://api.partners.daxko.com';
const API_VERSION = '/api/v1';


/**
* An HTTPClient to query Daxko's API
*/
protected Client $client;


public function __construct(string $accessToken, array $options = [])
public function __construct(string $accessToken)
{
$clientConfig = [
// 'base_uri' => $options['base_uri'] ?? $this->baseURL.$this->apiVersion,
'base_uri' => 'https://api.partners.daxko.com',
'base_uri' => self::BASE_URL,
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer '.$accessToken,
'Authorization' => 'Bearer ' . $accessToken,
]
];

Expand All @@ -51,7 +51,7 @@ public static function getToken(string $clientId, string $clientSecret, string $
{
try {
$response = (new Client())
->post('https://api.partners.daxko.com/auth/token', [
->post(self::BASE_URL . '/auth/token', [
'headers' => [ 'Content-Type' => 'application/json' ],
'json' => [
'client_id' => $clientId,
Expand Down Expand Up @@ -82,7 +82,7 @@ public static function refreshToken(string $clientId, string $refreshToken)
{
try {
$response = (new Client())
->post('https://api.partners.daxko.com/auth/token', [
->post(self::BASE_URL . '/auth/token', [
'headers' => [ 'Content-Type' => 'application/json' ],
'json' => [
'client_id' => $clientId,
Expand Down
18 changes: 9 additions & 9 deletions src/Entities/DaxkoClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace ForwardForce\Daxko\Entities;

use ForwardForce\Daxko\Client;
use ForwardForce\Daxko\Contracts\ApiAwareContract;
use ForwardForce\Daxko\Response;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Message;
Expand Down Expand Up @@ -198,13 +196,15 @@ public function all(array $params =[]): array
$classes = [];
$apiClasses = $this->responseToArray();

// foreach ($apiClasses as $class) {
// $instance = new static($this->client);
// $instance->response->withBody(new Message());
// $instance->setProperties();
// $classes[] = $instance;
// }
$classes = $apiClasses;
foreach ($apiClasses as $class) {
// $instance = new static($this->client);
// $instance->response->withBody(new Message());
// $instance->setProperties();
// $classes[] = $instance;

$classes[] = $class['brief'];
}
// $classes = $apiClasses;
} catch (RequestException $e) {
$error['request'] = Message::toString($e->getRequest());

Expand Down
2 changes: 0 additions & 2 deletions src/Entities/DaxkoUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace ForwardForce\Daxko\Entities;

use ForwardForce\Daxko\Client;
use ForwardForce\Daxko\Contracts\ApiAwareContract;
use ForwardForce\Daxko\Response;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Message;
Expand Down

0 comments on commit d7b04f2

Please sign in to comment.