Skip to content

Commit

Permalink
add users
Browse files Browse the repository at this point in the history
  • Loading branch information
vt-parhomenko committed Nov 19, 2020
1 parent cb7bcf4 commit 2e44d5f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# olx-sdk
Olx.ua API SDK
#Olx REST API PHP SDK
## Installation via composer
```
composer require vt-parhomenko/olx-ua-api-sdk
```
## API Documentation
https://developer.olx.ua/api/doc

## How to use
```php
<?php

use Parhomenko\Olx\OlxFactory;

$olx = OlxFactory::get( "ua", [
"client_id"=> 'client_id',
"client_secret"=> 'client_secret',
'access_token' => 'access_token',
'refresh_token' => 'refresh_token',
'token_type' => 'token_type',
'scope' => 'scope'
]);

$advert_data = [
//advert data
];

// create new advert
$olx->adverts()->create( $advert_data );

```
9 changes: 9 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Parhomenko\Olx\Api\Regions;
use Parhomenko\Olx\Api\Cities;
use Parhomenko\Olx\Api\Currencies;
use Parhomenko\Olx\Api\Users;

class Api implements IOlxApi
{
Expand All @@ -20,6 +21,7 @@ class Api implements IOlxApi
private $cities = null;
private $regions = null;
private $currencies = null;
private $users = null;

public function __construct( string $base_uri, array $credentials, bool $update_token = false )
{
Expand Down Expand Up @@ -74,4 +76,11 @@ public function currencies()
return is_null($this->currencies ) ? new Currencies( $this->user, $this->guzzleClient ) : $this->currencies;
}

/**
* @return Users
*/
public function users(){
return is_null($this->users) ? new Users( $this->user, $this->guzzleClient ) : $this->users;
}

}
2 changes: 0 additions & 2 deletions src/Api/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ public function me() : array

if( !isset( $me_info['data'] ) ) throw new \Exception( 'Got empty response | Get authenticated user' );

//return $me_info['data'];
$me_info = $me_info['data'];

}
catch ( \Exception $e ){
//print_r($e);
throw $e;
}

Expand Down

0 comments on commit 2e44d5f

Please sign in to comment.