sendyr 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -13,7 +13,7 @@ module Sendyr
13
13
  end
14
14
 
15
15
  class Configuration
16
- attr_accessor :url, :api_key
16
+ attr_accessor :url, :api_key, :noop
17
17
 
18
18
  def initialize
19
19
  end
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
@@ -1,3 +1,3 @@
1
1
  module Sendyr
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sendyr
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Carl Mercier