Ruby client library for Telerivet REST API
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
LICENSE
README
telerivet.gemspec

README

Ruby client library for Telerivet REST API

http://telerivet.com/api

Overview:
---------
This library makes it easy to integrate your Ruby application with Telerivet.
You can use it to:

- send SMS messages via an Android phone or SMS gateway service
- update contact information in Telerivet (e.g. from a signup form on your own website)
- add or remove contacts from groups
- export your message/contact data from Telerivet into your own systems
- schedule messages to be sent at a later time
- control automated services
- much more

All API methods are fully documented at http://telerivet.com/api/rest/ruby ,
as well as in the comments of the Ruby source files. To learn what functionality is 
available, start with lib/telerivet.rb, lib/telerivet/project.rb, 
and lib/telerivet/apicursor.rb .

System Requirements:
--------------------
Ruby 1.9 or higher

Installation:
-------------

# from rubygems (https://rubygems.org/gems/telerivet):
gem install telerivet

# from source:
gem build telerivet.gemspec
gem install telerivet

Example Usage:
--------------

require 'telerivet'
   
API_KEY = 'YOUR_API_KEY'  # from https://telerivet.com/api/keys
PROJECT_ID = 'YOUR_PROJECT_ID'

tr = Telerivet::API.new(API_KEY)

project = tr.init_project_by_id(PROJECT_ID)

# Send a SMS message
project.send_message({
    to_number: '555-0001',
    content: 'Hello world!'
})

# Query contacts  
name_prefix = 'John'
cursor = project.query_contacts({
    name: {prefix: name_prefix},
    sort: 'name'    
}).limit(20)

puts "#{cursor.count()} contacts matching #{name_prefix}:\n"

cursor.each { |contact|
    puts "#{contact.name} #{contact.phone_number} #{contact.vars.birthdate}"
}

# Import a contact
contact = project.get_or_create_contact({
    name: 'John Smith',
    phone_number: '555-0001',
    vars: {
        birthdate: '1981-03-04',
        network: 'Vodacom'
    }
})

# Add a contact to a group    
group = project.get_or_create_group('Subscribers')
contact.add_to_group(group)