getresponse 0.4 → 0.5
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/README.rdoc +53 -1
- data/lib/get_response.rb +7 -1
- data/lib/get_response/campaign.rb +104 -0
- data/lib/get_response/campaign_proxy.rb +17 -0
- data/lib/get_response/conditions.rb +97 -0
- data/lib/get_response/confirmation_body.rb +18 -0
- data/lib/get_response/confirmation_body_proxy.rb +47 -0
- data/lib/get_response/confirmation_subject.rb +17 -0
- data/lib/get_response/confirmation_subject_proxy.rb +46 -0
- data/lib/get_response/connection.rb +24 -0
- data/lib/get_response/contact.rb +28 -2
- data/lib/get_response/contact_proxy.rb +47 -0
- data/lib/get_response/from_fields_proxy.rb +14 -0
- metadata +30 -15
- data/lib/api.rb +0 -1
data/README.rdoc
CHANGED
|
@@ -113,6 +113,11 @@ Get campaign messages
|
|
|
113
113
|
messages = campaign.messages
|
|
114
114
|
newsletters = campaign.messages(:type => "newsletter")
|
|
115
115
|
|
|
116
|
+
Get all messages
|
|
117
|
+
|
|
118
|
+
# with connection
|
|
119
|
+
connection.messages.all
|
|
120
|
+
|
|
116
121
|
Get message contents
|
|
117
122
|
|
|
118
123
|
# with message
|
|
@@ -135,4 +140,51 @@ Get/set campaign's postal address
|
|
|
135
140
|
# campaign_one - existing campaign
|
|
136
141
|
# campaign_two - existing campaign
|
|
137
142
|
postal_address = campaign_one.postal_address
|
|
138
|
-
campaign_two.postal_address = postal_address
|
|
143
|
+
campaign_two.postal_address = postal_address
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
To get contact openned message list with dates
|
|
147
|
+
|
|
148
|
+
# contact - existing contact
|
|
149
|
+
@contact.opens
|
|
150
|
+
|
|
151
|
+
Get subscriptions statistics
|
|
152
|
+
|
|
153
|
+
# campaign - existing campaign
|
|
154
|
+
campaign.subscription_statistics
|
|
155
|
+
campaign.subscription_statistics(:created_on => {:at => Date.today})
|
|
156
|
+
campaign.subscription_statistics(:created_on => {:from => "2011-01-01", :to => "2011-12-30"})
|
|
157
|
+
|
|
158
|
+
Get confirmation message bodies
|
|
159
|
+
|
|
160
|
+
# connection - existing connection
|
|
161
|
+
connection.confirmation_bodies.all
|
|
162
|
+
connection.confirmation_bodies.all(:language_code => {:equals => "en"})
|
|
163
|
+
|
|
164
|
+
Get confirmation message subjects
|
|
165
|
+
|
|
166
|
+
# connection - existing connection
|
|
167
|
+
connection.confirmation_subjects.all
|
|
168
|
+
connection.confirmation_subjects.all(:language_code => {:equals => "en"})
|
|
169
|
+
|
|
170
|
+
Get deleted contacts
|
|
171
|
+
|
|
172
|
+
contact_proxy.deleted
|
|
173
|
+
contact_proxy.deleted(:reason => "bounce")
|
|
174
|
+
campaign.deleted
|
|
175
|
+
|
|
176
|
+
Get single field form by id
|
|
177
|
+
|
|
178
|
+
from_field_proxy.find("from_field_id")
|
|
179
|
+
|
|
180
|
+
Get single confirmation body by id
|
|
181
|
+
|
|
182
|
+
confirmation_body_proxy.find("confirmation_body_id")
|
|
183
|
+
|
|
184
|
+
Get single confirmation subject by id
|
|
185
|
+
|
|
186
|
+
confirmation_subject_proxy.find("confirmation_subject_id")
|
|
187
|
+
|
|
188
|
+
Create new campaign
|
|
189
|
+
|
|
190
|
+
connection.campaigns.create(new_campaign_attributes)
|
data/lib/get_response.rb
CHANGED
|
@@ -24,6 +24,7 @@ class SymbolOperator
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def evaluate(value)
|
|
27
|
+
warn "[DEPRECATION] evaluation of GetResponse operators is deprecated."
|
|
27
28
|
{ field.to_s => { gr_operator => value } }
|
|
28
29
|
end
|
|
29
30
|
|
|
@@ -56,4 +57,9 @@ GetResponse.autoload :Domain, "get_response/domain"
|
|
|
56
57
|
GetResponse.autoload :DomainProxy, "get_response/domain_proxy"
|
|
57
58
|
GetResponse.autoload :MessageProxy, "get_response/message_proxy"
|
|
58
59
|
GetResponse.autoload :Newsletter, "get_response/newsletter"
|
|
59
|
-
GetResponse.autoload :FollowUp, "get_response/follow_up"
|
|
60
|
+
GetResponse.autoload :FollowUp, "get_response/follow_up"
|
|
61
|
+
GetResponse.autoload :ConfirmationBody, "get_response/confirmation_body"
|
|
62
|
+
GetResponse.autoload :ConfirmationBodyProxy, "get_response/confirmation_body_proxy"
|
|
63
|
+
GetResponse.autoload :ConfirmationSubject, "get_response/confirmation_subject"
|
|
64
|
+
GetResponse.autoload :ConfirmationSubjectProxy, "get_response/confirmation_subject_proxy"
|
|
65
|
+
GetResponse.autoload :Conditions, "get_response/conditions"
|
|
@@ -3,6 +3,8 @@ module GetResponse
|
|
|
3
3
|
# GetResponse email campaign
|
|
4
4
|
class Campaign
|
|
5
5
|
attr_reader :id, :name, :from_name, :from_email, :reply_to_email, :created_on
|
|
6
|
+
attr_reader :from_field, :reply_to_field, :confirmation_body, :confirmation_subject
|
|
7
|
+
attr_accessor :description, :language_code
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
def initialize(params, connection)
|
|
@@ -25,6 +27,15 @@ module GetResponse
|
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
# Get contacts deleted from this campaign
|
|
31
|
+
#
|
|
32
|
+
# @return [Array]
|
|
33
|
+
def deleted_contacts
|
|
34
|
+
@contact_proxy = ContactProxy.new(@connection)
|
|
35
|
+
@contact_proxy.deleted(:campaigns => [@id])
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
28
39
|
# Get domain assigned to this campaign.
|
|
29
40
|
#
|
|
30
41
|
# returns:: GetResponse::Domain
|
|
@@ -84,6 +95,99 @@ module GetResponse
|
|
|
84
95
|
result if result["updated"].to_i == 1
|
|
85
96
|
end
|
|
86
97
|
|
|
98
|
+
|
|
99
|
+
# Get contacts subscription stats for this campaign aggregated by date, campaign and contact’s origin.
|
|
100
|
+
# Example:
|
|
101
|
+
#
|
|
102
|
+
# # get stats for camapaign, any time period
|
|
103
|
+
# @campaign.subscription_statistics
|
|
104
|
+
#
|
|
105
|
+
# # get stats for specified date
|
|
106
|
+
# @campaign.subscription_statistics(:created_on => {:at => Date.today})
|
|
107
|
+
# @campaign.subscription_statistics(:created_on => {:from => "2011-01-01", :to => "2011-12-30"})
|
|
108
|
+
#
|
|
109
|
+
# @param conditions [Hash] conditions for statistics query, empty by default
|
|
110
|
+
# @return [Hash] collection of aggregated statistics
|
|
111
|
+
def subscription_statistics(conditions = {})
|
|
112
|
+
@contact_proxy = ContactProxy.new(@connection)
|
|
113
|
+
@contact_proxy.statistics(conditions.merge(:campaigns => [@id]))
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# Set object (without sending API 'set' request) level from field. If value is not
|
|
118
|
+
# <tt>GetResponse::FromField</tt> method will try to fetch from field attributes through API.
|
|
119
|
+
#
|
|
120
|
+
# @param value [FromField]
|
|
121
|
+
# @return [GetResponse::FromField]
|
|
122
|
+
def from_field=(value)
|
|
123
|
+
if value.instance_of? GetResponse::FromField
|
|
124
|
+
@from_field = value
|
|
125
|
+
else
|
|
126
|
+
@from_field = FromFieldsProxy.new(@connection).find(value)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Set object (without sending API 'set' request) level reply to field. If value is not
|
|
132
|
+
# <tt>GetResponse::FromField</tt> method will try to fetch from field attributes through API.
|
|
133
|
+
#
|
|
134
|
+
# @param value [FromField]
|
|
135
|
+
# @return [GetResponse::FromField]
|
|
136
|
+
def reply_to_field=(value)
|
|
137
|
+
if value.instance_of? GetResponse::FromField
|
|
138
|
+
@reply_to_field = value
|
|
139
|
+
else
|
|
140
|
+
@reply_to_field = FromFieldsProxy.new(@connection).find(value)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Set object (without sending API 'set' request) level confirmation body. If value is not
|
|
146
|
+
# <tt>GetResponse::ConfirmationBody</tt> instance method will try to fetch attributes through API.
|
|
147
|
+
#
|
|
148
|
+
# @param value [GetResponse::ConfirmationBody]
|
|
149
|
+
# @return [GetResponse::ConfirmationBody]
|
|
150
|
+
def confirmation_body=(value)
|
|
151
|
+
if value.instance_of? GetResponse::ConfirmationBody
|
|
152
|
+
@confirmation_body = value
|
|
153
|
+
else
|
|
154
|
+
@confirmation_body = ConfirmationBodyProxy.new(@connection).find(value)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# Set object (without sending API 'set' request) level confirmation subject. If value is not
|
|
160
|
+
# <tt>GetResponse::ConfirmationSubject</tt> instance method will try to fetch attributes through API.
|
|
161
|
+
#
|
|
162
|
+
# @param value [GetResponse::ConfirmationSubject]
|
|
163
|
+
# @return [GetResponse::ConfirmationSubject]
|
|
164
|
+
def confirmation_subject=(value)
|
|
165
|
+
if value.instance_of? GetResponse::ConfirmationSubject
|
|
166
|
+
@confirmation_subject = value
|
|
167
|
+
else
|
|
168
|
+
@confirmation_subject = ConfirmationSubjectProxy.new(@connection).find(value)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# Saves new campaign.
|
|
174
|
+
#
|
|
175
|
+
# @return [GetResponse::Campaign]
|
|
176
|
+
def save
|
|
177
|
+
attributes = {
|
|
178
|
+
"name" => name,
|
|
179
|
+
"description" => description,
|
|
180
|
+
"language_code" => language_code,
|
|
181
|
+
"from_field" => from_field.id,
|
|
182
|
+
"reply_to_field" => reply_to_field.id,
|
|
183
|
+
"confirmation_subject" => confirmation_subject.id,
|
|
184
|
+
"confirmation_body" => confirmation_body.id
|
|
185
|
+
}
|
|
186
|
+
save_result = @connection.send_request("add_campaign", attributes)["result"]
|
|
187
|
+
@id = save_result["CAMPAIGN_ID"]
|
|
188
|
+
self
|
|
189
|
+
end
|
|
190
|
+
|
|
87
191
|
end
|
|
88
192
|
|
|
89
193
|
end
|
|
@@ -18,6 +18,23 @@ module GetResponse
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
# Create new campaign from passed attributes
|
|
23
|
+
#
|
|
24
|
+
# @param attrs [Hash]
|
|
25
|
+
# @return [GetResponse::Campaign]
|
|
26
|
+
def create(attrs)
|
|
27
|
+
new_campaign = Campaign.new(attrs, @connection)
|
|
28
|
+
new_campaign.description = attrs["description"]
|
|
29
|
+
new_campaign.language_code = attrs["language_code"]
|
|
30
|
+
new_campaign.reply_to_field = attrs["reply_to_field"]
|
|
31
|
+
new_campaign.from_field = attrs["from_field"]
|
|
32
|
+
new_campaign.confirmation_body = attrs["confirmation_body"]
|
|
33
|
+
new_campaign.confirmation_subject = attrs["confirmation_subject"]
|
|
34
|
+
new_campaign.save
|
|
35
|
+
new_campaign
|
|
36
|
+
end
|
|
37
|
+
|
|
21
38
|
end
|
|
22
39
|
|
|
23
40
|
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module GetResponse
|
|
2
|
+
|
|
3
|
+
# GetResponse API Operators (http://dev.getresponse.com/api-doc/#operators) parsing module.
|
|
4
|
+
module Conditions
|
|
5
|
+
|
|
6
|
+
protected
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# Parse whole set of conditions. Method can raise <tt>GetResponseError</tt> exception if any of
|
|
10
|
+
# passed condition opertors is not on supported operator list.
|
|
11
|
+
# Example:
|
|
12
|
+
#
|
|
13
|
+
# parse_conditions(:created_on => {:from => "2011-01-01", :to => Time.now}, :count => {'less' => 45, :equals => nil})
|
|
14
|
+
# => {:created_on=>{"FROM"=>"2011-01-01", "TO"=>"2011-10-31"}, :count=>{"LESS"=>45}}
|
|
15
|
+
#
|
|
16
|
+
# conditions:: Hash, empty by default
|
|
17
|
+
# returns:: Hash
|
|
18
|
+
def parse_conditions(conditions = {})
|
|
19
|
+
parsed_conditions = {}
|
|
20
|
+
conditions.each_pair do |field, conds|
|
|
21
|
+
# if conds doesn't look like conditions hash
|
|
22
|
+
unless conds.respond_to?(:each_pair)
|
|
23
|
+
parsed_conditions[field] = conds
|
|
24
|
+
next
|
|
25
|
+
end
|
|
26
|
+
conds.each_pair do |operator, value|
|
|
27
|
+
parsed_conditions[field] ||= {}
|
|
28
|
+
operator = operator.to_s.upcase
|
|
29
|
+
parsed_conditions[field].merge! parse_condition(operator, value)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
parsed_conditions
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Parse condition with operator and its value. Method return <tt>Hash</tt> instance with
|
|
38
|
+
# condition for operator. If value is <tt>nil</tt> empty <tt>Hash</tt> will be returned.
|
|
39
|
+
# If operator is not on supported operator list <tt>GetResponseError</tt> will be raised.
|
|
40
|
+
# Example:
|
|
41
|
+
#
|
|
42
|
+
# parse_condition(:from, 2.days.ago)
|
|
43
|
+
# => {"FROM" => "2011-10-28"}
|
|
44
|
+
# parse_condition("TO", nil)
|
|
45
|
+
# => {}
|
|
46
|
+
#
|
|
47
|
+
# operator:: Symbol, String
|
|
48
|
+
# value:: String, Fixnum, Date, Time
|
|
49
|
+
# returns:: Hash
|
|
50
|
+
def parse_condition(operator, value)
|
|
51
|
+
parsed = case operator
|
|
52
|
+
when "EQUALS", "NOT_EQUALS", "CONTAINS", "NOT_CONTAINS", "MATCHES"
|
|
53
|
+
parse_text_conditions(operator, value)
|
|
54
|
+
when "LESS", "LESS_OR_EQUALS", "EQUALS", "GREATER_OR_EQUALS", "GREATER"
|
|
55
|
+
parse_text_conditions(operator, value)
|
|
56
|
+
when "FROM", "TO", "AT"
|
|
57
|
+
parse_date_conditions(operator, value)
|
|
58
|
+
else
|
|
59
|
+
raise GetResponse::GetResponseError.new("Bad operator: #{operator}")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
parsed.delete_if { |k, v| v.nil? }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# Parse datetime operators.
|
|
67
|
+
# Example:
|
|
68
|
+
#
|
|
69
|
+
# parse_date_conditions(:from => "2011-10-01")
|
|
70
|
+
# => {"FROM" => "2011-10-01"}
|
|
71
|
+
# parse_date_conditions(:to => 2.days.ago)
|
|
72
|
+
# => {"TO" => "2011-10-28"}
|
|
73
|
+
#
|
|
74
|
+
# operator:: String
|
|
75
|
+
# value:: String, Date, Time
|
|
76
|
+
# returns:: Hash
|
|
77
|
+
def parse_date_conditions(operator, value)
|
|
78
|
+
if value.respond_to?(:strftime)
|
|
79
|
+
{operator => value.strftime("%Y-%m-%d")}
|
|
80
|
+
else
|
|
81
|
+
{operator => value}
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Parse text operators.
|
|
87
|
+
#
|
|
88
|
+
# operator:: String
|
|
89
|
+
# value:: String
|
|
90
|
+
# returns:: Hash
|
|
91
|
+
def parse_text_conditions(operator, value)
|
|
92
|
+
{operator => value}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module GetResponse
|
|
2
|
+
|
|
3
|
+
# GetResponse confirmation body. It can be used in campaign settings.
|
|
4
|
+
class ConfirmationBody
|
|
5
|
+
|
|
6
|
+
attr_reader :id, :plain, :html, :language_code
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def initialize(attributes)
|
|
10
|
+
@id = attributes["id"]
|
|
11
|
+
@plain = attributes["plain"]
|
|
12
|
+
@html = attributes["html"]
|
|
13
|
+
@language_code = attributes["language_code"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module GetResponse
|
|
2
|
+
|
|
3
|
+
# Proxy class for confirmation body operations.
|
|
4
|
+
class ConfirmationBodyProxy
|
|
5
|
+
|
|
6
|
+
include Conditions
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def initialize(connection)
|
|
10
|
+
@connection = connection
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Get list of available bodies for confirmation messages. They can be used in campaign settings.
|
|
15
|
+
# Example:
|
|
16
|
+
#
|
|
17
|
+
# @proxy.all
|
|
18
|
+
# @proxy.all(:language_code => {:equals => "pl"})
|
|
19
|
+
#
|
|
20
|
+
# @param conditions [Hash] conditions passed to query, empty by default
|
|
21
|
+
# @return [Array] collection of <tt>ConfirmationBody</tt> objects returned by API query
|
|
22
|
+
def all(conditions = {})
|
|
23
|
+
conditions = parse_conditions(conditions)
|
|
24
|
+
|
|
25
|
+
response = @connection.send_request("get_confirmation_bodies", conditions)["result"]
|
|
26
|
+
response.inject([]) do |bodies, resp|
|
|
27
|
+
bodies << ConfirmationBody.new(resp[1].merge("id" => resp[0]))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Get single confirmation body based on its <tt>id</tt>. Method can raise
|
|
33
|
+
#<tt>GetResposne::GetResponseError</tt> exception if no confirmation body is found.
|
|
34
|
+
#
|
|
35
|
+
# @param body_id [String]
|
|
36
|
+
# @return [GetResponse::ConfirmationBody]
|
|
37
|
+
def find(body_id)
|
|
38
|
+
params = {"confirmation_body" => body_id}
|
|
39
|
+
resp = @connection.send_request("get_confirmation_body", params)["result"]
|
|
40
|
+
raise GetResponseError.new "Confirmation body with id '#{body_id}' not found." if resp.empty?
|
|
41
|
+
body_attrs = resp.values[0].merge("id" => resp.keys.first)
|
|
42
|
+
ConfirmationBody.new body_attrs
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module GetResponse
|
|
2
|
+
|
|
3
|
+
# GetResponse confirmation subject. It can be used in campaign settings.
|
|
4
|
+
class ConfirmationSubject
|
|
5
|
+
|
|
6
|
+
attr_reader :id, :content, :language_code
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def initialize(attributes)
|
|
10
|
+
@id = attributes["id"]
|
|
11
|
+
@content = attributes["content"]
|
|
12
|
+
@language_code = attributes["language_code"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module GetResponse
|
|
2
|
+
|
|
3
|
+
# Proxy class for confirmation subjects operations.
|
|
4
|
+
class ConfirmationSubjectProxy
|
|
5
|
+
|
|
6
|
+
include Conditions
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def initialize(connection)
|
|
10
|
+
@connection = connection
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Get list of available subjects for confirmation messages. They can be used in campaign settings.
|
|
15
|
+
# Example:
|
|
16
|
+
#
|
|
17
|
+
# @proxy.all
|
|
18
|
+
# @proxy.all(:language_code => {:equals => "pl"})
|
|
19
|
+
#
|
|
20
|
+
# @param conditions [Hash] conditions passed to query, empty by default
|
|
21
|
+
# @return [Array] collection of <tt>ConfirmationSubject</tt> objects returned by API query
|
|
22
|
+
def all(conditions = {})
|
|
23
|
+
conditions = parse_conditions(conditions)
|
|
24
|
+
response = @connection.send_request("get_confirmation_subjects", conditions)["result"]
|
|
25
|
+
response.inject([]) do |bodies, resp|
|
|
26
|
+
bodies << ConfirmationSubject.new(resp[1].merge("id" => resp[0]))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Get single confirmation subject based on its <tt>id</tt>. Method can raise
|
|
32
|
+
#<tt>GetResposne::GetResponseError</tt> exception if no confirmation subject is found.
|
|
33
|
+
#
|
|
34
|
+
# @param subject_id [String]
|
|
35
|
+
# @return [GetResponse::ConfirmationSubject]
|
|
36
|
+
def find(subject_id)
|
|
37
|
+
params = {"confirmation_subject" => subject_id}
|
|
38
|
+
resp = @connection.send_request("get_confirmation_subject", params)["result"]
|
|
39
|
+
raise GetResponseError.new "Confirmation subject with id '#{subject_id}' not found." if resp.empty?
|
|
40
|
+
subject_attrs = resp.values[0].merge("id" => resp.keys.first)
|
|
41
|
+
ConfirmationSubject.new subject_attrs
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -47,6 +47,30 @@ module GetResponse
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
|
|
50
|
+
# Method returns proxy to execute all message related operations.
|
|
51
|
+
#
|
|
52
|
+
# returns:: GetResponse::MessageProxy
|
|
53
|
+
def messages
|
|
54
|
+
@message_proxy ||= GetResponse::MessageProxy.new(self)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# Method returnx proxy to execute all confirmation body related operations.
|
|
59
|
+
#
|
|
60
|
+
# @return [ConfirmationBodyProxy]
|
|
61
|
+
def confirmation_bodies
|
|
62
|
+
@confirmation_body_proxy ||= GetResponse::ConfirmationBodyProxy.new(self)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# Method returnx proxy to execute all confirmation subject related operations.
|
|
67
|
+
#
|
|
68
|
+
# @return [ConfirmationSubjectProxy]
|
|
69
|
+
def confirmation_subjects
|
|
70
|
+
@confirmation_subject_proxy ||= GetResponse::ConfirmationSubjectProxy.new(self)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
50
74
|
# Send request to JSON-RPC service.
|
|
51
75
|
#
|
|
52
76
|
# method:: String
|
data/lib/get_response/contact.rb
CHANGED
|
@@ -2,7 +2,7 @@ module GetResponse
|
|
|
2
2
|
|
|
3
3
|
# GetResponse contact
|
|
4
4
|
class Contact
|
|
5
|
-
attr_accessor :campaign, :name, :email, :cycle_day, :ip, :customs
|
|
5
|
+
attr_accessor :campaign, :name, :email, :cycle_day, :ip, :customs, :created_on, :deleted_on, :reason
|
|
6
6
|
attr_reader :id
|
|
7
7
|
|
|
8
8
|
|
|
@@ -14,6 +14,9 @@ module GetResponse
|
|
|
14
14
|
@ip = params["ip"]
|
|
15
15
|
@customs = parse_customs(params["customs"])
|
|
16
16
|
@id = params["id"]
|
|
17
|
+
@created_on = params["created_on"]
|
|
18
|
+
@deleted_on = params["deleted_on"]
|
|
19
|
+
@reason = params["reason"]
|
|
17
20
|
@connection = connection
|
|
18
21
|
end
|
|
19
22
|
|
|
@@ -64,8 +67,10 @@ module GetResponse
|
|
|
64
67
|
#
|
|
65
68
|
# net_attrs:: Hash
|
|
66
69
|
def update(new_attrs)
|
|
67
|
-
|
|
70
|
+
# Don't save immediately changes
|
|
71
|
+
@lazy_save = true
|
|
68
72
|
|
|
73
|
+
new_attrs.each_pair { |key, value| self.send(key + "=", value) }
|
|
69
74
|
self.save
|
|
70
75
|
end
|
|
71
76
|
|
|
@@ -121,6 +126,27 @@ module GetResponse
|
|
|
121
126
|
end
|
|
122
127
|
|
|
123
128
|
|
|
129
|
+
# List dates when the messages were opened by contact. If a contact opened the same message
|
|
130
|
+
# multiple times, only the oldest date is listed.
|
|
131
|
+
# returns:: Hash
|
|
132
|
+
def opens
|
|
133
|
+
param = {"contact" => @id}
|
|
134
|
+
@connection.send_request("get_contact_opens", param)["result"]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# Set contact name. Method can raise <tt>GetResponseError</tt> exception.
|
|
139
|
+
#
|
|
140
|
+
# @param value [String] new name value
|
|
141
|
+
# @return [String] new name value
|
|
142
|
+
def name=(value)
|
|
143
|
+
unless @lazy_save
|
|
144
|
+
@connection.send_request("set_contact_name", { "contact" => @id, "name" => value })["result"]
|
|
145
|
+
end
|
|
146
|
+
@name = value
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
|
|
124
150
|
protected
|
|
125
151
|
|
|
126
152
|
|
|
@@ -3,6 +3,8 @@ module GetResponse
|
|
|
3
3
|
# Proxy class for contact related operations.
|
|
4
4
|
class ContactProxy
|
|
5
5
|
|
|
6
|
+
include Conditions
|
|
7
|
+
|
|
6
8
|
def initialize(connection)
|
|
7
9
|
@connection = connection
|
|
8
10
|
end
|
|
@@ -33,6 +35,51 @@ module GetResponse
|
|
|
33
35
|
contact
|
|
34
36
|
end
|
|
35
37
|
|
|
38
|
+
|
|
39
|
+
# Get contacts subscription stats aggregated by date, campaign and contact’s origin.
|
|
40
|
+
# Example:
|
|
41
|
+
#
|
|
42
|
+
# # get stats for any camapign, any time period
|
|
43
|
+
# @contact_proxy.statistics
|
|
44
|
+
#
|
|
45
|
+
# # get stats for selected camapigns, any time period
|
|
46
|
+
# @contact_proxy.statistics(:campaigns => ["cmp1", "cmp2"])
|
|
47
|
+
#
|
|
48
|
+
# # get stats for specified date
|
|
49
|
+
# @contact_proxy.statistics(:created_on => {:at => Date.today})
|
|
50
|
+
# @contact_proxy.statistics(:created_on => {:from => "2011-01-01", :to => "2011-12-30"})
|
|
51
|
+
#
|
|
52
|
+
# @param conditions [Hash] conditions for statistics query, empty by default
|
|
53
|
+
# @return [Hash] collection of aggregated statistics
|
|
54
|
+
def statistics(conditions = {})
|
|
55
|
+
conditions = parse_conditions(conditions)
|
|
56
|
+
|
|
57
|
+
@connection.send_request("get_contacts_subscription_stats", conditions)["result"]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Get deleted contacts.
|
|
62
|
+
# Example:
|
|
63
|
+
#
|
|
64
|
+
# # get all deleted contacts
|
|
65
|
+
# @contact_proxy.deleted
|
|
66
|
+
#
|
|
67
|
+
# # get contacts deleted through api
|
|
68
|
+
# @contact_proxy.deleted(:reason => "api")
|
|
69
|
+
#
|
|
70
|
+
# # get deleted contacts from campaign
|
|
71
|
+
# @contact_proxy.deleted(:campaigns => ["campaign_id"])
|
|
72
|
+
#
|
|
73
|
+
# @param conditions [Hash]
|
|
74
|
+
# @return [Array]
|
|
75
|
+
def deleted(conditions = {})
|
|
76
|
+
conditions = parse_conditions(conditions)
|
|
77
|
+
response = @connection.send_request("get_contacts_deleted", conditions)
|
|
78
|
+
response["result"].inject([]) do |contacts, resp|
|
|
79
|
+
contacts << Contact.new(resp[1].merge("id" => resp[0]), @connection)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
36
83
|
end
|
|
37
84
|
|
|
38
85
|
end
|
|
@@ -28,6 +28,20 @@ module GetResponse
|
|
|
28
28
|
FromField.new(attributes.merge("id" => add_result["FROM_FIELD_ID"]))
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
|
|
32
|
+
# Get single from field. Method can raise <tt>GetResponse::GetResponseError</tt> exception when
|
|
33
|
+
# form field with passed <tt>from_field_id</tt> is not found.
|
|
34
|
+
#
|
|
35
|
+
# @param from_field_id [String]
|
|
36
|
+
# @return [FormField]
|
|
37
|
+
def find(from_field_id)
|
|
38
|
+
params = {"account_from_field" => from_field_id}
|
|
39
|
+
resp = @connection.send_request("get_account_from_field", params)["result"]
|
|
40
|
+
raise GetResponseError.new "Form field with id '#{from_field_id}' not found." if resp.empty?
|
|
41
|
+
from_field_attrs = resp.values[0].merge("id" => resp.keys.first)
|
|
42
|
+
FromField.new(from_field_attrs)
|
|
43
|
+
end
|
|
44
|
+
|
|
31
45
|
end
|
|
32
46
|
|
|
33
47
|
end
|
metadata
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: getresponse
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 1
|
|
4
5
|
prerelease: false
|
|
5
6
|
segments:
|
|
6
7
|
- 0
|
|
7
|
-
-
|
|
8
|
-
version: "0.
|
|
8
|
+
- 5
|
|
9
|
+
version: "0.5"
|
|
9
10
|
platform: ruby
|
|
10
11
|
authors:
|
|
11
12
|
- Sebastian Nowak
|
|
@@ -13,16 +14,18 @@ autorequire:
|
|
|
13
14
|
bindir: bin
|
|
14
15
|
cert_chain: []
|
|
15
16
|
|
|
16
|
-
date:
|
|
17
|
+
date: 2012-01-02 00:00:00 +01:00
|
|
17
18
|
default_executable:
|
|
18
19
|
dependencies:
|
|
19
20
|
- !ruby/object:Gem::Dependency
|
|
20
21
|
name: json
|
|
21
22
|
prerelease: false
|
|
22
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
23
25
|
requirements:
|
|
24
26
|
- - ~>
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 7
|
|
26
29
|
segments:
|
|
27
30
|
- 1
|
|
28
31
|
- 4
|
|
@@ -33,9 +36,11 @@ dependencies:
|
|
|
33
36
|
name: json_pure
|
|
34
37
|
prerelease: false
|
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
36
40
|
requirements:
|
|
37
41
|
- - ~>
|
|
38
42
|
- !ruby/object:Gem::Version
|
|
43
|
+
hash: 7
|
|
39
44
|
segments:
|
|
40
45
|
- 1
|
|
41
46
|
- 4
|
|
@@ -46,9 +51,11 @@ dependencies:
|
|
|
46
51
|
name: rr
|
|
47
52
|
prerelease: false
|
|
48
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
54
|
+
none: false
|
|
49
55
|
requirements:
|
|
50
56
|
- - ~>
|
|
51
57
|
- !ruby/object:Gem::Version
|
|
58
|
+
hash: 15
|
|
52
59
|
segments:
|
|
53
60
|
- 1
|
|
54
61
|
- 0
|
|
@@ -64,23 +71,27 @@ extensions: []
|
|
|
64
71
|
extra_rdoc_files: []
|
|
65
72
|
|
|
66
73
|
files:
|
|
67
|
-
- lib/get_response.rb
|
|
68
|
-
- lib/get_response/from_field.rb
|
|
69
|
-
- lib/get_response/domain_proxy.rb
|
|
70
|
-
- lib/get_response/contact_proxy.rb
|
|
71
|
-
- lib/get_response/message_proxy.rb
|
|
72
|
-
- lib/get_response/newsletter.rb
|
|
73
74
|
- lib/get_response/account.rb
|
|
74
|
-
- lib/get_response/contact.rb
|
|
75
|
-
- lib/get_response/campaign_proxy.rb
|
|
76
75
|
- lib/get_response/campaign.rb
|
|
77
|
-
- lib/get_response/
|
|
76
|
+
- lib/get_response/campaign_proxy.rb
|
|
77
|
+
- lib/get_response/conditions.rb
|
|
78
|
+
- lib/get_response/confirmation_body.rb
|
|
79
|
+
- lib/get_response/confirmation_body_proxy.rb
|
|
80
|
+
- lib/get_response/confirmation_subject.rb
|
|
81
|
+
- lib/get_response/confirmation_subject_proxy.rb
|
|
78
82
|
- lib/get_response/connection.rb
|
|
83
|
+
- lib/get_response/contact.rb
|
|
84
|
+
- lib/get_response/contact_proxy.rb
|
|
85
|
+
- lib/get_response/domain.rb
|
|
86
|
+
- lib/get_response/domain_proxy.rb
|
|
79
87
|
- lib/get_response/follow_up.rb
|
|
88
|
+
- lib/get_response/from_field.rb
|
|
80
89
|
- lib/get_response/from_fields_proxy.rb
|
|
81
|
-
- lib/get_response/domain.rb
|
|
82
90
|
- lib/get_response/get_response_error.rb
|
|
83
|
-
- lib/
|
|
91
|
+
- lib/get_response/message.rb
|
|
92
|
+
- lib/get_response/message_proxy.rb
|
|
93
|
+
- lib/get_response/newsletter.rb
|
|
94
|
+
- lib/get_response.rb
|
|
84
95
|
- README.rdoc
|
|
85
96
|
has_rdoc: true
|
|
86
97
|
homepage: http://dev.getresponse.com
|
|
@@ -92,16 +103,20 @@ rdoc_options: []
|
|
|
92
103
|
require_paths:
|
|
93
104
|
- lib
|
|
94
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
|
+
none: false
|
|
95
107
|
requirements:
|
|
96
108
|
- - ">="
|
|
97
109
|
- !ruby/object:Gem::Version
|
|
110
|
+
hash: 3
|
|
98
111
|
segments:
|
|
99
112
|
- 0
|
|
100
113
|
version: "0"
|
|
101
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
none: false
|
|
102
116
|
requirements:
|
|
103
117
|
- - ">="
|
|
104
118
|
- !ruby/object:Gem::Version
|
|
119
|
+
hash: 17
|
|
105
120
|
segments:
|
|
106
121
|
- 1
|
|
107
122
|
- 3
|
|
@@ -110,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
125
|
requirements: []
|
|
111
126
|
|
|
112
127
|
rubyforge_project:
|
|
113
|
-
rubygems_version: 1.3.
|
|
128
|
+
rubygems_version: 1.3.7
|
|
114
129
|
signing_key:
|
|
115
130
|
specification_version: 3
|
|
116
131
|
summary: Ruby wrapper for GetResponse API
|
data/lib/api.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
API_KEY='d333e12e5019b6940127e82b499d75a5'
|