Closex ✨

CircleCICoverage StatusPackage VersionDocumentation

Elixir wrapper for the Close.io API with optional caching support.

📔 Learn more about the Close.io API: http://developer.close.io

📖 Documentation for this package is available on HexDocs.

Installation

Add closex to your list of dependencies in mix.exs:

def deps do
  [
    {:closex, "~> 0.2.0"}
  ]
end

Configuration

In your config.exs:

config :closex,
  api_key: "YOUR_API_KEY"

You can also read from an environment variable:

config :closex,
  api_key: {:system, "MY_ENV_VAR"}

Usage

The client is essentially a wrapper around the Close.IO REST API.

It follows the Close.IO API naming conventions as closely as possible. It supports almost everything that the REST API supports including querying leads, opportunities, users, organizations, statuses and more.

Example usage:

# Get a lead
Closex.HTTPClient.get_lead("my_lead_id")
{:ok, %{"id" => "my_lead_id", "status_id" => "my_status_id", ...}}

# Update a lead
Closex.HTTPClient.update_lead("my_lead_id", %{status_id: "new_status_id"})
{:ok, %{"id" => "my_lead_id", "status_id" => "new_status_id", ...}}

# With caching
:timer.tc fn -> Closex.CachingClient.get_opportunity_statuses end
{907682, {:loaded, {:ok, %{"data" => [% ...lots of data... ]}}}}
# 900ms response time
:timer.tc fn -> Closex.CachingClient.get_opportunity_statuses end
{17, {:loaded, {:ok, %{"data" => [% ...lots of data... ]}}}}
# 17us response time with caching

# many more ...

See the docs for more examples.

Options

Options will be passed through to HTTPoison. For example, to set a shorter timeout:

Closex.HTTPClient.get_lead("my_lead_id", timeout: 500, recv_timeout: 1_000)

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

License

MIT

Copyright

Copyright NextDayProperty Ltd (see LICENSE for details)