aweber 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.textile +38 -4
- data/aweber.gemspec +3 -3
- data/lib/aweber/collection.rb +4 -5
- data/lib/aweber/oauth.rb +1 -4
- data/spec/oauth_spec.rb +0 -5
- data/spec/spec_helper.rb +2 -2
- metadata +84 -89
data/LICENSE
CHANGED
data/README.textile
CHANGED
@@ -32,7 +32,11 @@ h4. Authorize an Account
|
|
32
32
|
|
33
33
|
Open, what the following outputs, in a browser and use your AWeber account credentials. This will give your app permission to work with your account's data:
|
34
34
|
|
35
|
-
bc. oauth.request_token.
|
35
|
+
bc. oauth.request_token.authorize_url
|
36
|
+
|
37
|
+
A callback url may also be passed by setting the :oauth_callback parameter:
|
38
|
+
|
39
|
+
bc. oauth.request_token(:oauth_callback => 'http://www.example.com').authorize_url
|
36
40
|
|
37
41
|
h4. Verification Code
|
38
42
|
|
@@ -44,7 +48,25 @@ h4. Grab an AWeber::Base
|
|
44
48
|
|
45
49
|
bc. aweber = AWeber::Base.new(oauth)
|
46
50
|
|
47
|
-
This object is how you access data from your account. @aweber.account@ is your account object which is the stem for all other resources.
|
51
|
+
This object is how you access data from your account. @aweber.account@ is your account object which is the stem for all other resources.
|
52
|
+
|
53
|
+
h4. What if I don't want to verify every time?
|
54
|
+
|
55
|
+
After verifying once, the @oauth@ object contains an @oauth.access_token.token@ and and @oauth.access_token.secret@ which may be used to authorize your application without having to verify via url:
|
56
|
+
|
57
|
+
bc. ...
|
58
|
+
oauth.authorize_with_verifier('verification_code')
|
59
|
+
puts 'Access token: ' + oauth.access_token.token
|
60
|
+
puts 'Access token secret: ' + oauth.access_token.secret
|
61
|
+
|
62
|
+
The token and secret can then be saved, and authorization can be performed as follows:
|
63
|
+
|
64
|
+
bc. require 'aweber'
|
65
|
+
oauth = AWeber::OAuth.new('consumer_key', 'consumer_secret')
|
66
|
+
#Rather than authorizing with the verification code, we use the token and secret
|
67
|
+
oauth.authorize_with_access(YOUR_ACCESS_TOKEN, YOUR_ACCESS_TOKEN_SECRET)
|
68
|
+
aweber = AWeber::Base.new(oauth)
|
69
|
+
|
48
70
|
|
49
71
|
h2. Usage
|
50
72
|
|
@@ -53,7 +75,7 @@ h3. Resource Traversal
|
|
53
75
|
Getting resource data is much like traversing associations in ActiveRecord. Everything starts with the @account@ object and goes from there:
|
54
76
|
|
55
77
|
bc.. aweber.account.lists #=> #<AWeber::Collection>
|
56
|
-
aweber.account.lists[123] #=> #<AWeber::Resource::List>
|
78
|
+
aweber.account.lists[123] #=> #<AWeber::Resource::List> #123 represents the list id
|
57
79
|
aweber.account.lists[123].name #=> "WhateverList"
|
58
80
|
|
59
81
|
h3. Collections
|
@@ -72,6 +94,10 @@ Resources are elements of a Collection. A single list resource would be retrieve
|
|
72
94
|
|
73
95
|
bc. aweber.account.lists[1234]
|
74
96
|
|
97
|
+
h3. Why can't I access the subscriber data?
|
98
|
+
|
99
|
+
If you are unable to access the data associated with your subscribers, it is likely that you have not enabled subscriber access permissions for your application. To do so, follow the directions at: https://labs.aweber.com/docs/permissions. These changes won't take effect until you renew your access tokens.
|
100
|
+
|
75
101
|
h2. Updating Resources
|
76
102
|
|
77
103
|
Currently, subscribers are the only resource you can update via the API. Everything else is read only for the time being.
|
@@ -97,6 +123,14 @@ bc. subscriber = account.lists[654321].subscribers[123456]
|
|
97
123
|
subscriber.name = "New Name"
|
98
124
|
subscriber.save
|
99
125
|
|
126
|
+
h2. Adding Subscribers
|
127
|
+
|
128
|
+
bc. new_subscriber = {}
|
129
|
+
new_subscriber["email"] = "fake@example.com"
|
130
|
+
new_subscriber["name"] = "My New Subscriber"
|
131
|
+
aweber.account.lists.find_by_name("mylistname").subscribers.create(new_subscriber)]
|
132
|
+
#Or alternatively: aweber.account.lists[list_id].subscribers.create(new_subscriber)]
|
133
|
+
|
100
134
|
h2. Note on Patches/Pull Requests
|
101
135
|
|
102
136
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
@@ -109,4 +143,4 @@ h2. Note on Patches/Pull Requests
|
|
109
143
|
|
110
144
|
h2. Copyright
|
111
145
|
|
112
|
-
Copyright (c) 2010-
|
146
|
+
Copyright (c) 2010-2012 AWeber Communications, Inc. See LICENSE for more detail.
|
data/aweber.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "aweber"
|
4
|
-
s.version = "1.
|
4
|
+
s.version = "1.4.0"
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.summary = "Ruby interface to AWeber's API"
|
7
7
|
s.description = "Ruby interface to AWeber's API"
|
@@ -17,10 +17,10 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.extra_rdoc_files = ["LICENSE", "README.textile"]
|
18
18
|
|
19
19
|
s.add_dependency "oauth"
|
20
|
-
s.add_dependency "
|
20
|
+
s.add_dependency "json"
|
21
21
|
|
22
22
|
s.add_development_dependency "fakeweb"
|
23
|
-
s.add_development_dependency "rspec", "~> 2.
|
23
|
+
s.add_development_dependency "rspec", "~> 2.11.0"
|
24
24
|
s.add_development_dependency "yard", "~> 0.6.0"
|
25
25
|
end
|
26
26
|
|
data/lib/aweber/collection.rb
CHANGED
@@ -62,13 +62,12 @@ module AWeber
|
|
62
62
|
def create(attrs={})
|
63
63
|
params = attrs.merge("ws.op" => "create")
|
64
64
|
response = client.post(path, params)
|
65
|
-
|
65
|
+
|
66
66
|
return false unless response.is_a? Net::HTTPCreated
|
67
|
-
|
68
|
-
response = JSON.parse(response.body)
|
67
|
+
|
69
68
|
resource = get(response["location"]).merge(:parent => self)
|
70
69
|
resource = @klass.new(client, resource)
|
71
|
-
|
70
|
+
|
72
71
|
self[resource.id] = resource
|
73
72
|
end
|
74
73
|
|
@@ -144,4 +143,4 @@ module AWeber
|
|
144
143
|
end
|
145
144
|
|
146
145
|
end
|
147
|
-
end
|
146
|
+
end
|
data/lib/aweber/oauth.rb
CHANGED
@@ -4,12 +4,9 @@ module AWeber
|
|
4
4
|
|
5
5
|
def_delegators :access_token, :get, :post, :put, :delete
|
6
6
|
|
7
|
-
attr_accessor :callback_url
|
8
|
-
|
9
7
|
def initialize(consumer_token, consumer_secret, options={})
|
10
8
|
@consumer_token = consumer_token
|
11
9
|
@consumer_secret = consumer_secret
|
12
|
-
@callback_url = options[:callback_url]
|
13
10
|
end
|
14
11
|
|
15
12
|
def consumer
|
@@ -66,4 +63,4 @@ module AWeber
|
|
66
63
|
@access_token = nil
|
67
64
|
end
|
68
65
|
end
|
69
|
-
end
|
66
|
+
end
|
data/spec/oauth_spec.rb
CHANGED
@@ -45,11 +45,6 @@ describe AWeber::OAuth do
|
|
45
45
|
aweber.request_token.should == rtoken
|
46
46
|
end
|
47
47
|
|
48
|
-
it "should set the callback url" do
|
49
|
-
oauth = AWeber::OAuth.new('token', 'secret', :callback_url => "http://example.com")
|
50
|
-
oauth.callback_url.should == "http://example.com"
|
51
|
-
end
|
52
|
-
|
53
48
|
it "should be able to authorize with a verifier code" do
|
54
49
|
consumer = double('oauth consumer')
|
55
50
|
rtoken = double('request token')
|
data/spec/spec_helper.rb
CHANGED
@@ -55,5 +55,5 @@ route :get, %r[/accounts/\d+/lists/\d+/campaigns/[\d\w]+/messages\?], fixture("m
|
|
55
55
|
route :get, %r[/accounts/\d+/lists/\d+/campaigns/[\d\w]+/messages/\d+/opens\?], fixture("opens.json")
|
56
56
|
route :get, %r[/accounts/\d+/lists/\d+/campaigns/[\d\w]+/messages/\d+/tracked_events\?], fixture("tracked_events.json")
|
57
57
|
|
58
|
-
route :post, %r[/accounts/\d+/lists\?],
|
59
|
-
route :post, %r[/accounts/\d+/lists/\d+/subscribers/\d+], "201 Created", :status => ["201", "Created"]
|
58
|
+
route :post, %r[/accounts/\d+/lists\?], '', :location => 'https://api.aweber.com/1.0/accounts/1/lists/1550679', :status => ["201", "Created"]
|
59
|
+
route :post, %r[/accounts/\d+/lists/\d+/subscribers/\d+], "201 Created", :status => ["201", "Created"]
|
metadata
CHANGED
@@ -1,101 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: aweber
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 3
|
8
|
-
- 1
|
9
|
-
version: 1.3.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- AWeber Communications, Inc.
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: oauth
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: json_pure
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
37
33
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
44
38
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: fakeweb
|
48
39
|
prerelease: false
|
49
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
41
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
|
56
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fakeweb
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
57
54
|
type: :development
|
58
|
-
version_requirements: *id003
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: rspec
|
61
55
|
prerelease: false
|
62
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
63
65
|
none: false
|
64
|
-
requirements:
|
66
|
+
requirements:
|
65
67
|
- - ~>
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
- 2
|
69
|
-
- 1
|
70
|
-
- 0
|
71
|
-
version: 2.1.0
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.11.0
|
72
70
|
type: :development
|
73
|
-
version_requirements: *id004
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: yard
|
76
71
|
prerelease: false
|
77
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.11.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: yard
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
78
81
|
none: false
|
79
|
-
requirements:
|
82
|
+
requirements:
|
80
83
|
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
- 6
|
85
|
-
- 0
|
84
|
+
- !ruby/object:Gem::Version
|
86
85
|
version: 0.6.0
|
87
86
|
type: :development
|
88
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.6.0
|
89
94
|
description: Ruby interface to AWeber's API
|
90
95
|
email: help@aweber.com
|
91
96
|
executables: []
|
92
|
-
|
93
97
|
extensions: []
|
94
|
-
|
95
|
-
extra_rdoc_files:
|
98
|
+
extra_rdoc_files:
|
96
99
|
- LICENSE
|
97
100
|
- README.textile
|
98
|
-
files:
|
101
|
+
files:
|
99
102
|
- .document
|
100
103
|
- .gitignore
|
101
104
|
- Gemfile
|
@@ -175,39 +178,31 @@ files:
|
|
175
178
|
- spec/resources/web_form_split_test_spec.rb
|
176
179
|
- spec/spec_helper.rb
|
177
180
|
- spec/support/fake_classes.rb
|
178
|
-
has_rdoc: true
|
179
181
|
homepage: http://github.com/aweber/AWeber-API-Ruby-Library
|
180
182
|
licenses: []
|
181
|
-
|
182
183
|
post_install_message:
|
183
184
|
rdoc_options: []
|
184
|
-
|
185
|
-
require_paths:
|
185
|
+
require_paths:
|
186
186
|
- lib
|
187
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
188
188
|
none: false
|
189
|
-
requirements:
|
190
|
-
- -
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
|
193
|
-
|
194
|
-
version: "0"
|
195
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ! '>='
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
194
|
none: false
|
197
|
-
requirements:
|
198
|
-
- -
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
|
201
|
-
- 0
|
202
|
-
version: "0"
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
203
199
|
requirements: []
|
204
|
-
|
205
200
|
rubyforge_project:
|
206
|
-
rubygems_version: 1.
|
201
|
+
rubygems_version: 1.8.24
|
207
202
|
signing_key:
|
208
203
|
specification_version: 3
|
209
204
|
summary: Ruby interface to AWeber's API
|
210
|
-
test_files:
|
205
|
+
test_files:
|
211
206
|
- spec/base_spec.rb
|
212
207
|
- spec/collection_spec.rb
|
213
208
|
- spec/fixtures/account.json
|