Giter Club home page Giter Club logo

orthrus's Introduction

Orthrus

Orthrus is a simple opinionated implementation of ESI for Laravel that provides an easy to use interface for all ESI endpoints, delivering original JSON responses in easily accessible Eloquent collections.

Installing Orthrus

Require Orthrus via Composer

Simply require Orthrus through Composer to pull the package into your project.

composer require michaelcooke/orthrus

Configure Eseye

Orthrus depends on Eseye to take care of caching, logging, and making ESI requests that Orthrus builds up. Configuring Eseye may be done through your .env configuration file, making switching between ESI application details as well as caching and logging mechanisms between production and development environments easy.

Include the following in your .env configuration file and add your ESI application client id and key. In addition, you may specify a refresh token to use for all Orthrus ESI calls by default.

ESEYE_CLIENT_ID=
ESEYE_SECRET_KEY=
ESEYE_REFRESH_TOKEN=
ESEYE_DATASOURCE=tranquility
ESEYE_CACHE=

ESEYE_DATASOURCE may be tranquility or singularity. ESEYE_CACHE may be file, redis or memcached, and will attempt to use default configuration options where applicable.

Using Orthrus

Accessing ESI endpoints through Orthrus is easily done with a natural syntax while adhering closely to the verbage of the ESI spec. An easy-to-use ESI facade is also provided, making ESI calls dead-simple.

Making ESI Calls

Orthrus's syntax is straight-forward and adheres closely to the verbage and conventions of the ESI spec.

ESI::character($characterId)->get();      // GET /character/{$characterId}/
ESI::character($characterId)->portrait(); // GET /character/{$characterId}/portrait/

In some cases, aliases are provided to reflect more common verbage that may differ from the ESI spec.

ESI::character($characterId)->corporationHistory(); // GET /character/{$characterId}/corporation_history/
ESI::character($characterId)->employmentHistory();  // GET /character/{$characterId}/corporation_history/

ESI::character($characterId)->agentsResearch();     // GET /character/{$characterId}/agents_research/
ESI::character($characterId)->researchAgents();     // GET /character/{$characterId}/agents_research/

Accessing the Response

Every ESI call made through Orthrus will return an object decoded from the original JSON response.

ESI::character(94087852)->get()->name; // Michael Mach

Helper Methods

Set ESI Route Version

By default, Orthrus will use the /latest/ version route for all ESI calls. You may override this for an ESI call.

ESI::version('v1')->character($characterId)->get();

Set/Override Default Refresh Token

You may set or override the default refresh token for all ESI calls made through Orthrus for a request lifecycle.

ESI::setRefreshToken($token);

Reset Default Refresh Token

If you wish to set the default refresh token for all ESI calls made through Orthrus after changing it with setRefreshToken(), you may reset it to the default defined in your .env configuration file.

ESI::resetRefreshToken();

Using Alternative Refresh Token For One ESI Call

You may use an alternative refresh token for a single ESI call through Orthrus.

This is particularly useful for endpoints which require the call to be made from a refresh token belonging to a character with a particular role or level of access in a corporation, and you don't want to set and reset the refresh token used by Orthrus manually.

ESI::corporation($corporationId)->roles()->withRefreshToken($token);

Accessing Ancillary Response Information

It can be useful in some situations to be able to evaluate the response code, expiration, and potential error message from a response. To do so, you may use the following methods below.

ESI::responseCode();
ESI::responseExpires();
ESI::responseErrorMessage();

orthrus's People

Contributors

michaelcooke avatar ortholoess avatar rmatulis avatar

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.