Skip to content

tbtalbottjr/constant-contact-ruby

 
 

Repository files navigation

constant-contact-ruby

Ruby wrapper for the Constant Contact REST API

Requirements

HTTParty gem - rubygems.org/gems/httparty

Usage

require 'constant_contact'
include ConstantContact

### Setup Credentials ###
ConstantContact.setup( 'my_username', 'my_password' )

### Contacts ###

all_contacts = Contact.all 

contact_7 = Contact.get( 7 ) 
contact_7.update_attributes!( :first_name => 'John', :last_name => 'Doe' )
contact_7.add_to_list!( 3 )
contact_7.remove_from_list!( 3 )
contact_7.replace_contact_lists!( 1, 3, 9 )

new_contact = Contact.add( :email_address => '[email protected]', :first_name => 'John', :last_name => 'Doe' )

john_doe = Contact.search_by_email( '[email protected]' )

### Contact Lists ###

all_lists = ContactList.all

list_1 = ContactList.get( 1 )
list_1_members = ContactList.members( list_1.uid )
list_1.clear_contacts!    # remove all contacts from list
ContactList.delete( 1 )   # delete the list

new_list = ContactList.add( 'my new list' )

### Bulk Activities (involving multiple contacts) ###

activities = Activity.all # list all activities in the system

activity_details = Activity.get( activities.first.uid )

Activity.remove_all_contacts_from_lists( 1, 3, 4 )    # remove all contacts from lists 1, 3, and 4

new_contacts = [
  { :email_address => '[email protected]', :first_name => 'User1', :last_name => 'test' },
  { :email_address => '[email protected]', :first_name => 'User2', :last_name => 'test 2' },
  { :email_address => '[email protected]', :first_name => 'User1' },
  { :email_address => '[email protected]' }
]
Activity.add_contacts_to_lists( new_contacts, 3, 4 )    # all the users array to lists 3 and 4
Activity.remove_contacts_from_lists( new_contacts, 4 )  # remove the users from list 4

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Authors

Craig P Jolicoeur - craigjolicoeur.com

Copyright © 2010 BatchBlue Software, LLC. See LICENSE for details.

About

Ruby wrapper for constant contact API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%