reps_client 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +32 -0
- data/LICENSE +19 -0
- data/README.md +59 -33
- data/lib/reps_client/client.rb +85 -5
- data/lib/reps_client/community.rb +22 -1
- data/lib/reps_client/configuration.rb +34 -6
- data/lib/reps_client/lead.rb +15 -9
- data/lib/reps_client/pick_list.rb +43 -2
- data/lib/reps_client/version.rb +2 -1
- data/lib/reps_client.rb +0 -4
- data/reps_client.gemspec +3 -2
- data/spec/fixtures/save_lead/broken_rule.xml +49 -0
- data/spec/fixtures/save_lead/success.xml +42 -0
- data/spec/reps_client/client_spec.rb +122 -1
- data/spec/reps_client/community_spec.rb +12 -4
- data/spec/reps_client/configuration_spec.rb +31 -0
- data/spec/reps_client/lead_spec.rb +40 -17
- data/spec/reps_client/pick_list_spec.rb +2 -1
- data/spec/spec_helper.rb +0 -3
- data/spec/support/pick_list_shared_examples.rb +5 -3
- data/spec/support/ws_addressing_shared_examples.rb +33 -0
- metadata +42 -18
data/CHANGELOG.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
## 0.1.0 (2011-12-30)
|
2
|
+
|
3
|
+
* Add configuration option to enable or disable debug logging.
|
4
|
+
It is disabled by default (previously, it was always enabled).
|
5
|
+
|
6
|
+
``` ruby
|
7
|
+
RepsClient.configure do |config|
|
8
|
+
config.debug = true
|
9
|
+
end
|
10
|
+
```
|
11
|
+
|
12
|
+
* When logging is enabled, it defaults to logging to STDOUT, but you can
|
13
|
+
configure a custom logger.
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
RepsClient.configure do |config|
|
17
|
+
config.logger = Logger.new('my.log')
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
* Add support for ws-addressing. The REPS production environment requires
|
22
|
+
these headers on all requests.
|
23
|
+
|
24
|
+
* Flesh out logic around the return value of `RepsClient::Client#save_lead`.
|
25
|
+
It will return true when successful and false otherwise (previously, the
|
26
|
+
return value was meaningless).
|
27
|
+
|
28
|
+
* Update documentation.
|
29
|
+
|
30
|
+
## 0.0.1 (2011-12-09)
|
31
|
+
|
32
|
+
* Initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 G5
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -4,9 +4,11 @@ This adapter provides a simple wrapper around a SOAP client for the [MDI Achieve
|
|
4
4
|
|
5
5
|
## Installation ##
|
6
6
|
|
7
|
-
|
7
|
+
The gem is available on [RubyGems][rubygems] and can be installed via:
|
8
8
|
|
9
|
-
|
9
|
+
```
|
10
|
+
gem install reps_client
|
11
|
+
```
|
10
12
|
|
11
13
|
## Basics ##
|
12
14
|
|
@@ -14,49 +16,73 @@ For more details on any topic, see the [RDocs][rdocs].
|
|
14
16
|
|
15
17
|
### Configuration ###
|
16
18
|
|
17
|
-
Most commonly, you will only need to supply the enterprise key in order to access the service.
|
18
|
-
|
19
19
|
Configuration options can be set at the module level to automatically apply it to all client instances:
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
```ruby
|
22
|
+
RepsClient.configure do |config|
|
23
|
+
config.enterprise_key = 'mykey'
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
+
client = RepsClient::Client.new
|
27
|
+
```
|
26
28
|
|
27
29
|
Or you can set it on each individual client instance:
|
28
30
|
|
29
|
-
|
31
|
+
```ruby
|
32
|
+
client = RepsClient::Client.new(:enterprise_key => 'mykey')
|
33
|
+
```
|
30
34
|
|
31
|
-
|
35
|
+
The external service always requires an enterprise key. Optionally, you
|
36
|
+
may also wish to change settings such as the service endpoint (which defaults
|
37
|
+
to the REPS test server) and configure debug logging (which is disabled by default).
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
RepsClient.configure do |config|
|
41
|
+
config.enterprise_key = 'mykey'
|
42
|
+
config.endpoint = 'http://my.hosted.endpoint.com/lead.asmx'
|
43
|
+
config.debug = true
|
44
|
+
config.logger = Logger.new('my.log')
|
45
|
+
end
|
46
|
+
```
|
32
47
|
|
33
|
-
|
48
|
+
For a full list of configuration options, see {RepsClient::Configuration}.
|
49
|
+
|
50
|
+
### Examples ###
|
34
51
|
|
35
|
-
|
36
|
-
# => [#<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">]
|
52
|
+
To retrieve a list of communities that belong to this enterprise in REPS:
|
37
53
|
|
54
|
+
```ruby
|
55
|
+
communities = client.get_communities
|
56
|
+
# => [#<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">]
|
57
|
+
```
|
38
58
|
To retrieve a list of enumerated data types (e.g. relationship type, ad source) that are available for a particular community:
|
39
59
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
+
```ruby
|
61
|
+
pick_lists = client.get_pick_lists(2)
|
62
|
+
# => {:prefix => [#<RepsClient::Prefix prefix_id="1" value="Mr.">, #<RepsClient::Prefix prefix_id="2" value="Ms.">],
|
63
|
+
# :suffix => [#<RepsClient::Suffix suffix_id="200" value="Jr.">, #<RepsClient::Suffix suffix_id="99" value="M.D">],
|
64
|
+
# :relationship_type => [#<RepsClient::RelationshipType relationship_type_id="42" name="Self">],
|
65
|
+
# :source => [#<RepsClient::Source source_id="99" code="WEB" description="From the community website">]}
|
66
|
+
```
|
67
|
+
|
68
|
+
To save a simple lead:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
community_id = 2
|
72
|
+
contact = RepsClient::Contact.new(:prefix => 'Mr.',
|
73
|
+
:first_name => 'Fred',
|
74
|
+
:last_name => 'Rogers',
|
75
|
+
:email => 'misterrogers@neighborhood.com',
|
76
|
+
:relationship_to_prospect_id => 2,
|
77
|
+
:source_id => 99)
|
78
|
+
prospect = RepsClient::Prospect.new(:prefix => 'Mr.',
|
79
|
+
:first_name => 'Fred',
|
80
|
+
:last_name => 'Rogers',
|
81
|
+
:email => 'misterrogers@neighborhood.com',
|
82
|
+
:notes => 'Request for Brochure')
|
83
|
+
client.save_lead(community_id, contact, prospect)
|
84
|
+
```
|
60
85
|
|
61
86
|
[mdi]: http://mdiachieve.com
|
62
87
|
[rdocs]: http://rubydoc.info/gems/reps_client
|
88
|
+
[rubygems]: http://rubygems.org/gems/reps_client
|
data/lib/reps_client/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'savon'
|
2
|
+
require 'uuidtools'
|
2
3
|
|
3
4
|
require 'reps_client/community'
|
4
5
|
require 'reps_client/errors'
|
@@ -6,7 +7,7 @@ require 'reps_client/pick_list'
|
|
6
7
|
require 'reps_client/lead'
|
7
8
|
|
8
9
|
module RepsClient
|
9
|
-
#
|
10
|
+
# RepsClient::Client is the main object for connecting to the remote REPS service.
|
10
11
|
class Client
|
11
12
|
include CommunityMethods
|
12
13
|
include PickListMethods
|
@@ -20,15 +21,76 @@ module RepsClient
|
|
20
21
|
define_method(opt) { get_value(opt) }
|
21
22
|
end
|
22
23
|
|
24
|
+
# @attr [String] endpoint the service endpoint URL
|
25
|
+
# @attr [String] username the username for authentication
|
26
|
+
# @attr [String] password the password for authentication
|
27
|
+
# @attr [String] namespace the namespace for SOAP requests
|
28
|
+
# @attr [String] enterprise_key the corporate key required for all REPS requests
|
29
|
+
# @attr [true,false,String] debug set to true or 'true' to enable debug logging (defaults to false)
|
30
|
+
# @attr [Logger] logger the custom logger instance for debug logging (defaults to STDOUT)
|
31
|
+
|
32
|
+
def debug=(val)
|
33
|
+
@debug = val
|
34
|
+
Savon.log = self.debug?
|
35
|
+
end
|
36
|
+
|
37
|
+
def debug?
|
38
|
+
self.debug.to_s == 'true'
|
39
|
+
end
|
40
|
+
|
41
|
+
def logger=(val)
|
42
|
+
@logger = val
|
43
|
+
Savon.logger = self.logger
|
44
|
+
end
|
45
|
+
|
23
46
|
# Initializes the client.
|
24
47
|
#
|
48
|
+
# By default, the new client instance will take all of its configuration values from the
|
49
|
+
# module-level configuration, but these can be overridden at the client-level.
|
50
|
+
#
|
51
|
+
# @example Using module-level configuration values
|
52
|
+
# RepsClient.configure do |config|
|
53
|
+
# config.enterprise_key = 'my_key'
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# client1 = RepsClient::Client.new
|
57
|
+
# client1.enterprise_key
|
58
|
+
# # => "my_key"
|
59
|
+
#
|
60
|
+
# client2 = RepsClient::Client.new
|
61
|
+
# client2.enterprise_key
|
62
|
+
# # => "my_key"
|
63
|
+
#
|
64
|
+
# @example Selectively overriding configuration values at the client level
|
65
|
+
# RepsClient.configure do |config|
|
66
|
+
# config.enterprise_key = 'my_key'
|
67
|
+
# config.debug = 'true'
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# client1 = RepsClient::Client.new
|
71
|
+
# client1.enterprise_key
|
72
|
+
# # => "my_key"
|
73
|
+
# client1.debug?
|
74
|
+
# # => true
|
75
|
+
#
|
76
|
+
# client2 = RepsClient::Client.new(:debug => false)
|
77
|
+
# client2.enterprise_key
|
78
|
+
# # => "my_key"
|
79
|
+
# client2.debug?
|
80
|
+
# # => false
|
81
|
+
#
|
25
82
|
# @param [Hash] options
|
26
83
|
# @option options [String] :username The username for authenticating to the web service
|
27
84
|
# @option options [String] :password The password for authenticating to the web service
|
28
85
|
# @option options [String] :enterprise_key The enterprise key for authentication to the web service
|
29
86
|
# @option options [String] :endpoint The address for connecting to the web service
|
30
87
|
# @option options [String] :namespace The XML namespace to use for requests
|
88
|
+
# @option options [true,false] :debug true enabled debug logging (defaults to false)
|
89
|
+
# @option options [Logger] :logger a custom logger instance (defaults to STDOUT)
|
90
|
+
# @see RepsClient::Configuration
|
31
91
|
def initialize(options={})
|
92
|
+
self.debug = nil
|
93
|
+
self.logger = nil
|
32
94
|
options.each { |k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=") }
|
33
95
|
end
|
34
96
|
|
@@ -44,14 +106,18 @@ module RepsClient
|
|
44
106
|
wsdl.namespace = self.namespace.to_s
|
45
107
|
wsse.credentials self.username, self.password, false
|
46
108
|
|
47
|
-
|
109
|
+
wsse.timestamp = true
|
110
|
+
|
111
|
+
# We have to override some of the timestamps to force UTC
|
48
112
|
# (the reps service cacks on any other timezone)
|
113
|
+
wsse.created_at = Time.now.utc
|
49
114
|
class << wsse
|
50
115
|
define_method(:timestamp, lambda { @timestamp ||= Time.now.utc.xs_datetime })
|
51
116
|
end
|
52
117
|
end
|
53
118
|
end
|
54
119
|
|
120
|
+
private
|
55
121
|
# Sends a SOAP request to the remote service. This method takes care of
|
56
122
|
# constructing the SOAP envelope and headers as well as common parameters
|
57
123
|
# for REPS (e.g. the enterprise key)
|
@@ -72,15 +138,19 @@ module RepsClient
|
|
72
138
|
|
73
139
|
response = soap_client.request :wsdl, camelcase_action do
|
74
140
|
soap.element_form_default = :qualified
|
141
|
+
qualified_soap_action = URI.join(self.namespace, camelcase_action).to_s
|
142
|
+
|
143
|
+
soap.namespaces['xmlns:wsa'] = 'http://schemas.xmlsoap.org/ws/2004/08/addressing'
|
144
|
+
soap.header = ws_addressing_headers(qualified_soap_action)
|
145
|
+
http.headers['SOAPAction'] = %{"#{qualified_soap_action}"}
|
146
|
+
|
75
147
|
soap.body = {:enterprise_key => self.enterprise_key}.merge(soap_parameters)
|
76
|
-
http.headers['SOAPAction'] = %{"#{URI.join(self.namespace, camelcase_action)}"}
|
77
148
|
end
|
78
149
|
rescue Savon::SOAP::Fault => f
|
79
150
|
raise RepsClient::ServiceError.translate_fault(f)
|
80
151
|
end
|
81
152
|
end
|
82
153
|
|
83
|
-
|
84
154
|
# Retrieves an attribute value. If the attribute has not been set
|
85
155
|
# on this object, it is retrieved from the global configuration.
|
86
156
|
#
|
@@ -89,7 +159,17 @@ module RepsClient
|
|
89
159
|
# @param [Symbol] attribute the name of the attribute
|
90
160
|
# @return [String] the value of the attribute
|
91
161
|
def get_value(attribute)
|
92
|
-
instance_variable_get("@#{attribute}")
|
162
|
+
local_val = instance_variable_get("@#{attribute}")
|
163
|
+
local_val.nil? ? RepsClient.send(attribute) : local_val
|
164
|
+
end
|
165
|
+
|
166
|
+
# Manually constructs the ws-addressing soap headers required by the REPS production
|
167
|
+
# web service. It would be nice to add ws-addressing support to savon eventually.
|
168
|
+
def ws_addressing_headers(soap_action)
|
169
|
+
{ 'wsa:Action' => soap_action,
|
170
|
+
'wsa:To' => self.endpoint,
|
171
|
+
'wsa:ReplyTo' => {'wsa:Address' => 'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous'},
|
172
|
+
'wsa:MessageID' => "urn:uuid:#{UUIDTools::UUID.random_create.to_s}" }
|
93
173
|
end
|
94
174
|
end
|
95
175
|
end
|
@@ -1,18 +1,39 @@
|
|
1
1
|
require 'modelish'
|
2
2
|
|
3
3
|
module RepsClient
|
4
|
-
# A community (i.e. location) as configured in the MDI REPS service.
|
4
|
+
# A community (i.e. location) as configured in the MDI Achieve REPS service.
|
5
5
|
class Community < Modelish::Base
|
6
|
+
# @return [Integer] the unique identifier for the community in REPS.
|
7
|
+
# @note This ID will be required as an argument in most service calls.
|
6
8
|
property :community_id, :from => :community_idy, :type => Integer
|
9
|
+
|
10
|
+
# @return [String] the name of the community
|
7
11
|
property :name, :type => String
|
12
|
+
|
13
|
+
# @return [String] the first line of the community's street address
|
8
14
|
property :address1, :from => :community_address1, :type => String
|
15
|
+
|
16
|
+
# @return [String] the second line of the community's street address
|
9
17
|
property :address2, :from => :community_address2, :type => String
|
18
|
+
|
19
|
+
# @return [String] the city where the community is located
|
10
20
|
property :city, :from => :community_city, :type => String
|
21
|
+
|
22
|
+
# @return [String] the state or territory where the community is located
|
11
23
|
property :state, :from => :community_state, :type => String
|
24
|
+
|
25
|
+
# @return [String] the zip or postal code of the community
|
12
26
|
property :zip, :from => :community_zip, :type => String
|
27
|
+
|
28
|
+
ignore_unknown_properties!
|
13
29
|
end
|
14
30
|
|
15
31
|
module CommunityMethods
|
32
|
+
# Retrieves a list of communities from the REPS web service.
|
33
|
+
# Note that all of the other service methods require a community ID
|
34
|
+
# that is returned by this method.
|
35
|
+
#
|
36
|
+
# @return [Array<RepsClient::Community>] the list of REPS communities
|
16
37
|
def get_communities
|
17
38
|
response = send_soap_request(:get_communities)
|
18
39
|
communities = response.to_hash[:get_communities_response][:get_communities_result][:diffgram][:document_element][:community]
|
@@ -1,34 +1,60 @@
|
|
1
1
|
require 'configlet'
|
2
|
+
require 'logger'
|
2
3
|
|
3
4
|
module RepsClient
|
4
|
-
# All
|
5
|
-
VALID_CONFIG_OPTIONS = [:endpoint, :username, :password, :namespace, :enterprise_key
|
5
|
+
# All possible configuration options
|
6
|
+
VALID_CONFIG_OPTIONS = [:endpoint, :username, :password, :namespace, :enterprise_key,
|
7
|
+
:debug, :logger]
|
6
8
|
|
7
|
-
|
9
|
+
# The default endpoint (points to the REPS test server)
|
10
|
+
DEFAULT_ENDPOINT = 'https://repssuite.mdiachieve.com/webservices/lead.asmx'
|
11
|
+
|
12
|
+
# The default namespace for SOAP requests
|
8
13
|
DEFAULT_NAMESPACE = 'http://www.mdiachieve.com/'
|
9
14
|
|
10
15
|
module Configuration
|
11
16
|
include Configlet
|
12
|
-
|
17
|
+
|
13
18
|
def self.extended(base)
|
14
19
|
# Default configuration - happens whether or not .configure is called
|
15
20
|
base.config :reps_client do
|
16
21
|
default :endpoint => DEFAULT_ENDPOINT
|
17
22
|
default :namespace => DEFAULT_NAMESPACE
|
23
|
+
default :debug => 'false'
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
|
-
#
|
27
|
+
# Dynamically define mutators and accessors for configuration options
|
22
28
|
VALID_CONFIG_OPTIONS.each do |config_opt|
|
23
29
|
define_method(config_opt) do
|
24
30
|
self[config_opt]
|
25
31
|
end
|
26
32
|
|
27
33
|
define_method("#{config_opt}=".to_sym) do |val|
|
28
|
-
self[config_opt] = val
|
34
|
+
self[config_opt] = val.nil? ? nil : val.to_s
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
38
|
+
# @attr [String] endpoint the service endpoint URL (defaults to RepsClient::DEFAULT_ENDPOINT)
|
39
|
+
# @attr [String] username the username for authentication
|
40
|
+
# @attr [String] password the password for authentication
|
41
|
+
# @attr [String] namespace the namespace for SOAP requests (defaults to RepsClient::DEFAULT_NAMESPACE)
|
42
|
+
# @attr [String] enterprise_key the corporate key required for all REPS requests
|
43
|
+
# @attr [true,false,String] debug set to true or 'true' to enable debug logging (defaults to false)
|
44
|
+
|
45
|
+
# @return [true,false] true if debug logging is enabled; false otherwie.
|
46
|
+
def debug?
|
47
|
+
self[:debug] == 'true'
|
48
|
+
end
|
49
|
+
|
50
|
+
# Sets the logger to use for debug messages
|
51
|
+
attr_writer :logger
|
52
|
+
|
53
|
+
# @return [Logger] the logger to use for debug messages (defaults to STDOUT)
|
54
|
+
def logger
|
55
|
+
@logger ||= Logger.new(STDOUT)
|
56
|
+
end
|
57
|
+
|
32
58
|
# Configures this module through the given +block+.
|
33
59
|
# Default configuration options will be applied unless
|
34
60
|
# they are explicitly overridden in the +block+.
|
@@ -48,6 +74,8 @@ module RepsClient
|
|
48
74
|
# config.endpoint = 'http://my.endpoint.com'
|
49
75
|
# config.namespace = 'http://my.namespace.com'
|
50
76
|
# config.enterprise_key = 'my_key'
|
77
|
+
# config.debug = true
|
78
|
+
# config.logger = Logger.new('my.log')
|
51
79
|
# end
|
52
80
|
# @return [RepsClient] _self
|
53
81
|
# @see VALID_CONFIG_OPTIONS
|
data/lib/reps_client/lead.rb
CHANGED
@@ -25,12 +25,12 @@ module RepsClient
|
|
25
25
|
# :state => 'CA',
|
26
26
|
# :zip_code => '12345')
|
27
27
|
class Contact < Modelish::Base
|
28
|
-
# @attribute [rw]
|
28
|
+
# @attribute [rw]
|
29
29
|
# @return [String] the contact's salutation (e.g. "Mr.", "Ms.", "Dr.", etc.)
|
30
30
|
# @see RepsClient::PickListMethods#get_pick_lists
|
31
31
|
property :prefix, :type => String, :max_length => 30
|
32
32
|
|
33
|
-
# @attribute [rw]
|
33
|
+
# @attribute [rw]
|
34
34
|
# @return [String] the contact's first name
|
35
35
|
# @note This attribute is required on initialization.
|
36
36
|
property :first_name, :type => String, :required => true, :max_length => 30
|
@@ -88,11 +88,15 @@ module RepsClient
|
|
88
88
|
property :email, :type => String, :max_length => 100
|
89
89
|
|
90
90
|
# @attribute [rw]
|
91
|
-
# @return [int] the relationship type id describing the contact
|
92
|
-
# @note
|
93
|
-
#
|
94
|
-
#
|
91
|
+
# @return [int] the relationship type id describing the relationship of the contact to the prospect
|
92
|
+
# @note REPS requires the "direction" of the relationship type to be the opposite of what most users expect.
|
93
|
+
#
|
94
|
+
# The relationship type is determined based on the contact's answer to the question "What
|
95
|
+
# is your relationship to the prospect?" For instance, if a contact was acting on behalf of their
|
96
|
+
# mother, the relationship type name might be "Child" or "Son" or "Daughter" (but definitely
|
97
|
+
# *not* "Mother" or "Parent"). Valid relationship types are available from
|
95
98
|
# the remote service.
|
99
|
+
#
|
96
100
|
# @see RepsClient::PickListMethods#get_pick_lists
|
97
101
|
property :relationship_to_prospect_id, :type => Integer
|
98
102
|
|
@@ -105,7 +109,7 @@ module RepsClient
|
|
105
109
|
property :include_in_emailings, :default => false, :type => lambda { |v| !!v }
|
106
110
|
|
107
111
|
# @attribute [rw]
|
108
|
-
# @return [int]
|
112
|
+
# @return [int] the identifier for the lead source in REPS
|
109
113
|
# @see RepsClient::PickListMethods#get_pick_lists
|
110
114
|
# @note This attribute is required on initialization.
|
111
115
|
property :source_id, :type => Integer, :required => true, :validate_type => true
|
@@ -269,7 +273,7 @@ module RepsClient
|
|
269
273
|
# @param [Integer] community_id the REPS ID of the community
|
270
274
|
# @param [RepsClient::Contact] contact the contact person for the lead
|
271
275
|
# @param [RepsClient::Prospect] prospect the prospective resident (if different than contact)
|
272
|
-
#
|
276
|
+
# @return [true,false] true if the lead was saved succesfully; false otherwise
|
273
277
|
def save_lead(community_id,contact,prospect=nil)
|
274
278
|
LeadMethods.validate_required!(:community_id => community_id,
|
275
279
|
:contact => contact)
|
@@ -285,7 +289,9 @@ module RepsClient
|
|
285
289
|
soap_params[:order!] << :new_prospect
|
286
290
|
end
|
287
291
|
|
288
|
-
send_soap_request(:save_lead, soap_params)
|
292
|
+
response = send_soap_request(:save_lead, soap_params).to_hash
|
293
|
+
|
294
|
+
response[:save_lead_response][:save_lead_result][:diffgram][:document_element].nil?
|
289
295
|
end
|
290
296
|
end
|
291
297
|
end
|
@@ -1,25 +1,65 @@
|
|
1
1
|
require 'modelish/validations'
|
2
2
|
|
3
3
|
module RepsClient
|
4
|
+
# A name prefix from the REPS service.
|
5
|
+
# Equates to the dropdown list labeled "Prefix" on the Leads -> Contact and
|
6
|
+
# Prospect pages in REPS.
|
4
7
|
class Prefix < Modelish::Base
|
8
|
+
# @return [int] the id of the prefix
|
5
9
|
property :prefix_id, :from => :user_list_idy, :type => Integer
|
10
|
+
|
11
|
+
# @return [String] the display value of the prefix (e.g. "Mr.")
|
6
12
|
property :value, :from => :list_value, :type => String
|
13
|
+
|
14
|
+
ignore_unknown_properties!
|
7
15
|
end
|
8
16
|
|
17
|
+
# A name suffix from the REPS service.
|
18
|
+
# Equates to the dropdown list labeled "Suffix" on the Leads -> Contact and
|
19
|
+
# Prospect pages in REPS.
|
9
20
|
class Suffix < Modelish::Base
|
21
|
+
# @return [int] the id of the suffix
|
10
22
|
property :suffix_id, :from => :user_list_idy, :type => Integer
|
23
|
+
|
24
|
+
# @return [String] the display value of the suffix (e.g. "Jr.")
|
11
25
|
property :value, :from => :list_value, :type => String
|
26
|
+
|
27
|
+
ignore_unknown_properties!
|
12
28
|
end
|
13
29
|
|
30
|
+
# A type of relationship from the REPS service.
|
31
|
+
# Equates to the dropdown list labeled 'Relation to Resident' on the
|
32
|
+
# Leads -> Contact page in REPS.
|
33
|
+
#
|
34
|
+
# Note: Be careful of the direction of the relationship type. Many web pages
|
35
|
+
# ask about the relationship of the prospect to the contact (Q: For whom are
|
36
|
+
# you inquiring? A: Mother), but REPS uses the relationship of the contact
|
37
|
+
# to the prospect (Q: What is your relationship to the prospective resident?
|
38
|
+
# A: Daughter).
|
14
39
|
class RelationshipType < Modelish::Base
|
40
|
+
# @return [int] the id of the relationship type
|
15
41
|
property :relationship_type_id, :from => :relationship_type_idy, :type => Integer
|
42
|
+
|
43
|
+
# @return [String] the display name of the relationship type (e.g. "Daughter")
|
16
44
|
property :name, :from => :relationship_name, :type => String
|
45
|
+
|
46
|
+
ignore_unknown_properties!
|
17
47
|
end
|
18
48
|
|
49
|
+
# A lead source (e.g. print advertising, direct mail, referral, etc.)
|
50
|
+
# Equates to the dropdown list labeled 'Source 1' on the Leads -> Contact
|
51
|
+
# page in REPS.
|
19
52
|
class Source < Modelish::Base
|
53
|
+
# @return [int] the id of the lead source
|
20
54
|
property :source_id, :from => :source_idy, :type => Integer
|
55
|
+
|
56
|
+
# @return [String] the unique human-readable code identifying the source (e.g. 'KOIN-TV')
|
21
57
|
property :code, :type => String
|
58
|
+
|
59
|
+
# @return [String] the description of the lead source (e.g. 'KOIN television ad campaign')
|
22
60
|
property :description, :type => String
|
61
|
+
|
62
|
+
ignore_unknown_properties!
|
23
63
|
end
|
24
64
|
|
25
65
|
module PickListMethods
|
@@ -41,14 +81,15 @@ module RepsClient
|
|
41
81
|
def get_pick_lists(community_id)
|
42
82
|
PickListMethods.validate_required!(:community_id => community_id)
|
43
83
|
|
44
|
-
response = send_soap_request(:get_pick_lists, :community_id => community_id,
|
84
|
+
response = send_soap_request(:get_pick_lists, :community_id => community_id,
|
85
|
+
:order! => [:enterprise_key,:community_id])
|
45
86
|
lists = response.to_hash[:get_pick_lists_response][:get_pick_lists_result][:diffgram][:pick_lists]
|
46
87
|
|
47
88
|
result = {}
|
48
89
|
[:prefix, :suffix, :relationship_type, :source].each do |k|
|
49
90
|
result[k] = process_pick_list(k, lists)
|
50
91
|
end
|
51
|
-
|
92
|
+
|
52
93
|
result
|
53
94
|
end
|
54
95
|
|
data/lib/reps_client/version.rb
CHANGED
data/lib/reps_client.rb
CHANGED
data/reps_client.gemspec
CHANGED
@@ -14,13 +14,14 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
|
17
|
+
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.add_dependency('modelish', '>=0.1.3')
|
21
21
|
s.add_dependency('configlet', '~>2.1')
|
22
|
-
|
22
|
+
s.add_dependency('uuidtools', '~>2.1.2')
|
23
23
|
s.add_dependency('savon', '~>0.9.7')
|
24
|
+
|
24
25
|
s.add_development_dependency('savon_spec', '~>0.1')
|
25
26
|
|
26
27
|
s.add_development_dependency('rspec', '~>2.6')
|