Giter Site home page Giter Site logo

active-campaign-simple's Introduction

active-campaign-simple

Simple Ruby REST wrapper for the Active Campaign API

This is a very simple wrapper around the REST ActiveCampaign API. You will still need to provide the path and the payload for each request. Eventually I will grow this out to be more convenient, if needed. Right now, this just provides some conveniences and an easy way to configure the API and not much more... hence the name active-campaign-simple :)

Use the public API as a guide for paths (urls) and payload info: https://developers.activecampaign.com/

gem install active-campaign-simple

  1. add gem 'active-campaign-simple' to your Gemfile
  2. Get your API URL and Key from within your application (Settings > Developer)
  3. Then create an initializer in config\initializers called active_campaign.rb and the following
# Added to your config\initializers file
ActiveCampaign.configure do |config|
  config.api_url = 'YOUR_API_URL'
  config.api_key = 'YOUR_API_KEY'
  config.api_logger = Logger.new("#{Rails.root}/log/active_campaign_api.log") # optional logger file
end
# Get a list of contacts
ActiveCampaign.get('/contacts')

# Get a contact
ActiveCampaign.get('/contacts/' + id)

# Create (post) a new contact
# https://developers.activecampaign.com/reference#create-a-contact-new
ActiveCampaign.post('/contacts', payload: {
  contact: {
    email: '[email protected]',
    firstName: 'Nate',
    lastName: 'Test',
    phone: '1231231234'
  },
  fieldValues: [
    {
      field: '1',
      value: 'The Value for First Field'
    }
  ]
})

# Update (put) a contact
ActiveCampaign.put('/contacts/' + id, payload: {
  contact: {
    email: '[email protected]'
  }
})

# Delete a contact
ActiveCampaign.delete('/contacts/' + id)

# Search for a contact
ActiveCampaign.get('/contacts', query: { email: '[email protected]' })

# Event Tracking
# See: https://developers.activecampaign.com/reference#track-event
# NOTE - The tracking API is different from all other calls as it changes the arguments a little to simplify.
ActiveCampaign.track_event('event-key', 'actid', 'event-name', 'email')

# or with optional eventdata
ActiveCampaign.track_event('event-key', 'actid', 'event-name', 'email', 'eventdata')

In the spirit of free software, everyone is encouraged to help improve this project.

See MIT LICENSE for details.

active-campaign-simple's People

Contributors

nateleavitt avatar

Stargazers

 avatar Francis Karuri avatar Serhii Ponomarov avatar

Watchers

 avatar James Cloos avatar

Forkers

cmaxw

active-campaign-simple's Issues

ArgumentError: wrong number of arguments (given 2, expected 1) when calling delete

When I try calling the delete method, it throws an ArgumentError, I'm not sure why:

ArgumentError: wrong number of arguments (given 2, expected 1)
from /Users/matteoguerrieri/Desktop/active-campaign-simple/lib/active-campaign-simple/request.rb:28:in `delete'

I'm following the example on the README.

I noticed that a fix could be adding payload: {} on the method, but not sure why it expects two arguments in lib/active-campaign-simple/request.rb:28

def delete(path, payload: {})
  request(:delete, path)
end

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.