clj-base-crm is a simple client library for accessing the Base CRM API.
Please read through the Base CRM API Endpoint Reference.
Add the following to your project.clj dependencies:
[clj-base-crm "0.2.0"]
Require the clj-base-crm.core
in your namespace:
(require '[clj-base-crm.core :as base])
Setup your Base Personal Access Tokens (PAT) Don't have one? Read this.
(base/set-access-token! "YOUR_BASE_PAT_ACCESS_TOKEN")
clj-base-crm only supports the following resources:
::base/leads
::base/lead-sources
::base/contacts
::base/notes
To create a new lead, use the create
function.
(base/create ::base/leads
{:first_name "John" :last_name "Doe" :email "[email protected]"})
To retrieve a new lead by it's ID, use the retrieve
function.
(base/retrieve ::base/leads {:id 1234})
To update a lead by it's ID, use the update
function.
(base/update ::base/leads {:id 1234} {:email "[email protected]"})
To delete a lead by it's ID, use the delete
function.
(base/delete ::base/leads {:id 1234})
Sometimes you need to create a lead but you are not sure if this lead is already in the system. Base provides an upsert action which will create a new lead or update an existing lead based on the filters you pass in.
To upsert a lead by it's ID, use the upsert
function.
This will upsert based on the email filter [email protected]
.
(base/upsert ::base/leads
{:email "[email protected]"}
{:first_name "John" :last_name "Doe" :phone "916-456-7890"})
This will upsert based on the custom field filter external_id
123
.
(base/upsert ::base/leads
{:custom_fields {:external_id 123}}
{:first_name "John" :last_name "Doe" :phone "916-456-7890"})
clj-base-crm returns the data received from the Base CRM API unaltered but the response will be converted from json to a Clojure map.
##Error handling
clj-base-crm does not throw exceptions on exceptional status codes from the Base API. It returns the error body.
##Todo clj-base-crm only exposes a few resources. I plan to add more as I need them. If you would like to expose more (just a simple hash-map), feel free to submit a PR!
- Support more Base resources
- Tests
Copyright (c) 2016 Ryan Bertrand
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.