Skip to content

Commit

Permalink
Construct, get_product
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardo-lewis committed Sep 15, 2017
1 parent ccaa1a0 commit 06b6421
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Multivendor/MultivendorAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,24 @@ class MultivendorAPI {
* @param string $secret
* @param array|null $options
*/
public function __construct( $key='', $secret='', $options = [] ) {
$this->key = $key;
$this->secret = $secret;
public function __construct( $accessToken='', $options = [] ) {
$this->token = $accessToken;
$this->options = $options;
$this->options['auth'] = array( $this->get_key(), $this->get_secret() );
$this->Client = new Client([
'auth' => [$this->get_key(), $this->get_secret()] ,
'auth' => ['Authorize', 'Bearer ' . $this->get_token()] ,
'headers' => ['Accept' => 'application/json']
]);
}

/**
* Retrieve API Access Token
*
* @return string
*/
public function get_token() {
return $this->token;
}
/**
* Retrieve API Key
*
Expand Down Expand Up @@ -126,7 +133,7 @@ public function get_products( $per_page = 10, $page = 1 ) {
public function get_product( $product_id = 0 ) {
$headers = [ 'Accept' => 'application/json' ];
//$response = Requests::get( $this->products_endpoint .'/' . $product_id, $headers, $this->options );
$response = $this->Client->request('GET', $this->products_endpoint .'/' . $product_id );
$response = $this->Client->request('GET', $this->api_endpoint .'/id/' . $product_id . '.json');

//print_r($response);

Expand Down

0 comments on commit 06b6421

Please sign in to comment.