getresponse 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +39 -1
- data/lib/api.rb +1 -0
- data/lib/api_key.rb +1 -0
- data/lib/get_response.rb +5 -1
- data/lib/get_response/account.rb +13 -1
- data/lib/get_response/campaign.rb +25 -0
- data/lib/get_response/connection.rb +1 -1
- data/lib/get_response/contact.rb +18 -0
- data/lib/get_response/domain.rb +16 -0
- data/lib/get_response/domain_proxy.rb +23 -0
- data/lib/get_response/from_field.rb +18 -0
- data/lib/get_response/from_fields_proxy.rb +33 -0
- metadata +15 -20
data/README.rdoc
CHANGED
@@ -66,4 +66,42 @@ Set contact cycle
|
|
66
66
|
|
67
67
|
# with connection
|
68
68
|
# contact - existing contact
|
69
|
-
contact.set_cycle(5)
|
69
|
+
contact.set_cycle(5)
|
70
|
+
|
71
|
+
Get custom attributes
|
72
|
+
|
73
|
+
# with connection
|
74
|
+
# contact - existing contact
|
75
|
+
contact.customs
|
76
|
+
=> { "attr_name" => "attr_value" }
|
77
|
+
|
78
|
+
Get account from fields
|
79
|
+
|
80
|
+
# with account
|
81
|
+
# account - existing account
|
82
|
+
account.from_fields.all
|
83
|
+
=> [<FromField: xcv>]
|
84
|
+
|
85
|
+
Add account from field
|
86
|
+
|
87
|
+
# with account
|
88
|
+
# account = existing account
|
89
|
+
account.from_fields.create("name" => "My new name", "email" => "my_new_email@foo.bar")
|
90
|
+
=> #<GetResponse::FromField:0xb7727010 ... >
|
91
|
+
|
92
|
+
Get account domains
|
93
|
+
|
94
|
+
# with account
|
95
|
+
# account - existing account
|
96
|
+
account.domains.all
|
97
|
+
|
98
|
+
Get campaign domain
|
99
|
+
|
100
|
+
# with campaign
|
101
|
+
# campaign - existing campaign
|
102
|
+
campaign.domain
|
103
|
+
|
104
|
+
Set campaign domain
|
105
|
+
|
106
|
+
domain = account.domains.first
|
107
|
+
campaign.domain = domain
|
data/lib/api.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
API_KEY='d333e12e5019b6940127e82b499d75a5'
|
data/lib/api_key.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
API_KEY='d333e12e5019b6940127e82b499d75a5'
|
data/lib/get_response.rb
CHANGED
@@ -49,4 +49,8 @@ GetResponse.autoload :Connection, "get_response/connection"
|
|
49
49
|
GetResponse.autoload :Contact, "get_response/contact"
|
50
50
|
GetResponse.autoload :Message, "get_response/message"
|
51
51
|
GetResponse.autoload :CampaignProxy, "get_response/campaign_proxy"
|
52
|
-
GetResponse.autoload :ContactProxy, "get_response/contact_proxy"
|
52
|
+
GetResponse.autoload :ContactProxy, "get_response/contact_proxy"
|
53
|
+
GetResponse.autoload :FromField, "get_response/from_field"
|
54
|
+
GetResponse.autoload :FromFieldsProxy, "get_response/from_fields_proxy"
|
55
|
+
GetResponse.autoload :Domain, "get_response/domain"
|
56
|
+
GetResponse.autoload :DomainProxy, "get_response/domain_proxy"
|
data/lib/get_response/account.rb
CHANGED
@@ -5,11 +5,23 @@ module GetResponse
|
|
5
5
|
attr_reader :login, :name, :email, :created_on
|
6
6
|
|
7
7
|
|
8
|
-
def initialize(params)
|
8
|
+
def initialize(params, connection)
|
9
9
|
@login = params["login"]
|
10
10
|
@name = params["from_name"]
|
11
11
|
@email = params["from_email"]
|
12
12
|
@created_on = params["created_on"]
|
13
|
+
@connection = connection
|
13
14
|
end
|
15
|
+
|
16
|
+
|
17
|
+
def from_fields
|
18
|
+
FromFieldsProxy.new(@connection)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def domains
|
23
|
+
DomainProxy.new(@connection)
|
24
|
+
end
|
25
|
+
|
14
26
|
end
|
15
27
|
end
|
@@ -24,6 +24,31 @@ module GetResponse
|
|
24
24
|
@contact_proxy.all(:campaigns => [@id])
|
25
25
|
end
|
26
26
|
|
27
|
+
|
28
|
+
# Get domain assigned to this campaign.
|
29
|
+
#
|
30
|
+
# returns:: GetResponse::Domain
|
31
|
+
def domain
|
32
|
+
params = {"campaign" => self.id}
|
33
|
+
domain = @connection.send_request("get_campaign_domain", params)["result"].map do |id, attrs|
|
34
|
+
Domain.new(attrs.merge("id" => id))
|
35
|
+
end
|
36
|
+
domain.first
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# Set domain for this campaign.
|
41
|
+
#
|
42
|
+
# new_domain:: GetResponse::Domain
|
43
|
+
# returns:: GetResponse::Domain
|
44
|
+
def domain=(new_domain)
|
45
|
+
params = { "domain" => new_domain.id, "campaign" => self.id }
|
46
|
+
|
47
|
+
# there will be an exception if bad ids sent
|
48
|
+
@connection.send_request("set_campaign_domain", params)
|
49
|
+
new_domain
|
50
|
+
end
|
51
|
+
|
27
52
|
end
|
28
53
|
|
29
54
|
end
|
data/lib/get_response/contact.rb
CHANGED
@@ -103,6 +103,24 @@ module GetResponse
|
|
103
103
|
end
|
104
104
|
|
105
105
|
|
106
|
+
# Get list of custom attributes. It performs additional API request to fetch attributes. By
|
107
|
+
# default new contacts has en empty custom attributes list.
|
108
|
+
#
|
109
|
+
# returns:: Hash
|
110
|
+
def customs
|
111
|
+
@connection.send_request("get_contact_customs", { "contact" => @id })["result"]
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
# Set custom attributes in contact instance. After set attributes you _must_ save contact.
|
116
|
+
#
|
117
|
+
# value:: Hash
|
118
|
+
# returns:: Hash
|
119
|
+
def customs=(value)
|
120
|
+
@customs = parse_customs(value)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
106
124
|
protected
|
107
125
|
|
108
126
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GetResponse
|
2
|
+
|
3
|
+
# Domain connected with account or campaign in GetResponse
|
4
|
+
class Domain
|
5
|
+
|
6
|
+
attr_reader :id, :domain, :created_on
|
7
|
+
|
8
|
+
def initialize(attributes)
|
9
|
+
@id = attributes["id"]
|
10
|
+
@domain = attributes["domain"]
|
11
|
+
@created_on = attributes["created_on"]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module GetResponse
|
2
|
+
|
3
|
+
# Proxy class for domain operations.
|
4
|
+
class DomainProxy
|
5
|
+
|
6
|
+
def initialize(connection)
|
7
|
+
@connection = connection
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
# Get all domains connected with account.
|
12
|
+
#
|
13
|
+
# returns:: [GetResponse::Domain]
|
14
|
+
def all
|
15
|
+
domains_attrs = @connection.send_request("get_account_domains")["result"]
|
16
|
+
domains_attrs.map do |id, attrs|
|
17
|
+
GetResponse::Domain.new(attrs.merge("id" => id))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module GetResponse
|
2
|
+
|
3
|
+
# Form field connected with account.
|
4
|
+
class FromField
|
5
|
+
|
6
|
+
attr_reader :id, :name, :email, :created_on
|
7
|
+
|
8
|
+
|
9
|
+
def initialize(params)
|
10
|
+
@id = params["id"]
|
11
|
+
@name = params["name"]
|
12
|
+
@email = params["email"]
|
13
|
+
@created_on = params["created_on"]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module GetResponse
|
2
|
+
|
3
|
+
# Proxy class from all from fields operations.
|
4
|
+
class FromFieldsProxy
|
5
|
+
|
6
|
+
def initialize(connection)
|
7
|
+
@connection = connection
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
# Fetch all from fields connected with account
|
12
|
+
#
|
13
|
+
# returns:: [FromFields]
|
14
|
+
def all
|
15
|
+
from_fields_attrs = @connection.send_request("get_account_from_fields")["result"]
|
16
|
+
from_fields_attrs.map do |id, attrs|
|
17
|
+
FromField.new(attrs.merge("id" => id))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Create new from field connection with account. Method returns new instance of <tt>FromField</tt>
|
23
|
+
# if new from field was saved or raise <tt>GetResponseError</tt> if not.
|
24
|
+
#
|
25
|
+
# returns:: FromField
|
26
|
+
def create(attributes)
|
27
|
+
add_result = @connection.send_request("add_account_from_field", attributes)["result"]
|
28
|
+
FromField.new(attributes.merge("id" => add_result["FROM_FIELD_ID"]))
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getresponse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
7
|
+
- 3
|
8
|
+
version: "0.3"
|
10
9
|
platform: ruby
|
11
10
|
authors:
|
12
11
|
- Sebastian Nowak
|
@@ -14,18 +13,16 @@ autorequire:
|
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
15
|
|
17
|
-
date:
|
16
|
+
date: 2011-02-02 00:00:00 +01:00
|
18
17
|
default_executable:
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
21
20
|
name: json
|
22
21
|
prerelease: false
|
23
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
23
|
requirements:
|
26
24
|
- - ~>
|
27
25
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 7
|
29
26
|
segments:
|
30
27
|
- 1
|
31
28
|
- 4
|
@@ -36,11 +33,9 @@ dependencies:
|
|
36
33
|
name: json_pure
|
37
34
|
prerelease: false
|
38
35
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
37
|
- - ~>
|
42
38
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 7
|
44
39
|
segments:
|
45
40
|
- 1
|
46
41
|
- 4
|
@@ -51,11 +46,9 @@ dependencies:
|
|
51
46
|
name: rr
|
52
47
|
prerelease: false
|
53
48
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
49
|
requirements:
|
56
50
|
- - ~>
|
57
51
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 15
|
59
52
|
segments:
|
60
53
|
- 1
|
61
54
|
- 0
|
@@ -71,15 +64,21 @@ extensions: []
|
|
71
64
|
extra_rdoc_files: []
|
72
65
|
|
73
66
|
files:
|
67
|
+
- lib/get_response.rb
|
68
|
+
- lib/api_key.rb
|
69
|
+
- lib/get_response/from_field.rb
|
70
|
+
- lib/get_response/domain_proxy.rb
|
71
|
+
- lib/get_response/contact_proxy.rb
|
74
72
|
- lib/get_response/account.rb
|
75
|
-
- lib/get_response/
|
73
|
+
- lib/get_response/contact.rb
|
76
74
|
- lib/get_response/campaign_proxy.rb
|
75
|
+
- lib/get_response/campaign.rb
|
76
|
+
- lib/get_response/message.rb
|
77
77
|
- lib/get_response/connection.rb
|
78
|
-
- lib/get_response/
|
79
|
-
- lib/get_response/
|
78
|
+
- lib/get_response/from_fields_proxy.rb
|
79
|
+
- lib/get_response/domain.rb
|
80
80
|
- lib/get_response/get_response_error.rb
|
81
|
-
- lib/
|
82
|
-
- lib/get_response.rb
|
81
|
+
- lib/api.rb
|
83
82
|
- README.rdoc
|
84
83
|
has_rdoc: true
|
85
84
|
homepage: http://dev.getresponse.com
|
@@ -91,20 +90,16 @@ rdoc_options: []
|
|
91
90
|
require_paths:
|
92
91
|
- lib
|
93
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
93
|
requirements:
|
96
94
|
- - ">="
|
97
95
|
- !ruby/object:Gem::Version
|
98
|
-
hash: 3
|
99
96
|
segments:
|
100
97
|
- 0
|
101
98
|
version: "0"
|
102
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
100
|
requirements:
|
105
101
|
- - ">="
|
106
102
|
- !ruby/object:Gem::Version
|
107
|
-
hash: 17
|
108
103
|
segments:
|
109
104
|
- 1
|
110
105
|
- 3
|
@@ -113,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
108
|
requirements: []
|
114
109
|
|
115
110
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.3.
|
111
|
+
rubygems_version: 1.3.6
|
117
112
|
signing_key:
|
118
113
|
specification_version: 3
|
119
114
|
summary: Ruby wrapper for GetResponse API
|