aweber 1.6.0 → 1.6.1
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.textile +20 -0
- data/aweber.gemspec +1 -1
- data/lib/aweber/base.rb +18 -0
- data/lib/aweber/oauth.rb +8 -0
- data/lib/aweber/resources/web_form.rb +3 -0
- data/spec/base_spec.rb +41 -0
- data/spec/fixtures/web_form.json +2 -0
- data/spec/oauth_spec.rb +7 -1
- data/spec/resources/web_form_spec.rb +3 -0
- metadata +2 -2
data/README.textile
CHANGED
|
@@ -67,6 +67,24 @@ oauth = AWeber::OAuth.new('consumer_key', 'consumer_secret')
|
|
|
67
67
|
oauth.authorize_with_access(YOUR_ACCESS_TOKEN, YOUR_ACCESS_TOKEN_SECRET)
|
|
68
68
|
aweber = AWeber::Base.new(oauth)
|
|
69
69
|
|
|
70
|
+
h3. I want to distribute my app as a public app
|
|
71
|
+
|
|
72
|
+
If you intend to distribute your app to many AWeber customers via source code ("See here for more info":https://labs.aweber.com/getting_started/main#app_type), you will want to use the app id to authenticate your app as follows.
|
|
73
|
+
|
|
74
|
+
h4. Build the authorize_app url:
|
|
75
|
+
|
|
76
|
+
bc. require 'aweber'
|
|
77
|
+
app_id = '1XXXXXXX8' #paste you app id from labs.aweber.com here
|
|
78
|
+
auth_url = 'https://auth.aweber.com/1.0/oauth/authorize_app/' + app_id
|
|
79
|
+
puts "please go to " + auth_url
|
|
80
|
+
|
|
81
|
+
h4. Verification Code
|
|
82
|
+
|
|
83
|
+
After you do the above step, it will output a “Verification Code”. Copy this into @authorize_with_authorization_code@
|
|
84
|
+
|
|
85
|
+
bc. aweber = AWeber::Base.authorize_with_authorization_code('My|Authcode|Pasted|Here')
|
|
86
|
+
|
|
87
|
+
You can now use the aweber object to access data from the account that authorized your app!
|
|
70
88
|
|
|
71
89
|
h2. Usage
|
|
72
90
|
|
|
@@ -131,6 +149,8 @@ new_subscriber["name"] = "My New Subscriber"
|
|
|
131
149
|
aweber.account.lists.find_by_name("mylistname").subscribers.create(new_subscriber)
|
|
132
150
|
#Or alternatively: aweber.account.lists[list_id].subscribers.create(new_subscriber)
|
|
133
151
|
|
|
152
|
+
|
|
153
|
+
|
|
134
154
|
h2. Note on Patches/Pull Requests
|
|
135
155
|
|
|
136
156
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/aweber.gemspec
CHANGED
data/lib/aweber/base.rb
CHANGED
|
@@ -35,6 +35,24 @@ module AWeber
|
|
|
35
35
|
"#<AWeber::Base />"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
# Authorize an app with an auth code from 1.0/oauth/authorize_app/app_id
|
|
39
|
+
#
|
|
40
|
+
# @param [string] auth_code The authorization code received from
|
|
41
|
+
# /authorize_app to be used for authorization.
|
|
42
|
+
#
|
|
43
|
+
def self.authorize_with_authorization_code(auth_code)
|
|
44
|
+
consumer_token, consumer_secret, request_token, request_secret, verifier =
|
|
45
|
+
auth_code.split('|')
|
|
46
|
+
oauth = AWeber::OAuth.new(consumer_token, consumer_secret)
|
|
47
|
+
|
|
48
|
+
request_hash = {:oauth_token => request_token, :oauth_token_secret => request_secret}
|
|
49
|
+
request = ::OAuth::RequestToken.from_hash(oauth.consumer, request_hash)
|
|
50
|
+
|
|
51
|
+
oauth.request_token = request
|
|
52
|
+
oauth.authorize_with_verifier(verifier)
|
|
53
|
+
self.new(oauth)
|
|
54
|
+
end
|
|
55
|
+
|
|
38
56
|
private
|
|
39
57
|
|
|
40
58
|
def handle_errors(response, uri)
|
data/lib/aweber/oauth.rb
CHANGED
|
@@ -27,6 +27,14 @@ module AWeber
|
|
|
27
27
|
@request_token ||= consumer.get_request_token(options)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# Set a Request Token
|
|
31
|
+
#
|
|
32
|
+
# @param [Request Token] request_token the oauth request token to be set.
|
|
33
|
+
#
|
|
34
|
+
def request_token=(request_token)
|
|
35
|
+
@request_token = request_token
|
|
36
|
+
end
|
|
37
|
+
|
|
30
38
|
# Get an Access Token from a Request Token using the
|
|
31
39
|
# +verifier+ code.
|
|
32
40
|
#
|
data/spec/base_spec.rb
CHANGED
|
@@ -20,4 +20,45 @@ describe AWeber::Base do
|
|
|
20
20
|
@oauth.should_receive(:get).with("https://api.aweber.com/1.0/foo")
|
|
21
21
|
@aweber.send(:get, "/foo")
|
|
22
22
|
end
|
|
23
|
+
|
|
24
|
+
it "should set oauth request token" do
|
|
25
|
+
oauth_stub = double('oauth consumer')
|
|
26
|
+
oauth_stub.stub(:consumer) { 'consumer' }
|
|
27
|
+
oauth_stub.stub(:request_token=)
|
|
28
|
+
oauth_stub.stub(:authorize_with_verifier) { 'oauth' }
|
|
29
|
+
|
|
30
|
+
rtoken = double('request token')
|
|
31
|
+
rtoken.stub(:params=)
|
|
32
|
+
|
|
33
|
+
oauth_stub.should_receive(:request_token=).with(rtoken)
|
|
34
|
+
AWeber::OAuth.stub(:new) { oauth_stub }
|
|
35
|
+
OAuth::RequestToken.stub(:new) { rtoken }
|
|
36
|
+
|
|
37
|
+
aweber = AWeber::Base.authorize_with_authorization_code('a|b|c|d|verifier')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should delegate authorization to oauth object" do
|
|
41
|
+
oauth_stub = double('oauth consumer')
|
|
42
|
+
oauth_stub.stub(:consumer) { 'consumer' }
|
|
43
|
+
oauth_stub.stub(:request_token=)
|
|
44
|
+
oauth_stub.stub(:authorize_with_verifier) { 'oauth' }
|
|
45
|
+
|
|
46
|
+
oauth_stub.should_receive(:authorize_with_verifier).with('verifier')
|
|
47
|
+
AWeber::OAuth.stub(:new) { oauth_stub }
|
|
48
|
+
aweber = AWeber::Base.authorize_with_authorization_code('a|b|c|d|verifier')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should return new aweber base instance" do
|
|
52
|
+
oauth_stub = double('oauth consumer')
|
|
53
|
+
oauth_stub.stub(:consumer) { 'consumer' }
|
|
54
|
+
oauth_stub.stub(:request_token=)
|
|
55
|
+
oauth_stub.stub(:authorize_with_verifier) { 'oauth' }
|
|
56
|
+
|
|
57
|
+
base_stub = double('aweber base')
|
|
58
|
+
AWeber::Base.stub(:new) { base_stub }
|
|
59
|
+
|
|
60
|
+
AWeber::OAuth.stub(:new) { oauth_stub }
|
|
61
|
+
aweber = AWeber::Base.authorize_with_authorization_code('a|b|c|d|verifier')
|
|
62
|
+
aweber.should == base_stub
|
|
63
|
+
end
|
|
23
64
|
end
|
data/spec/fixtures/web_form.json
CHANGED
|
@@ -10,5 +10,7 @@
|
|
|
10
10
|
"http_etag": "\"be17a3eae7a396181c523ef2709acf2be037f0d8-ca5feee2b7fbb6febfca8af5541541ea960aaedb\"",
|
|
11
11
|
"total_displays": 33,
|
|
12
12
|
"resource_type_link": "https://api.aweber.com/1.0/#web_form",
|
|
13
|
+
"javascript_source_link": "http://forms.aweber.com/form/71/208918171.js",
|
|
14
|
+
"html_source_link": "http://forms.aweber.com/form/71/208918171.htm",
|
|
13
15
|
"id": 208918171
|
|
14
16
|
}
|
data/spec/oauth_spec.rb
CHANGED
|
@@ -44,7 +44,7 @@ describe AWeber::OAuth do
|
|
|
44
44
|
aweber = AWeber::OAuth.new('token', 'secret')
|
|
45
45
|
aweber.request_token.should == rtoken
|
|
46
46
|
end
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
it "should be able to authorize with a verifier code" do
|
|
49
49
|
consumer = double('oauth consumer')
|
|
50
50
|
rtoken = double('request token')
|
|
@@ -88,4 +88,10 @@ describe AWeber::OAuth do
|
|
|
88
88
|
aweber.post("/foo")
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
it "should be able to set a request token" do
|
|
92
|
+
rtoken = double('request token')
|
|
93
|
+
oauth = AWeber::OAuth.new('token', 'secret')
|
|
94
|
+
oauth.request_token = rtoken
|
|
95
|
+
oauth.request_token.should == rtoken
|
|
96
|
+
end
|
|
91
97
|
end
|
|
@@ -18,4 +18,7 @@ describe AWeber::Resources::WebForm do
|
|
|
18
18
|
it { should respond_to :total_unique_displays }
|
|
19
19
|
it { should respond_to :type }
|
|
20
20
|
it { should respond_to :unique_conversion_percentage }
|
|
21
|
+
it { should respond_to :html_source_link }
|
|
22
|
+
it { should respond_to :javascript_source_link }
|
|
23
|
+
|
|
21
24
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aweber
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: oauth
|