chubasaweber 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/README.textile +65 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/aweber.gemspec +53 -0
- data/chubasaweber.gemspec +144 -0
- data/examples/with_access_token.rb +17 -0
- data/examples/your_account.rb +26 -0
- data/lib/aweber.rb +66 -0
- data/lib/aweber/base.rb +57 -0
- data/lib/aweber/collection.rb +110 -0
- data/lib/aweber/oauth.rb +69 -0
- data/lib/aweber/resource.rb +131 -0
- data/lib/aweber/resources.rb +14 -0
- data/lib/aweber/resources/account.rb +14 -0
- data/lib/aweber/resources/broadcast.rb +29 -0
- data/lib/aweber/resources/click.rb +13 -0
- data/lib/aweber/resources/followup.rb +24 -0
- data/lib/aweber/resources/integration.rb +8 -0
- data/lib/aweber/resources/link.rb +12 -0
- data/lib/aweber/resources/list.rb +86 -0
- data/lib/aweber/resources/message.rb +20 -0
- data/lib/aweber/resources/open.rb +10 -0
- data/lib/aweber/resources/subscriber.rb +28 -0
- data/lib/aweber/resources/tracked_event.rb +13 -0
- data/lib/aweber/resources/web_form.rb +14 -0
- data/lib/aweber/resources/web_form_split_test.rb +11 -0
- data/lib/aweber/resources/web_form_split_test_component.rb +20 -0
- data/lib/chubasaweber.rb +66 -0
- data/spec/base_spec.rb +23 -0
- data/spec/collection_spec.rb +40 -0
- data/spec/fixtures/account.json +8 -0
- data/spec/fixtures/accounts.json +13 -0
- data/spec/fixtures/campaign.json +23 -0
- data/spec/fixtures/campaigns.json +106 -0
- data/spec/fixtures/click.json +9 -0
- data/spec/fixtures/clicks.json +14 -0
- data/spec/fixtures/integration.json +8 -0
- data/spec/fixtures/integrations.json +45 -0
- data/spec/fixtures/link.json +10 -0
- data/spec/fixtures/links.json +75 -0
- data/spec/fixtures/list.json +11 -0
- data/spec/fixtures/lists.json +38 -0
- data/spec/fixtures/message.json +12 -0
- data/spec/fixtures/messages.json +29 -0
- data/spec/fixtures/open.json +8 -0
- data/spec/fixtures/opens.json +21 -0
- data/spec/fixtures/subscriber.json +16 -0
- data/spec/fixtures/subscribers.json +69 -0
- data/spec/fixtures/tracked_event.json +8 -0
- data/spec/fixtures/tracked_events.json +21 -0
- data/spec/fixtures/web_form.json +14 -0
- data/spec/fixtures/web_form_split_test.json +9 -0
- data/spec/fixtures/web_form_split_test_component.json +16 -0
- data/spec/fixtures/web_form_split_test_components.json +37 -0
- data/spec/fixtures/web_form_split_tests.json +41 -0
- data/spec/fixtures/web_forms.json +229 -0
- data/spec/oauth_spec.rb +96 -0
- data/spec/resource_spec.rb +80 -0
- data/spec/resources/account_spec.rb +13 -0
- data/spec/resources/campaign_spec.rb +14 -0
- data/spec/resources/click_spec.rb +14 -0
- data/spec/resources/integration_spec.rb +13 -0
- data/spec/resources/link_spec.rb +15 -0
- data/spec/resources/list_spec.rb +26 -0
- data/spec/resources/message_spec.rb +17 -0
- data/spec/resources/open_spec.rb +13 -0
- data/spec/resources/subscriber_spec.rb +33 -0
- data/spec/resources/tracked_event_spec.rb +14 -0
- data/spec/resources/web_form_spec.rb +19 -0
- data/spec/resources/web_form_split_test_component_spec.rb +20 -0
- data/spec/resources/web_form_split_test_spec.rb +14 -0
- data/spec/spec_helper.rb +52 -0
- data/test/helper.rb +10 -0
- data/test/test_chubasaweber.rb +7 -0
- metadata +181 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 AWeber Communications, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= chubasaweber
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 kazuyoshi tlacaelel. See LICENSE for details.
|
data/README.textile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
h1. AWeber API Gem
|
2
|
+
|
3
|
+
Official AWeber API gem.
|
4
|
+
|
5
|
+
h2. Installation
|
6
|
+
|
7
|
+
* @gem install aweber@
|
8
|
+
|
9
|
+
h2. Quick Start
|
10
|
+
|
11
|
+
First, go to "http://labs.aweber.com":http://labs.aweber.com and sign up for a free AWeber Labs account. This is how you register apps and get OAuth keys.
|
12
|
+
|
13
|
+
bc.. # Register an app and use it's Consumer key and secret:
|
14
|
+
oauth = AWeber::OAuth.new("consumer_key", "consumer_secret")
|
15
|
+
|
16
|
+
# Go to the URL the following outputs.
|
17
|
+
oauth.request_token.authorize_url
|
18
|
+
|
19
|
+
# Authorize your account and copy the verification code.
|
20
|
+
oauth.authorize_with_verifier("verification_code")
|
21
|
+
|
22
|
+
# Grab an AWeber::Base object and get movin'
|
23
|
+
aweber = AWeber::Base.new(oauth)
|
24
|
+
aweber.account.lists[123456].name
|
25
|
+
|
26
|
+
p. Take a look at "examples":http://github.com/aweber/aweber-ruby/tree/master/examples/ for more examples.
|
27
|
+
|
28
|
+
h2. Getting Data
|
29
|
+
|
30
|
+
Every piece of data from AWeber's API stems from an Account object. From there you access associated resources in the same way you would an ActiveRecord accosication:
|
31
|
+
|
32
|
+
bc. account.lists #=> #<AWeber::Collection(AWeber::Resource::List)>
|
33
|
+
account.lists[1] #=> #<AWeber::Resource::List>
|
34
|
+
|
35
|
+
h2. Modifying Subscribers
|
36
|
+
|
37
|
+
Currently, only certain attributes of Subscribers are writable:
|
38
|
+
|
39
|
+
* name
|
40
|
+
* misc_notes
|
41
|
+
* email (yes email)
|
42
|
+
* status
|
43
|
+
* last_followup_message_number_sent
|
44
|
+
* custom_fields (Hash of key/value pairs)
|
45
|
+
* ad_tracking
|
46
|
+
|
47
|
+
h3. Example
|
48
|
+
|
49
|
+
bc. subscriber = account.lists[654321].subscribers[123456]
|
50
|
+
subscriber.name = "New Name"
|
51
|
+
subscriber.save
|
52
|
+
|
53
|
+
h2. Note on Patches/Pull Requests
|
54
|
+
|
55
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
56
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
57
|
+
* Fork the project
|
58
|
+
* Start a feature/bugfix branch
|
59
|
+
* Commit and push until you are happy with your contribution
|
60
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
61
|
+
* Please try not to mess with the Rakefile or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
62
|
+
|
63
|
+
h2. Copyright
|
64
|
+
|
65
|
+
Copyright (c) 2010 AWeber Communications, Inc. See LICENSE for more detail.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "chubasaweber"
|
8
|
+
gem.summary = %Q{A cubas aweber}
|
9
|
+
gem.description = %Q{a chubas aweber}
|
10
|
+
gem.email = "kazu.dev@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/ktlacaelel/chubasaweber"
|
12
|
+
gem.authors = ["kazuyoshi tlacaelel"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "chubasaweber #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/aweber.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = "aweber"
|
4
|
+
s.version = "1.1.0"
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.summary = "Ruby interface to AWeber's API"
|
7
|
+
s.description = "Ruby interface to AWeber's API"
|
8
|
+
|
9
|
+
s.author = "AWeber Communications, Inc."
|
10
|
+
s.email = "help@aweber.com"
|
11
|
+
s.homepage = "http://github.com/aweber/AWeber-API-Ruby-Library"
|
12
|
+
|
13
|
+
s.require_path = "lib"
|
14
|
+
s.files = [
|
15
|
+
"aweber.gemspec",
|
16
|
+
"examples/with_access_token.rb",
|
17
|
+
"examples/your_account.rb",
|
18
|
+
"Gemfile",
|
19
|
+
"lib/aweber.rb",
|
20
|
+
"lib/aweber/base.rb",
|
21
|
+
"lib/aweber/collection.rb",
|
22
|
+
"lib/aweber/oauth.rb",
|
23
|
+
"lib/aweber/resource.rb",
|
24
|
+
"lib/aweber/resources.rb",
|
25
|
+
"lib/aweber/resources/account.rb",
|
26
|
+
"lib/aweber/resources/broadcast.rb",
|
27
|
+
"lib/aweber/resources/click.rb",
|
28
|
+
"lib/aweber/resources/followup.rb",
|
29
|
+
"lib/aweber/resources/integration.rb",
|
30
|
+
"lib/aweber/resources/link.rb",
|
31
|
+
"lib/aweber/resources/list.rb",
|
32
|
+
"lib/aweber/resources/message.rb",
|
33
|
+
"lib/aweber/resources/open.rb",
|
34
|
+
"lib/aweber/resources/subscriber.rb",
|
35
|
+
"lib/aweber/resources/tracked_event.rb",
|
36
|
+
"lib/aweber/resources/web_form.rb",
|
37
|
+
"lib/aweber/resources/web_form_split_test.rb",
|
38
|
+
"lib/aweber/resources/web_form_split_test_component.rb",
|
39
|
+
"LICENSE",
|
40
|
+
"Rakefile",
|
41
|
+
"README.textile",
|
42
|
+
]
|
43
|
+
|
44
|
+
s.test_files = Dir["spec/**/*"]
|
45
|
+
s.extra_rdoc_files = ["LICENSE", "README.textile"]
|
46
|
+
|
47
|
+
s.add_dependency "oauth"
|
48
|
+
|
49
|
+
s.add_development_dependency "fakeweb"
|
50
|
+
s.add_development_dependency "rspec", "~> 2.1.0"
|
51
|
+
s.add_development_dependency "yard", "~> 0.6.0"
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{chubasaweber}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["kazuyoshi tlacaelel"]
|
12
|
+
s.date = %q{2011-07-20}
|
13
|
+
s.description = %q{a chubas aweber}
|
14
|
+
s.email = %q{kazu.dev@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc",
|
18
|
+
"README.textile"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".gitignore",
|
23
|
+
"Gemfile",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"README.textile",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"aweber.gemspec",
|
30
|
+
"chubasaweber.gemspec",
|
31
|
+
"examples/with_access_token.rb",
|
32
|
+
"examples/your_account.rb",
|
33
|
+
"lib/aweber.rb",
|
34
|
+
"lib/aweber/base.rb",
|
35
|
+
"lib/aweber/collection.rb",
|
36
|
+
"lib/aweber/oauth.rb",
|
37
|
+
"lib/aweber/resource.rb",
|
38
|
+
"lib/aweber/resources.rb",
|
39
|
+
"lib/aweber/resources/account.rb",
|
40
|
+
"lib/aweber/resources/broadcast.rb",
|
41
|
+
"lib/aweber/resources/click.rb",
|
42
|
+
"lib/aweber/resources/followup.rb",
|
43
|
+
"lib/aweber/resources/integration.rb",
|
44
|
+
"lib/aweber/resources/link.rb",
|
45
|
+
"lib/aweber/resources/list.rb",
|
46
|
+
"lib/aweber/resources/message.rb",
|
47
|
+
"lib/aweber/resources/open.rb",
|
48
|
+
"lib/aweber/resources/subscriber.rb",
|
49
|
+
"lib/aweber/resources/tracked_event.rb",
|
50
|
+
"lib/aweber/resources/web_form.rb",
|
51
|
+
"lib/aweber/resources/web_form_split_test.rb",
|
52
|
+
"lib/aweber/resources/web_form_split_test_component.rb",
|
53
|
+
"lib/chubasaweber.rb",
|
54
|
+
"spec/base_spec.rb",
|
55
|
+
"spec/collection_spec.rb",
|
56
|
+
"spec/fixtures/account.json",
|
57
|
+
"spec/fixtures/accounts.json",
|
58
|
+
"spec/fixtures/campaign.json",
|
59
|
+
"spec/fixtures/campaigns.json",
|
60
|
+
"spec/fixtures/click.json",
|
61
|
+
"spec/fixtures/clicks.json",
|
62
|
+
"spec/fixtures/integration.json",
|
63
|
+
"spec/fixtures/integrations.json",
|
64
|
+
"spec/fixtures/link.json",
|
65
|
+
"spec/fixtures/links.json",
|
66
|
+
"spec/fixtures/list.json",
|
67
|
+
"spec/fixtures/lists.json",
|
68
|
+
"spec/fixtures/message.json",
|
69
|
+
"spec/fixtures/messages.json",
|
70
|
+
"spec/fixtures/open.json",
|
71
|
+
"spec/fixtures/opens.json",
|
72
|
+
"spec/fixtures/subscriber.json",
|
73
|
+
"spec/fixtures/subscribers.json",
|
74
|
+
"spec/fixtures/tracked_event.json",
|
75
|
+
"spec/fixtures/tracked_events.json",
|
76
|
+
"spec/fixtures/web_form.json",
|
77
|
+
"spec/fixtures/web_form_split_test.json",
|
78
|
+
"spec/fixtures/web_form_split_test_component.json",
|
79
|
+
"spec/fixtures/web_form_split_test_components.json",
|
80
|
+
"spec/fixtures/web_form_split_tests.json",
|
81
|
+
"spec/fixtures/web_forms.json",
|
82
|
+
"spec/oauth_spec.rb",
|
83
|
+
"spec/resource_spec.rb",
|
84
|
+
"spec/resources/account_spec.rb",
|
85
|
+
"spec/resources/campaign_spec.rb",
|
86
|
+
"spec/resources/click_spec.rb",
|
87
|
+
"spec/resources/integration_spec.rb",
|
88
|
+
"spec/resources/link_spec.rb",
|
89
|
+
"spec/resources/list_spec.rb",
|
90
|
+
"spec/resources/message_spec.rb",
|
91
|
+
"spec/resources/open_spec.rb",
|
92
|
+
"spec/resources/subscriber_spec.rb",
|
93
|
+
"spec/resources/tracked_event_spec.rb",
|
94
|
+
"spec/resources/web_form_spec.rb",
|
95
|
+
"spec/resources/web_form_split_test_component_spec.rb",
|
96
|
+
"spec/resources/web_form_split_test_spec.rb",
|
97
|
+
"spec/spec_helper.rb",
|
98
|
+
"test/helper.rb",
|
99
|
+
"test/test_chubasaweber.rb"
|
100
|
+
]
|
101
|
+
s.homepage = %q{http://github.com/ktlacaelel/chubasaweber}
|
102
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
103
|
+
s.require_paths = ["lib"]
|
104
|
+
s.rubygems_version = %q{1.3.7}
|
105
|
+
s.summary = %q{A cubas aweber}
|
106
|
+
s.test_files = [
|
107
|
+
"spec/base_spec.rb",
|
108
|
+
"spec/collection_spec.rb",
|
109
|
+
"spec/oauth_spec.rb",
|
110
|
+
"spec/resource_spec.rb",
|
111
|
+
"spec/resources/account_spec.rb",
|
112
|
+
"spec/resources/campaign_spec.rb",
|
113
|
+
"spec/resources/click_spec.rb",
|
114
|
+
"spec/resources/integration_spec.rb",
|
115
|
+
"spec/resources/link_spec.rb",
|
116
|
+
"spec/resources/list_spec.rb",
|
117
|
+
"spec/resources/message_spec.rb",
|
118
|
+
"spec/resources/open_spec.rb",
|
119
|
+
"spec/resources/subscriber_spec.rb",
|
120
|
+
"spec/resources/tracked_event_spec.rb",
|
121
|
+
"spec/resources/web_form_spec.rb",
|
122
|
+
"spec/resources/web_form_split_test_component_spec.rb",
|
123
|
+
"spec/resources/web_form_split_test_spec.rb",
|
124
|
+
"spec/spec_helper.rb",
|
125
|
+
"test/helper.rb",
|
126
|
+
"test/test_chubasaweber.rb",
|
127
|
+
"examples/with_access_token.rb",
|
128
|
+
"examples/your_account.rb"
|
129
|
+
]
|
130
|
+
|
131
|
+
if s.respond_to? :specification_version then
|
132
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
133
|
+
s.specification_version = 3
|
134
|
+
|
135
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
136
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
137
|
+
else
|
138
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
139
|
+
end
|
140
|
+
else
|
141
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Getting started with saved Access Tokens
|
2
|
+
# ========================================
|
3
|
+
@oauth = AWeber::OAuth.new("consumer_key", "consumer_secret")
|
4
|
+
|
5
|
+
# Use your saved Access Token token and secret to authorize.
|
6
|
+
#
|
7
|
+
# This is also how you'd authorize your users' accounts after
|
8
|
+
# they've authorized your app to access their data for the
|
9
|
+
# first time.
|
10
|
+
@oauth.authorize_with_access("token", "secret")
|
11
|
+
|
12
|
+
# Go on your merry way.
|
13
|
+
@aweber = AWeber::Base.new(@oauth)
|
14
|
+
@account = @aweber.account
|
15
|
+
@account.lists
|
16
|
+
@account.lists[1].web_forms
|
17
|
+
# etc
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Getting started with your own AWeber Account
|
2
|
+
# ============================================
|
3
|
+
|
4
|
+
# First, go to http://labs.aweber.com, get a free AWeber Labs
|
5
|
+
# account and create an App.
|
6
|
+
@oauth = AWeber::OAuth.new("consumer_key", "consumer_secret")
|
7
|
+
|
8
|
+
# Go to URL outputed by the following, authorize your account
|
9
|
+
# and copy the verification code
|
10
|
+
@oauth.request_token.authorize_url
|
11
|
+
@oauth.authorize_with_verifier("verification_code")
|
12
|
+
|
13
|
+
# Save your Access Tokens for later use, you won't need
|
14
|
+
# to do all this once you have it. Check out
|
15
|
+
# with_access_tokens.rb for an example of this.
|
16
|
+
#
|
17
|
+
# DATASTORE << @oauth.access_token.token
|
18
|
+
# DATASTORE << @oauth.access_token.secret
|
19
|
+
|
20
|
+
@aweber = AWeber::Base.new(@oauth)
|
21
|
+
# An account is the root resource for all AWeber data
|
22
|
+
@account = @aweber.account
|
23
|
+
|
24
|
+
@account.lists
|
25
|
+
@account.lists[1].web_forms
|
26
|
+
# etc
|
data/lib/aweber.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require "oauth"
|
3
|
+
|
4
|
+
module AWeber
|
5
|
+
API_VERSION = "1.0".freeze
|
6
|
+
AUTH_VERSION = "1.0".freeze
|
7
|
+
|
8
|
+
# Used for +has_many+ and +has_one+ relationships.
|
9
|
+
#
|
10
|
+
INFLECTIONS = {
|
11
|
+
:accounts => :Account,
|
12
|
+
:clicks => :Click,
|
13
|
+
:links => :Link,
|
14
|
+
:lists => :List,
|
15
|
+
:messages => :Message,
|
16
|
+
:opens => :Open,
|
17
|
+
:subscribers => :Subscriber,
|
18
|
+
:tracked_events => :TrackedEvent,
|
19
|
+
:integrations => :Integration,
|
20
|
+
:web_forms => :WebForm,
|
21
|
+
:components => :WebFormSplitTestComponent,
|
22
|
+
:web_form_split_tests => :WebFormSplitTest,
|
23
|
+
:last_followup_sents => :Followup
|
24
|
+
}
|
25
|
+
|
26
|
+
class << self
|
27
|
+
# @param [String] Base URL of the API server
|
28
|
+
#
|
29
|
+
attr_accessor :api_endpoint
|
30
|
+
|
31
|
+
# @param [String] Base URL of the Auth server
|
32
|
+
#
|
33
|
+
attr_accessor :auth_endpoint
|
34
|
+
|
35
|
+
def api_url
|
36
|
+
File.join api_endpoint, API_VERSION
|
37
|
+
end
|
38
|
+
|
39
|
+
def auth_url
|
40
|
+
File.join auth_endpoint, AUTH_VERSION
|
41
|
+
end
|
42
|
+
|
43
|
+
# Retrieves the Resource class based on the
|
44
|
+
# +INFLECTIONS+ map and +name+.
|
45
|
+
#
|
46
|
+
# @param [Symbol] name Collection name
|
47
|
+
#
|
48
|
+
def get_class(name)
|
49
|
+
Resources.const_get(INFLECTIONS[name])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
@api_endpoint = "https://api.aweber.com"
|
54
|
+
@auth_endpoint = "https://auth.aweber.com"
|
55
|
+
|
56
|
+
class OAuthError < Exception; end
|
57
|
+
class NotFoundError < Exception; end
|
58
|
+
class UnknownRequestError < Exception; end
|
59
|
+
end
|
60
|
+
|
61
|
+
$LOAD_PATH << File.dirname(__FILE__) unless $LOAD_PATH.include?(File.dirname(__FILE__))
|
62
|
+
require "aweber/oauth"
|
63
|
+
require "aweber/base"
|
64
|
+
require "aweber/resource"
|
65
|
+
require "aweber/resources"
|
66
|
+
require "aweber/collection"
|