Code Monkey home page Code Monkey logo

ethical-jobs-sdk-php's Introduction

Installation

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\Collections 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');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.