ethical-jobs / ethical-jobs-sdk
EthicalJobs API client
Installs: 1 162
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.0
- ethical-jobs/ethical-jobs-foundation: ~1.3
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.5.3
- hirak/prestissimo: ^0.3.7
- illuminate/support: ^5.4
- mockery/mockery: 1.0.*
- orchestra/testbench: ~3.4
- phpunit/phpunit: ~6.5
This package is auto-updated.
Last update: 2024-09-19 12:40:57 UTC
README
composer require ethical-jobs/ethical-jobs-sdk
For Laravel < 5.5.x
include the service provider and facade in you config/app.php
file EthicalJobs\SDK\Laravel\ServiceProvider::class
, 'EthicalJobs' => EthicalJobs\SDK\Laravel\ApiFacade::class,
. For Laravel >= 5.5.x
the package will auto-include the service provider and facade.
Authentication
You will need to set 4 environment variables to enable authentication:
{ "AUTH_CLIENT_ID": "The client id of the oauth grant", "AUTH_CLIENT_SECRET": "The client secret of the oauth grant", "AUTH_SERVICE_USERNAME": "Username or email of the user", "AUTH_SERVICE_PASSWORD": "Base64 encoded password of the user", }
Authentication is made using oauth2
and JWT tokens are returned and attached to headers as bearer tokens. The grant type is a password
grant and thus its attached to a user model and thus the users access rights and roles.
Making Requests
There are many ways to access api resources, following are some examples:
// GET /jobs EthicalJobs::get('/jobs', ['status' => 'APPROVED']); // GET /jobs/drafts EthicalJobs::get('/jobs/drafts', ['status' => 'APPROVED']); // GET /jobs/214 EthicalJobs::get('/jobs/214'); // GET /jobs { status: APPROVED, expired: false } EthicalJobs::resource('jobs')->approved(); // GET /jobs { expired: true } EthicalJobs::resource('jobs')->expired(); // POST /jobs { ... } EthicalJobs::post('/jobs', ['title' => 'React Developer', 'description' => 'We are looking for...']);
Responses
Responses are returned as Illuminate\Support\Collection
s if there are no results an empty collection is returned.
In the future the results will be returned from an extended EthicalJobs\SDK\Collection
class with helper functions to select results from our normalized api responses.
$collection->entities('jobs');