Name: drip-ruby
Owner: Code Climate
Description: A Ruby gem for interacting with Drip's REST API v2.0
Created: 2015-08-24 21:30:30.0
Updated: 2015-08-24 21:30:32.0
Pushed: 2015-08-24 21:34:18.0
Homepage: null
Size: 115
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Ruby toolkit for the Drip API.
Add this line to your application's Gemfile:
gem 'drip-ruby', require: 'drip'
And then execute:
$ bundle
Or install it yourself as:
$ gem install drip-ruby
For private integrations, you may use your personal API key (found
here) via the api_key
setting:
nt = Drip::Client.new do |c|
api_key = "YOUR_API_KEY"
account_id = "YOUR_ACCOUNT_ID"
For public integrations, pass in the user's OAuth token via the access_token
setting:
nt = Drip::Client.new do |c|
access_token = "YOUR_ACCESS_TOKEN"
account_id = "YOUR_ACCOUNT_ID"
You may also pass client options in an argument hash:
nt = Drip::Client.new(
cess_token: "YOUR_ACCESS_TOKEN"
count_id: "YOUR_ACCOUNT_ID"
Your account ID can be found here. Most API actions require an account ID, with the exception of methods like the “list accounts” endpoint.
Since the Drip client is a flat API client, most API actions are available as methods on the client object. The following methods are currently available:
| Action | Method |
| :————————- | :————————————————— |
| List accounts | #accounts
|
| List subscribers | #subscribers(options = {})
|
| Create/update a subscriber | #create_or_update_subscriber(email, options = {})
|
| Create/update a batch of subscribers | #create_or_update_subscribers(subscribers)
|
| Fetch a subscriber | #subscriber(id_or_email)
|
| Subscribe to a campaign | #subscribe(email, campaign_id, options = {})
|
| Unsubscribe | #unsubscribe(id_or_email, options = {})
|
| Apply a tag | #apply_tag(email, tag)
|
| Remove a tag | #remove_tag(email, tag)
|
| Track an event | #track_event(email, action, properties = {})
|
| Track a batch of events | #track_events(events)
|
Note: We do not have complete API coverage yet. If we are missing an API method that you need to use in your application, please file an issue and/or open a pull request. See the official REST API docs for a complete API reference.
Here are some common use cases for the API client.
Once you have an access token for a Drip user, you can fetch their accounts.
Initialize your client and pull down the user's accounts. To make further calls, set the account_id on your client to the account you want to access.
nt = Drip::Client.new do |c|
access_token = "YOUR_ACCESS_TOKEN"
= client.accounts
<Drip::Response ...>
unt_id = resp.accounts.first.id
"9999999"
nt.account_id = account_id
Subscribers can be looked up by their email address or by their Drip subscriber ID. Most of the time you will want to look up subscribers by their email address, unless you've already stored this ID in your database.
= client.subscriber("foo@example.com")
<Drip::Response ...>
.success?
true
criber = resp.subscribers.first
criber.email
"foo@example.com"
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)