Acw

This is a very simple wrapper of the Active Campaign Api.

Installation

Add this line to your application's Gemfile:

gem 'acw'

And then execute:

$ bundle

Or install it yourself as:

$ gem install acw

Usage

Initialize client

client = Acw::Client.new({
    url:   'your-url',
    token: 'your-token'
})

Connection details

client.connection

Create contact - Api Reference

client.create_contact({
    email:     '[email protected]',
    firstName: 'first',
    lastName:  'last',
    phone:     '12312312'
})

Sync contact (Create or Update) - Api Reference

client.sync_contact({
  contact: {
    email:     '[email protected]',
    firstName: 'first',
    lastName:  'last',
    phone:     '12312312',
    fieldValues: [
      {
        field: '1',
        value: 'My Value'
      },
      {
        field: '2',
        value: 'My second value'
      }
    ]   
  }
})

Retrieve contact - Api Reference

client.retrieve_contact("contact_id")

Retrieve contact by email

This will return an array of contacts.

client.retrieve_contact_by_email("email")

Retrieve lists - Api Reference

client.retrieve_lists

Create tag - Api Reference

client.create_tag({ 
    tag: "tag_name", tagType: "tag_type"  
})

Add a tag to contact - Api Reference

It generates a relationship called contactTag containing an id.

client.add_contact_tag({ 
    contact: "contact_id", tag: "tag_id"
})

Remove a tag to contact - Api Reference

To remove a tag from contact just remove the relationship between them.

client.remove_contact_tag("contact_tag_id)

Create field value - Api Reference

It generates a relationship called fieldVaalue containing an id.

client.create_field_value(
  {
    contact: 572218,
    field: 2,
    value: 'field_value'
  }
)

Update a field value - Api Reference

It updates a relationship called fieldVaalue containing an id.

client.update_field_value(
  803_383,
  {
    contact: 572218,
    field: 2,
    value: 'new_field_value_put'
  }
)

Testing with your Api-Token

You can disable vcr in specs with these commands in your tests and create a new context for you.

WebMock.allow_net_connect!
VCR.turn_off!

License

The gem is available as open source under the terms of the MIT License.