newslettre 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ config/newslettre.yml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require ./spec/spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in newslettre.gemspec
4
+ gemspec
@@ -0,0 +1,84 @@
1
+ # Newslettre
2
+
3
+ While writing this [Sendgrid Newsletter API](http://docs.sendgrid.com/documentation/api/newsletter-api/) client in ruby
4
+ I noticed several flaws in their __API__ conception. Something like,
5
+ returning __401__ Status code when resources cannot be found are pretty
6
+ gross but anyway this client should be mostly complete (still work in
7
+ progress, scheduling etc.).
8
+
9
+ ## Installation
10
+
11
+ ``` ruby
12
+
13
+ gem install newslettre
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ this is definitely going to change since it's tedious to pass the client
19
+ instance around. Maybe there will be a top-level wrapper to give you
20
+ access to all the _modules_ the API defines (Identity, Newsletter,
21
+ Recipients)
22
+
23
+ Right now it works like this…
24
+
25
+ ``` ruby
26
+
27
+ require 'newslettre'
28
+
29
+ client = Newslettre::Client.new :email => "somebody@yourdomain.com",
30
+ :password => "reallygoodpassword"
31
+
32
+ letters = Newslettre::Letter.new client
33
+
34
+ letters.list # => [{ "name" => "webdev" }]
35
+
36
+
37
+ letters.get "webdev" # => { "name", "subject" => "Latest Web Development News", "html" => "<html>...</html>" }
38
+
39
+ letters.delete "webdev"
40
+
41
+ ```
42
+
43
+ nearly the same goes for `Identity`, `Lists`, `Lists::Email` and `Letter::Recipients`
44
+
45
+ ## Development
46
+
47
+ though it is still far from complete, if you'd like to help out please
48
+ submit pull request with passing specs (or scenarios)
49
+
50
+ you will need to add a `config/newslettre.yml` containing something like
51
+ this:
52
+
53
+ ``` yaml
54
+ sendgrid:
55
+ username: "somebody@yourdomain.com"
56
+ password: "reallysecurepassword"
57
+
58
+ identity:
59
+ email: "info@yourdomain.com"
60
+ name: "Lennart Melzer"
61
+ address: "Where you live 15"
62
+ city: "Downtown"
63
+ state: "C"
64
+ zip: "12345"
65
+ country: "EF"
66
+
67
+ letter:
68
+ name: "test"
69
+ identity: "test-identity"
70
+ subject: "A letter to the world!"
71
+ html: "<html><body><h1>A rendered Headline</h1></body></html>"
72
+ text: "An unrendered Headline"
73
+
74
+ emails:
75
+ -
76
+ email: somebody@yourdomain.com
77
+ name: Some Body
78
+ -
79
+ email: someone@else.com
80
+ name: Someone Else
81
+
82
+ ```
83
+
84
+ to make the specs pass
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ Cucumber::Rake::Task.new(:features) do |t|
10
+ t.cucumber_opts = "features --format pretty"
11
+ end
12
+
13
+ task :default => :spec
@@ -0,0 +1,185 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://sendgrid.com:443/api/newsletter/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&name=Superior%20Soy%20Beans%20Discount!
6
+ body: !!null
7
+ headers: !!null
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ server:
14
+ - nginx/0.7.65
15
+ date:
16
+ - Tue, 20 Sep 2011 14:59:13 GMT
17
+ content-type:
18
+ - text/html
19
+ transfer-encoding:
20
+ - chunked
21
+ connection:
22
+ - keep-alive
23
+ body: ! '{"message": "success"}'
24
+ http_version: '1.1'
25
+ - !ruby/struct:VCR::HTTPInteraction
26
+ request: !ruby/struct:VCR::Request
27
+ method: :post
28
+ uri: https://sendgrid.com:443/api/newsletter/lists/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts
29
+ body: !!null
30
+ headers: !!null
31
+ response: !ruby/struct:VCR::Response
32
+ status: !ruby/struct:VCR::ResponseStatus
33
+ code: 200
34
+ message: OK
35
+ headers:
36
+ server:
37
+ - nginx/0.7.65
38
+ date:
39
+ - Tue, 20 Sep 2011 14:59:13 GMT
40
+ content-type:
41
+ - text/html
42
+ transfer-encoding:
43
+ - chunked
44
+ connection:
45
+ - keep-alive
46
+ body: ! '{"message": "success"}'
47
+ http_version: '1.1'
48
+ - !ruby/struct:VCR::HTTPInteraction
49
+ request: !ruby/struct:VCR::Request
50
+ method: :post
51
+ uri: https://sendgrid.com:443/api/newsletter/identity/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&identity=Bourne
52
+ body: !!null
53
+ headers: !!null
54
+ response: !ruby/struct:VCR::Response
55
+ status: !ruby/struct:VCR::ResponseStatus
56
+ code: 200
57
+ message: OK
58
+ headers:
59
+ server:
60
+ - nginx/0.7.65
61
+ date:
62
+ - Tue, 20 Sep 2011 14:59:14 GMT
63
+ content-type:
64
+ - text/html
65
+ transfer-encoding:
66
+ - chunked
67
+ connection:
68
+ - keep-alive
69
+ body: ! '{"message": "success"}'
70
+ http_version: '1.1'
71
+ - !ruby/struct:VCR::HTTPInteraction
72
+ request: !ruby/struct:VCR::Request
73
+ method: :post
74
+ uri: https://sendgrid.com:443/api/newsletter/identity/add.json?address=Oranienstra%C3%9Fe%206&api_key=<<PASSWORD>>&api_user=<<USERNAME>>&city=Berlin&country=DE&email=<<USERNAME>>&identity=Bourne&name=Mathias%20Fiedler&state=B&zip=10997
75
+ body: !!null
76
+ headers: !!null
77
+ response: !ruby/struct:VCR::Response
78
+ status: !ruby/struct:VCR::ResponseStatus
79
+ code: 200
80
+ message: OK
81
+ headers:
82
+ server:
83
+ - nginx/0.7.65
84
+ date:
85
+ - Tue, 20 Sep 2011 14:59:15 GMT
86
+ content-type:
87
+ - text/html
88
+ transfer-encoding:
89
+ - chunked
90
+ connection:
91
+ - keep-alive
92
+ body: ! '{"message": "success"}'
93
+ http_version: '1.1'
94
+ - !ruby/struct:VCR::HTTPInteraction
95
+ request: !ruby/struct:VCR::Request
96
+ method: :post
97
+ uri: https://sendgrid.com:443/api/newsletter/add.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&html=%3Ch1%3Emeow%3C/h1%3E&identity=Bourne&name=Superior%20Soy%20Beans%20Discount!&subject=Superior%20Soy%20Beans%20Discount!&text=Super%20Cool!
98
+ body: !!null
99
+ headers: !!null
100
+ response: !ruby/struct:VCR::Response
101
+ status: !ruby/struct:VCR::ResponseStatus
102
+ code: 200
103
+ message: OK
104
+ headers:
105
+ server:
106
+ - nginx/0.7.65
107
+ date:
108
+ - Tue, 20 Sep 2011 14:59:16 GMT
109
+ content-type:
110
+ - text/html
111
+ transfer-encoding:
112
+ - chunked
113
+ connection:
114
+ - keep-alive
115
+ body: ! '{"message": "success"}'
116
+ http_version: '1.1'
117
+ - !ruby/struct:VCR::HTTPInteraction
118
+ request: !ruby/struct:VCR::Request
119
+ method: :post
120
+ uri: https://sendgrid.com:443/api/newsletter/lists/add.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts
121
+ body: !!null
122
+ headers: !!null
123
+ response: !ruby/struct:VCR::Response
124
+ status: !ruby/struct:VCR::ResponseStatus
125
+ code: 200
126
+ message: OK
127
+ headers:
128
+ server:
129
+ - nginx/0.7.65
130
+ date:
131
+ - Tue, 20 Sep 2011 14:59:17 GMT
132
+ content-type:
133
+ - text/html
134
+ transfer-encoding:
135
+ - chunked
136
+ connection:
137
+ - keep-alive
138
+ body: ! '{"message": "success"}'
139
+ http_version: '1.1'
140
+ - !ruby/struct:VCR::HTTPInteraction
141
+ request: !ruby/struct:VCR::Request
142
+ method: :post
143
+ uri: https://sendgrid.com:443/api/newsletter/recipients/add.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts&name=Superior%20Soy%20Beans%20Discount!
144
+ body: !!null
145
+ headers: !!null
146
+ response: !ruby/struct:VCR::Response
147
+ status: !ruby/struct:VCR::ResponseStatus
148
+ code: 200
149
+ message: OK
150
+ headers:
151
+ server:
152
+ - nginx/0.7.65
153
+ date:
154
+ - Tue, 20 Sep 2011 14:59:18 GMT
155
+ content-type:
156
+ - text/html
157
+ transfer-encoding:
158
+ - chunked
159
+ connection:
160
+ - keep-alive
161
+ body: ! '{"message": "success"}'
162
+ http_version: '1.1'
163
+ - !ruby/struct:VCR::HTTPInteraction
164
+ request: !ruby/struct:VCR::Request
165
+ method: :post
166
+ uri: https://sendgrid.com:443/api/newsletter/recipients/get.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&name=Superior%20Soy%20Beans%20Discount!
167
+ body: !!null
168
+ headers: !!null
169
+ response: !ruby/struct:VCR::Response
170
+ status: !ruby/struct:VCR::ResponseStatus
171
+ code: 200
172
+ message: OK
173
+ headers:
174
+ server:
175
+ - nginx/0.7.65
176
+ date:
177
+ - Tue, 20 Sep 2011 14:59:19 GMT
178
+ content-type:
179
+ - text/html
180
+ transfer-encoding:
181
+ - chunked
182
+ connection:
183
+ - keep-alive
184
+ body: ! '[{"list": "Junk-food addicts"}]'
185
+ http_version: '1.1'
@@ -0,0 +1,208 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://sendgrid.com:443/api/newsletter/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&name=Superior%20Soy%20Beans%20Discount!
6
+ body: !!null
7
+ headers: !!null
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ server:
14
+ - nginx/0.7.65
15
+ date:
16
+ - Tue, 20 Sep 2011 14:59:20 GMT
17
+ content-type:
18
+ - text/html
19
+ transfer-encoding:
20
+ - chunked
21
+ connection:
22
+ - keep-alive
23
+ body: ! '{"message": "success"}'
24
+ http_version: '1.1'
25
+ - !ruby/struct:VCR::HTTPInteraction
26
+ request: !ruby/struct:VCR::Request
27
+ method: :post
28
+ uri: https://sendgrid.com:443/api/newsletter/lists/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts
29
+ body: !!null
30
+ headers: !!null
31
+ response: !ruby/struct:VCR::Response
32
+ status: !ruby/struct:VCR::ResponseStatus
33
+ code: 200
34
+ message: OK
35
+ headers:
36
+ server:
37
+ - nginx/0.7.65
38
+ date:
39
+ - Tue, 20 Sep 2011 14:59:21 GMT
40
+ content-type:
41
+ - text/html
42
+ transfer-encoding:
43
+ - chunked
44
+ connection:
45
+ - keep-alive
46
+ body: ! '{"message": "success"}'
47
+ http_version: '1.1'
48
+ - !ruby/struct:VCR::HTTPInteraction
49
+ request: !ruby/struct:VCR::Request
50
+ method: :post
51
+ uri: https://sendgrid.com:443/api/newsletter/identity/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&identity=Bourne
52
+ body: !!null
53
+ headers: !!null
54
+ response: !ruby/struct:VCR::Response
55
+ status: !ruby/struct:VCR::ResponseStatus
56
+ code: 200
57
+ message: OK
58
+ headers:
59
+ server:
60
+ - nginx/0.7.65
61
+ date:
62
+ - Tue, 20 Sep 2011 14:59:21 GMT
63
+ content-type:
64
+ - text/html
65
+ transfer-encoding:
66
+ - chunked
67
+ connection:
68
+ - keep-alive
69
+ body: ! '{"message": "success"}'
70
+ http_version: '1.1'
71
+ - !ruby/struct:VCR::HTTPInteraction
72
+ request: !ruby/struct:VCR::Request
73
+ method: :post
74
+ uri: https://sendgrid.com:443/api/newsletter/identity/add.json?address=Oranienstra%C3%9Fe%206&api_key=<<PASSWORD>>&api_user=<<USERNAME>>&city=Berlin&country=DE&email=<<USERNAME>>&identity=Bourne&name=Mathias%20Fiedler&state=B&zip=10997
75
+ body: !!null
76
+ headers: !!null
77
+ response: !ruby/struct:VCR::Response
78
+ status: !ruby/struct:VCR::ResponseStatus
79
+ code: 200
80
+ message: OK
81
+ headers:
82
+ server:
83
+ - nginx/0.7.65
84
+ date:
85
+ - Tue, 20 Sep 2011 14:59:22 GMT
86
+ content-type:
87
+ - text/html
88
+ transfer-encoding:
89
+ - chunked
90
+ connection:
91
+ - keep-alive
92
+ body: ! '{"message": "success"}'
93
+ http_version: '1.1'
94
+ - !ruby/struct:VCR::HTTPInteraction
95
+ request: !ruby/struct:VCR::Request
96
+ method: :post
97
+ uri: https://sendgrid.com:443/api/newsletter/add.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&html=%3Ch1%3Emeow%3C/h1%3E&identity=Bourne&name=Superior%20Soy%20Beans%20Discount!&subject=Superior%20Soy%20Beans%20Discount!&text=Super%20Cool!
98
+ body: !!null
99
+ headers: !!null
100
+ response: !ruby/struct:VCR::Response
101
+ status: !ruby/struct:VCR::ResponseStatus
102
+ code: 200
103
+ message: OK
104
+ headers:
105
+ server:
106
+ - nginx/0.7.65
107
+ date:
108
+ - Tue, 20 Sep 2011 14:59:23 GMT
109
+ content-type:
110
+ - text/html
111
+ transfer-encoding:
112
+ - chunked
113
+ connection:
114
+ - keep-alive
115
+ body: ! '{"message": "success"}'
116
+ http_version: '1.1'
117
+ - !ruby/struct:VCR::HTTPInteraction
118
+ request: !ruby/struct:VCR::Request
119
+ method: :post
120
+ uri: https://sendgrid.com:443/api/newsletter/lists/add.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts
121
+ body: !!null
122
+ headers: !!null
123
+ response: !ruby/struct:VCR::Response
124
+ status: !ruby/struct:VCR::ResponseStatus
125
+ code: 200
126
+ message: OK
127
+ headers:
128
+ server:
129
+ - nginx/0.7.65
130
+ date:
131
+ - Tue, 20 Sep 2011 14:59:24 GMT
132
+ content-type:
133
+ - text/html
134
+ transfer-encoding:
135
+ - chunked
136
+ connection:
137
+ - keep-alive
138
+ body: ! '{"message": "success"}'
139
+ http_version: '1.1'
140
+ - !ruby/struct:VCR::HTTPInteraction
141
+ request: !ruby/struct:VCR::Request
142
+ method: :post
143
+ uri: https://sendgrid.com:443/api/newsletter/recipients/add.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts&name=Superior%20Soy%20Beans%20Discount!
144
+ body: !!null
145
+ headers: !!null
146
+ response: !ruby/struct:VCR::Response
147
+ status: !ruby/struct:VCR::ResponseStatus
148
+ code: 200
149
+ message: OK
150
+ headers:
151
+ server:
152
+ - nginx/0.7.65
153
+ date:
154
+ - Tue, 20 Sep 2011 14:59:25 GMT
155
+ content-type:
156
+ - text/html
157
+ transfer-encoding:
158
+ - chunked
159
+ connection:
160
+ - keep-alive
161
+ body: ! '{"message": "success"}'
162
+ http_version: '1.1'
163
+ - !ruby/struct:VCR::HTTPInteraction
164
+ request: !ruby/struct:VCR::Request
165
+ method: :post
166
+ uri: https://sendgrid.com:443/api/newsletter/recipients/delete.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&list=Junk-food%20addicts&name=Superior%20Soy%20Beans%20Discount!
167
+ body: !!null
168
+ headers: !!null
169
+ response: !ruby/struct:VCR::Response
170
+ status: !ruby/struct:VCR::ResponseStatus
171
+ code: 200
172
+ message: OK
173
+ headers:
174
+ server:
175
+ - nginx/0.7.65
176
+ date:
177
+ - Tue, 20 Sep 2011 14:59:26 GMT
178
+ content-type:
179
+ - text/html
180
+ transfer-encoding:
181
+ - chunked
182
+ connection:
183
+ - keep-alive
184
+ body: ! '{"message": "success"}'
185
+ http_version: '1.1'
186
+ - !ruby/struct:VCR::HTTPInteraction
187
+ request: !ruby/struct:VCR::Request
188
+ method: :post
189
+ uri: https://sendgrid.com:443/api/newsletter/recipients/get.json?api_key=<<PASSWORD>>&api_user=<<USERNAME>>&name=Superior%20Soy%20Beans%20Discount!
190
+ body: !!null
191
+ headers: !!null
192
+ response: !ruby/struct:VCR::Response
193
+ status: !ruby/struct:VCR::ResponseStatus
194
+ code: 200
195
+ message: OK
196
+ headers:
197
+ server:
198
+ - nginx/0.7.65
199
+ date:
200
+ - Tue, 20 Sep 2011 14:59:26 GMT
201
+ content-type:
202
+ - text/html
203
+ transfer-encoding:
204
+ - chunked
205
+ connection:
206
+ - keep-alive
207
+ body: ! '[]'
208
+ http_version: '1.1'