REPS Client
This adapter provides a simple wrapper around a SOAP client for the MDI Achieve REPS Leads web service.
Installation
The gem is available on RubyGems and can be installed via:
gem install reps_client
Basics
For more details on any topic, see the RDocs.
Configuration
Configuration options can be set at the module level to automatically apply it to all client instances:
RepsClient.configure do |config|
config.enterprise_key = 'mykey'
end
client = RepsClient::Client.new
Or you can set it on each individual client instance:
client = RepsClient::Client.new(:enterprise_key => 'mykey')
The external service always requires an enterprise key. Optionally, you may also wish to change settings such as the service endpoint (which defaults to the REPS test server) and configure debug logging (which is disabled by default).
RepsClient.configure do |config|
config.enterprise_key = 'mykey'
config.endpoint = 'http://my.hosted.endpoint.com/lead.asmx'
config.debug = true
config.logger = Logger.new('my.log')
end
For a full list of configuration options, see RepsClient::Configuration.
Examples
To retrieve a list of communities that belong to this enterprise in REPS:
communities = client.get_communities
# => [#<RepsClient::Community address1="123 Anywhere Ln" city="Somewhere" community_id="2" name="Pine View Terrace" state="AK" zip="12345">, #<RepsClient::Community community_id="8" name="The Hills at Dale Valley">]
To retrieve a list of enumerated data types (e.g. relationship type, ad source) that are available for a particular community:
pick_lists = client.get_pick_lists(2)
# => {:prefix => [#<RepsClient::Prefix prefix_id="1" value="Mr.">, #<RepsClient::Prefix prefix_id="2" value="Ms.">],
# :suffix => [#<RepsClient::Suffix suffix_id="200" value="Jr.">, #<RepsClient::Suffix suffix_id="99" value="M.D">],
# :relationship_type => [#<RepsClient::RelationshipType relationship_type_id="42" name="Self">],
# :source => [#<RepsClient::Source source_id="99" code="WEB" description="From the community website">]}
To save a simple lead:
community_id = 2
contact = RepsClient::Contact.new(:prefix => 'Mr.',
:first_name => 'Fred',
:last_name => 'Rogers',
:email => '[email protected]',
:relationship_to_prospect_id => 2,
:source_id => 99)
prospect = RepsClient::Prospect.new(:prefix => 'Mr.',
:first_name => 'Fred',
:last_name => 'Rogers',
:email => '[email protected]',
:notes => 'Request for Brochure')
client.save_lead(community_id, contact, prospect)