sendyr 0.1.0 → 0.2.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/README.md +3 -0
- data/lib/sendyr.rb +1 -1
- data/lib/sendyr/client.rb +15 -0
- data/lib/sendyr/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -21,6 +21,7 @@ Or install it yourself as:
|
|
21
21
|
Sendyr.configure do |c|
|
22
22
|
c.url = 'http://my.sendy-install.com'
|
23
23
|
c.api_key = '1234567890'
|
24
|
+
# c.noop = true # You can use this to noop in dev and test environments
|
24
25
|
end
|
25
26
|
|
26
27
|
list_id = 1
|
@@ -33,6 +34,8 @@ Or install it yourself as:
|
|
33
34
|
|
34
35
|
client.unsubscribe(email: 'joe@example.org') # => true
|
35
36
|
|
37
|
+
client.update_subscription('joe@example.org', email: 'newemail@example.com', name: 'Joe Smith', FirstName => 'Joe') # => true
|
38
|
+
|
36
39
|
|
37
40
|
## Contributing
|
38
41
|
|
data/lib/sendyr.rb
CHANGED
data/lib/sendyr/client.rb
CHANGED
@@ -8,9 +8,12 @@ module Sendyr
|
|
8
8
|
@list_id = list_id
|
9
9
|
@api_key = Sendyr.configuration.api_key
|
10
10
|
@base_uri = Sendyr.configuration.url
|
11
|
+
@noop = Sendyr.configuration.noop || false
|
11
12
|
end
|
12
13
|
|
13
14
|
def subscribe(opts = {})
|
15
|
+
return noop if @noop
|
16
|
+
|
14
17
|
opts = {boolean: true, list: @list_id}.merge(opts)
|
15
18
|
raise_if_missing_arg([:email, :list], opts)
|
16
19
|
|
@@ -25,6 +28,8 @@ module Sendyr
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def unsubscribe(opts = {})
|
31
|
+
return noop if @noop
|
32
|
+
|
28
33
|
opts = {boolean: true, list: @list_id}.merge(opts)
|
29
34
|
raise_if_missing_arg([:email, :list], opts)
|
30
35
|
|
@@ -39,6 +44,8 @@ module Sendyr
|
|
39
44
|
end
|
40
45
|
|
41
46
|
def subscription_status(opts = {})
|
47
|
+
return noop if @noop
|
48
|
+
|
42
49
|
opts = {api_key: @api_key, list_id: @list_id}.merge(opts)
|
43
50
|
raise_if_missing_arg([:api_key, :email, :list_id, :api_key], opts)
|
44
51
|
|
@@ -62,6 +69,8 @@ module Sendyr
|
|
62
69
|
end
|
63
70
|
|
64
71
|
def update_subscription(email, opts = {})
|
72
|
+
return noop if @noop
|
73
|
+
|
65
74
|
status = subscription_status(email: email)
|
66
75
|
|
67
76
|
return false if status == :not_in_list
|
@@ -81,6 +90,8 @@ module Sendyr
|
|
81
90
|
end
|
82
91
|
|
83
92
|
def active_subscriber_count(opts = {})
|
93
|
+
return noop if @noop
|
94
|
+
|
84
95
|
opts = {api_key: @api_key, list_id: @list_id}.merge(opts)
|
85
96
|
raise_if_missing_arg([:list_id, :api_key], opts)
|
86
97
|
|
@@ -136,5 +147,9 @@ module Sendyr
|
|
136
147
|
word.downcase!
|
137
148
|
word
|
138
149
|
end
|
150
|
+
|
151
|
+
def noop
|
152
|
+
:noop
|
153
|
+
end
|
139
154
|
end
|
140
155
|
end
|
data/lib/sendyr/version.rb
CHANGED