Skip to content

chloeandisabel/apprentice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apprentice

Apprentice is a collection of Elixir structs for the HireFire API useable by the Napper JSON REST API application.

Apprentice defines structs for all of the resources exposed by HireFire's API.

Installation

First, add Apprentice to your mix.exs dependencies:

def deps do
  [{:apprentice, git: "https://github.com/chloeandisabel/apprentice.git"}]
end

and run $ mix deps.get. Now, list the :apprentice application as your application dependency:

def applications do
  [applications: [:apprentice]]
end

Configuration

We need to tell Napper about HireFire's API.

config :napper,
  url: "https://api.hirefire.io",
  auth: "Token #{System.get_env("HIREFIRE_API_KEY")}",
  accept: "application/vnd.hirefire.v1+json",
  remove_wrapper: true

That last entry tells Napper to remove the outer wrapper from HireFire responses. When asking for a list of organizations, HireFire returns

{"organizations": [...]}

but Napper expects that innter array of objects. Setting remove_wrapper to true tells Napper to strip off the outer "organizations" object, returning only the array.

Using Apprentice

Let's try out Apprentice from within IEX.

$ iex -S mix

First we create a client using Napper. This example assumes we've used our config file to configure Napper properly.

iex> client = Napper.api_client

What organizations do we have?

iex> client |> Apprentice.HireFire.Organization.list
#=> [%Apprentice.HireFire.Organization{...}]

About

HireFire REST API modules for the Napper REST API client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages