2017 © Pedro Peláez
 

library ethical-jobs-sdk

EthicalJobs API client

image

ethical-jobs/ethical-jobs-sdk

EthicalJobs API client

  • Friday, May 4, 2018
  • by andrewmclagan
  • Repository
  • 2 Watchers
  • 0 Stars
  • 591 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 34 Versions
  • 19 % Grown

The README.md

Installation

composer require ethical-jobs/ethical-jobs-sdk, (*1)

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., (*2)

Authentication

You will need to set 4 environment variables to enable authentication:, (*3)

{
    "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., (*4)

Making Requests

There are many ways to access api resources, following are some examples:, (*5)

// 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\Collections if there are no results an empty collection is returned., (*6)

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., (*7)

$collection->entities('jobs');, (*8)

The Versions