aweber 1.0.0 → 1.1.0
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/Gemfile +1 -8
- data/Gemfile.lock +19 -13
- data/README.textile +27 -7
- data/Rakefile +1 -1
- data/aweber.gemspec +3 -3
- data/lib/aweber/base.rb +13 -5
- data/lib/aweber/resource.rb +46 -8
- data/lib/aweber/resources/account.rb +2 -2
- data/lib/aweber/resources/broadcast.rb +16 -16
- data/lib/aweber/resources/click.rb +3 -3
- data/lib/aweber/resources/followup.rb +15 -15
- data/lib/aweber/resources/integration.rb +2 -2
- data/lib/aweber/resources/link.rb +4 -4
- data/lib/aweber/resources/list.rb +7 -7
- data/lib/aweber/resources/message.rb +7 -7
- data/lib/aweber/resources/open.rb +2 -2
- data/lib/aweber/resources/subscriber.rb +16 -14
- data/lib/aweber/resources/tracked_event.rb +3 -3
- data/lib/aweber/resources/web_form.rb +8 -8
- data/lib/aweber/resources/web_form_split_test.rb +3 -3
- data/lib/aweber/resources/web_form_split_test_component.rb +10 -10
- data/spec/fixtures/lists_page_2.json +38 -0
- data/spec/resource_spec.rb +19 -0
- data/spec/resources/subscriber_spec.rb +8 -0
- metadata +10 -8
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
aweber (1.1.0)
|
5
|
+
json_pure
|
6
|
+
oauth
|
7
|
+
|
1
8
|
GEM
|
2
9
|
remote: http://rubygems.org/
|
3
10
|
specs:
|
@@ -5,24 +12,23 @@ GEM
|
|
5
12
|
fakeweb (1.3.0)
|
6
13
|
json_pure (1.4.6)
|
7
14
|
oauth (0.4.4)
|
8
|
-
rspec (2.
|
9
|
-
rspec-core (
|
10
|
-
rspec-expectations (
|
11
|
-
rspec-mocks (
|
12
|
-
rspec-core (2.
|
13
|
-
rspec-expectations (2.
|
14
|
-
diff-lcs (
|
15
|
-
rspec-mocks (2.
|
16
|
-
|
17
|
-
rspec-expectations (= 2.0.0.beta.22)
|
18
|
-
yard (0.6.3)
|
15
|
+
rspec (2.1.0)
|
16
|
+
rspec-core (~> 2.1.0)
|
17
|
+
rspec-expectations (~> 2.1.0)
|
18
|
+
rspec-mocks (~> 2.1.0)
|
19
|
+
rspec-core (2.1.0)
|
20
|
+
rspec-expectations (2.1.0)
|
21
|
+
diff-lcs (~> 1.1.2)
|
22
|
+
rspec-mocks (2.1.0)
|
23
|
+
yard (0.6.4)
|
19
24
|
|
20
25
|
PLATFORMS
|
21
26
|
ruby
|
22
27
|
|
23
28
|
DEPENDENCIES
|
29
|
+
aweber!
|
24
30
|
fakeweb
|
25
31
|
json_pure
|
26
32
|
oauth
|
27
|
-
rspec (
|
28
|
-
yard (~> 0.6.
|
33
|
+
rspec (~> 2.1.0)
|
34
|
+
yard (~> 0.6.0)
|
data/README.textile
CHANGED
@@ -10,25 +10,45 @@ h2. Quick Start
|
|
10
10
|
|
11
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
12
|
|
13
|
-
bc
|
13
|
+
bc.. # Register an app and use it's Consumer key and secret:
|
14
14
|
oauth = AWeber::OAuth.new("consumer_key", "consumer_secret")
|
15
|
+
|
15
16
|
# Go to the URL the following outputs.
|
16
17
|
oauth.request_token.authorize_url
|
18
|
+
|
17
19
|
# Authorize your account and copy the verification code.
|
18
20
|
oauth.authorize_with_verifier("verification_code")
|
19
|
-
aweber = AWeber::Base.new(oauth)
|
20
|
-
account = aweber.account
|
21
|
-
account.lists # Start getting data
|
22
21
|
|
23
|
-
|
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.
|
24
27
|
|
25
28
|
h2. Getting Data
|
26
29
|
|
27
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:
|
28
31
|
|
29
32
|
bc. account.lists #=> #<AWeber::Collection(AWeber::Resource::List)>
|
30
|
-
account.lists[1]
|
31
|
-
|
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
|
32
52
|
|
33
53
|
h2. Note on Patches/Pull Requests
|
34
54
|
|
data/Rakefile
CHANGED
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.1.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"
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.add_dependency "json_pure"
|
50
50
|
|
51
51
|
s.add_development_dependency "fakeweb"
|
52
|
-
s.add_development_dependency "rspec", "
|
53
|
-
s.add_development_dependency "yard",
|
52
|
+
s.add_development_dependency "rspec", "~> 2.1.0"
|
53
|
+
s.add_development_dependency "yard", "~> 0.6.0"
|
54
54
|
end
|
55
55
|
|
data/lib/aweber/base.rb
CHANGED
@@ -8,15 +8,23 @@ module AWeber
|
|
8
8
|
def account
|
9
9
|
accounts.first.last
|
10
10
|
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
11
|
+
|
14
12
|
def get(uri)
|
15
13
|
response = oauth.get(expand(uri))
|
16
14
|
handle_errors(response, uri)
|
17
15
|
parse(response) if response
|
18
16
|
end
|
19
17
|
|
18
|
+
def delete(uri)
|
19
|
+
oauth.delete(expand(uri))
|
20
|
+
end
|
21
|
+
|
22
|
+
def put(uri, body={})
|
23
|
+
oauth.put(uri, body.to_json, {"Content-Type" => "application/json"})
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
20
28
|
def handle_errors(response, uri)
|
21
29
|
if response.is_a? Net::HTTPNotFound
|
22
30
|
raise NotFoundError, "Invalid resource uri.", caller
|
@@ -32,9 +40,9 @@ module AWeber
|
|
32
40
|
def expand(uri)
|
33
41
|
parsed = URI.parse(uri)
|
34
42
|
url = []
|
35
|
-
url << AWeber.api_endpoint
|
43
|
+
url << AWeber.api_endpoint
|
36
44
|
url << API_VERSION unless parsed.path.include? API_VERSION
|
37
|
-
url <<
|
45
|
+
url << parsed.path
|
38
46
|
File.join(*url)
|
39
47
|
end
|
40
48
|
|
data/lib/aweber/resource.rb
CHANGED
@@ -14,9 +14,8 @@ module AWeber
|
|
14
14
|
extend Forwardable
|
15
15
|
include Comparable
|
16
16
|
|
17
|
-
def_delegators :client, :get
|
18
|
-
|
19
17
|
class << self
|
18
|
+
attr_accessor :writable_attrs
|
20
19
|
# Works the same as +alias_method+, but for attributes created via
|
21
20
|
# +attr*+ methods.
|
22
21
|
#
|
@@ -24,6 +23,29 @@ module AWeber
|
|
24
23
|
alias_method alias_, attribute
|
25
24
|
end
|
26
25
|
|
26
|
+
# Defines an attribute that it either read only or writable.
|
27
|
+
#
|
28
|
+
# == Example:
|
29
|
+
#
|
30
|
+
# # Read-only
|
31
|
+
# api_attr :name
|
32
|
+
#
|
33
|
+
# # Writable
|
34
|
+
# api_attr :name, :writable => true
|
35
|
+
#
|
36
|
+
# If an attribute is writable it will be sent with the request when
|
37
|
+
# +save+ is called.
|
38
|
+
#
|
39
|
+
def api_attr(attr_, opts={})
|
40
|
+
if opts[:writable]
|
41
|
+
attr_accessor attr_
|
42
|
+
@writable_attrs ||= []
|
43
|
+
@writable_attrs << attr_
|
44
|
+
else
|
45
|
+
attr_reader attr_
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
def has_one(name)
|
28
50
|
define_method(name) do
|
29
51
|
ivar = instance_variable_get("@#{name}")
|
@@ -31,7 +53,7 @@ module AWeber
|
|
31
53
|
|
32
54
|
resource_link = instance_variable_get("@#{name}_link")
|
33
55
|
klass = AWeber.get_class(:"#{name}s")
|
34
|
-
collection = klass.new(client, get(resource_link))
|
56
|
+
collection = klass.new(client, client.get(resource_link))
|
35
57
|
instance_variable_set("@#{name}", collection)
|
36
58
|
end
|
37
59
|
end
|
@@ -57,16 +79,16 @@ module AWeber
|
|
57
79
|
|
58
80
|
resource_link = instance_variable_get("@#{name}_collection_link")
|
59
81
|
klass = AWeber.get_class(name)
|
60
|
-
collection = Collection.new(client, klass, get(resource_link))
|
82
|
+
collection = Collection.new(client, klass, client.get(resource_link))
|
61
83
|
instance_variable_set("@#{name}", collection)
|
62
84
|
end
|
63
85
|
end
|
64
86
|
end
|
65
87
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
88
|
+
api_attr :id
|
89
|
+
api_attr :http_etag
|
90
|
+
api_attr :self_link
|
91
|
+
api_attr :resource_type_link
|
70
92
|
|
71
93
|
alias_attribute :etag, :http_etag
|
72
94
|
alias_attribute :link, :self_link
|
@@ -78,6 +100,22 @@ module AWeber
|
|
78
100
|
instance_variable_set("@#{key}", value) if respond_to? key
|
79
101
|
end
|
80
102
|
end
|
103
|
+
|
104
|
+
def delete
|
105
|
+
client.delete(@self_link)
|
106
|
+
end
|
107
|
+
|
108
|
+
def save
|
109
|
+
body = writable_attrs.inject({}) do |body, attr_|
|
110
|
+
body[attr_] = send(attr_)
|
111
|
+
body
|
112
|
+
end
|
113
|
+
client.put(self_link, body)
|
114
|
+
end
|
115
|
+
|
116
|
+
def writable_attrs
|
117
|
+
self.class.writable_attrs ||= {}
|
118
|
+
end
|
81
119
|
|
82
120
|
def <=>(other)
|
83
121
|
@id <=> other.id
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class Broadcast < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
api_attr :click_tracking_enabled
|
5
|
+
api_attr :content_type
|
6
|
+
api_attr :is_archived
|
7
|
+
api_attr :scheduled_at
|
8
|
+
api_attr :sent_at
|
9
|
+
api_attr :spam_assassin_score
|
10
|
+
api_attr :subject
|
11
|
+
api_attr :total_clicks
|
12
|
+
api_attr :total_opens
|
13
|
+
api_attr :total_sent
|
14
|
+
api_attr :total_spam_complaints
|
15
|
+
api_attr :total_undelivered
|
16
|
+
api_attr :total_unsubscribes
|
17
|
+
api_attr :twitter_account_link
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
api_attr :links_collection_link
|
20
|
+
api_attr :messages_collection_link
|
21
21
|
|
22
22
|
has_many :links
|
23
23
|
has_many :messages
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class Followup < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
api_attr :click_tracking_enabled
|
5
|
+
api_attr :content_type
|
6
|
+
api_attr :message_interval
|
7
|
+
api_attr :message_number
|
8
|
+
api_attr :spam_assassin_score
|
9
|
+
api_attr :subject
|
10
|
+
api_attr :total_clicked
|
11
|
+
api_attr :total_opened
|
12
|
+
api_attr :total_sent
|
13
|
+
api_attr :total_spam_complaints
|
14
|
+
api_attr :total_undelivered
|
15
|
+
api_attr :total_unsubscribes
|
16
|
+
|
17
|
+
api_attr :links_collection_link
|
18
|
+
api_attr :messages_collection_link
|
19
19
|
|
20
20
|
has_many :links
|
21
21
|
has_many :messages
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class Link < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
api_attr :total_clicks
|
5
|
+
api_attr :total_unique_clicks
|
6
|
+
api_attr :url
|
7
|
+
api_attr :clicks_collection_link
|
8
8
|
|
9
9
|
has_many :clicks
|
10
10
|
end
|
@@ -4,12 +4,12 @@ module AWeber
|
|
4
4
|
FOLLOWUP_TYPE_LINK = File.join(AWeber.api_url, "#followup_campaign")
|
5
5
|
BROADCAST_TYPE_LINK = File.join(AWeber.api_url, "#broadcast_campaign")
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
api_attr :name
|
8
|
+
|
9
|
+
api_attr :campaigns_collection_link
|
10
|
+
api_attr :subscribers_collection_link
|
11
|
+
api_attr :web_forms_collection_link
|
12
|
+
api_attr :web_form_split_tests_collection_link
|
13
13
|
|
14
14
|
has_many :subscribers
|
15
15
|
has_many :web_forms
|
@@ -74,7 +74,7 @@ module AWeber
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def _campaigns
|
77
|
-
@_campaigns ||= get(@campaigns_collection_link)
|
77
|
+
@_campaigns ||= client.get(@campaigns_collection_link)
|
78
78
|
end
|
79
79
|
|
80
80
|
def _entries
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class Message < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
api_attr :event_time
|
5
|
+
api_attr :last_opened
|
6
|
+
api_attr :total_opens
|
7
|
+
|
8
|
+
api_attr :subscriber_link
|
9
|
+
api_attr :tracked_events_collection_link
|
10
|
+
api_attr :opens_collection_link
|
11
11
|
|
12
12
|
has_one :subscriber
|
13
13
|
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class Subscriber < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
attr_reader :status
|
12
|
-
attr_reader :subscribed_at
|
13
|
-
attr_reader :subscription_method
|
14
|
-
attr_reader :subscription_url
|
15
|
-
attr_reader :unsubscribed_at
|
16
|
-
attr_reader :verified_at
|
4
|
+
api_attr :name, :writable => true
|
5
|
+
api_attr :misc_notes, :writable => true
|
6
|
+
api_attr :email, :writable => true
|
7
|
+
api_attr :status, :writable => true
|
8
|
+
api_attr :custom_fields, :writable => true
|
9
|
+
api_attr :ad_tracking, :writable => true
|
10
|
+
api_attr :last_followup_message_number_sent, :writable => true
|
17
11
|
|
18
|
-
|
12
|
+
api_attr :ip_address
|
13
|
+
api_attr :is_verified
|
14
|
+
api_attr :last_followup_sent_at
|
15
|
+
api_attr :subscribed_at
|
16
|
+
api_attr :subscription_method
|
17
|
+
api_attr :subscription_url
|
18
|
+
api_attr :unsubscribed_at
|
19
|
+
api_attr :verified_at
|
20
|
+
api_attr :last_followup_sent_link
|
19
21
|
|
20
22
|
has_one :last_followup_sent
|
21
23
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class WebForm < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
api_attr :conversion_percentage
|
5
|
+
api_attr :is_active
|
6
|
+
api_attr :name
|
7
|
+
api_attr :total_displays
|
8
|
+
api_attr :total_submissions
|
9
|
+
api_attr :total_unique_displays
|
10
|
+
api_attr :type
|
11
|
+
api_attr :unique_conversion_percentage
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class WebFormSplitTest < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
api_attr :components_collection_link
|
5
|
+
api_attr :is_active
|
6
|
+
api_attr :name
|
7
7
|
|
8
8
|
has_many :components
|
9
9
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module AWeber
|
2
2
|
module Resources
|
3
3
|
class WebFormSplitTestComponent < Resource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
api_attr :conversion_percentage
|
5
|
+
api_attr :is_active
|
6
|
+
api_attr :name
|
7
|
+
api_attr :total_displays
|
8
|
+
api_attr :total_submissions
|
9
|
+
api_attr :total_unique_displays
|
10
|
+
api_attr :type
|
11
|
+
api_attr :unique_conversion_percentage
|
12
|
+
api_attr :web_form_link
|
13
|
+
api_attr :weight
|
14
14
|
|
15
15
|
has_one :web_form
|
16
16
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"total_size": 6,
|
3
|
+
"start": 4,
|
4
|
+
"resource_type_link": "https://api.aweber.com/1.0/#list-page-resource",
|
5
|
+
"entries": [{
|
6
|
+
"campaigns_collection_link": "/accounts/1/lists/4565456/campaigns",
|
7
|
+
"name": "asdsa456464",
|
8
|
+
"web_form_split_tests_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/4565456/web_form_split_tests",
|
9
|
+
"subscribers_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/4565456/subscribers",
|
10
|
+
"id": 4565456,
|
11
|
+
"http_etag": "\"4ab41e60d14ea138a4522b3d2896942b7335c13c - ca5feee2b7fbb6febfca8af5541541ea960aaedb\"",
|
12
|
+
"self_link": "https://api.aweber.com/1.0/accounts/1/lists/4565456",
|
13
|
+
"resource_type_link": "https://api.aweber.com/1.0/#list",
|
14
|
+
"web_forms_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/4565456/web_forms"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"campaigns_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/8975612/campaigns",
|
18
|
+
"name": "default8975612",
|
19
|
+
"web_form_split_tests_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/8975612/web_form_split_tests",
|
20
|
+
"subscribers_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/8975612/subscribers",
|
21
|
+
"id": 8975612,
|
22
|
+
"http_etag": "\"685c00e3983add5e4efb5ca3bc7294e247f6e9fe - ca5feee2b7fbb6febfca8af5541541ea960aaedb\"",
|
23
|
+
"self_link": "https://api.aweber.com/1.0/accounts/1/lists/8975612",
|
24
|
+
"resource_type_link": "https://api.aweber.com/1.0/#list",
|
25
|
+
"web_forms_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/8975612/web_forms"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"campaigns_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/12357254/campaigns",
|
29
|
+
"name": "default123572549",
|
30
|
+
"web_form_split_tests_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/12357254/web_form_split_tests",
|
31
|
+
"subscribers_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/12357254/subscribers",
|
32
|
+
"id": 12357254,
|
33
|
+
"http_etag": "\"0aaa38a50287df08ccb74c7f13fca8679aab688a - ca5feee2b7fbb6febfca8af5541541ea960aaedb\"",
|
34
|
+
"self_link": "https://api.aweber.com/1.0/accounts/1/lists/12357254",
|
35
|
+
"resource_type_link": "https://api.aweber.com/1.0/#list",
|
36
|
+
"web_forms_collection_link": "https://api.aweber.com/1.0/accounts/1/lists/12357254/web_forms"
|
37
|
+
}]
|
38
|
+
}
|
data/spec/resource_spec.rb
CHANGED
@@ -2,6 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
class FakeResource < AWeber::Resource
|
4
4
|
attr_accessor :foo
|
5
|
+
api_attr :name, :writable => true
|
5
6
|
alias_attribute :bar, :foo
|
6
7
|
has_many :lists
|
7
8
|
end
|
@@ -58,4 +59,22 @@ describe AWeber::Resource do
|
|
58
59
|
fake1.should_not == fake3
|
59
60
|
end
|
60
61
|
|
62
|
+
it "should be deleted" do
|
63
|
+
fake = FakeResource.new(@aweber, JSON.parse(fixture("account.json")))
|
64
|
+
@oauth.should_receive(:delete).with(fake.link)
|
65
|
+
fake.delete
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should declare writable attributes" do
|
69
|
+
resource = FakeResource.new(@aweber)
|
70
|
+
resource.writable_attrs.include?(:name).should be_true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should send a JSON respresentation of the object on save" do
|
74
|
+
resource = FakeResource.new(@aweber)
|
75
|
+
@oauth.should_receive(:put).with(resource.link, "{\"name\":\"Bob\"}")
|
76
|
+
resource.name = "Bob"
|
77
|
+
resource.save
|
78
|
+
end
|
79
|
+
|
61
80
|
end
|
@@ -22,4 +22,12 @@ describe AWeber::Resources::Subscriber do
|
|
22
22
|
it { should respond_to :subscription_url }
|
23
23
|
it { should respond_to :unsubscribed_at }
|
24
24
|
it { should respond_to :verified_at }
|
25
|
+
|
26
|
+
its(:writable_attrs) { should include :name }
|
27
|
+
its(:writable_attrs) { should include :misc_notes }
|
28
|
+
its(:writable_attrs) { should include :email }
|
29
|
+
its(:writable_attrs) { should include :status }
|
30
|
+
its(:writable_attrs) { should include :custom_fields }
|
31
|
+
its(:writable_attrs) { should include :ad_tracking }
|
32
|
+
its(:writable_attrs) { should include :last_followup_message_number_sent }
|
25
33
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 1.0.0
|
9
|
+
version: 1.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- AWeber Communications, Inc.
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-13 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -62,13 +62,13 @@ dependencies:
|
|
62
62
|
requirement: &id004 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - ~>
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
segments:
|
68
68
|
- 2
|
69
|
+
- 1
|
69
70
|
- 0
|
70
|
-
|
71
|
-
version: 2.0.0
|
71
|
+
version: 2.1.0
|
72
72
|
type: :development
|
73
73
|
version_requirements: *id004
|
74
74
|
- !ruby/object:Gem::Dependency
|
@@ -82,8 +82,8 @@ dependencies:
|
|
82
82
|
segments:
|
83
83
|
- 0
|
84
84
|
- 6
|
85
|
-
-
|
86
|
-
version: 0.6.
|
85
|
+
- 0
|
86
|
+
version: 0.6.0
|
87
87
|
type: :development
|
88
88
|
version_requirements: *id005
|
89
89
|
description: Ruby interface to AWeber's API
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- spec/fixtures/links.json
|
139
139
|
- spec/fixtures/list.json
|
140
140
|
- spec/fixtures/lists.json
|
141
|
+
- spec/fixtures/lists_page_2.json
|
141
142
|
- spec/fixtures/message.json
|
142
143
|
- spec/fixtures/messages.json
|
143
144
|
- spec/fixtures/open.json
|
@@ -215,6 +216,7 @@ test_files:
|
|
215
216
|
- spec/fixtures/links.json
|
216
217
|
- spec/fixtures/list.json
|
217
218
|
- spec/fixtures/lists.json
|
219
|
+
- spec/fixtures/lists_page_2.json
|
218
220
|
- spec/fixtures/message.json
|
219
221
|
- spec/fixtures/messages.json
|
220
222
|
- spec/fixtures/open.json
|