litmus-instant 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +33 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/Guardfile +18 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +182 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/examples/Gemfile +4 -0
  13. data/examples/Gemfile.lock +32 -0
  14. data/examples/README.md +29 -0
  15. data/examples/email/test-email.html +330 -0
  16. data/examples/example_batch.rb +50 -0
  17. data/examples/example_simple.rb +35 -0
  18. data/fixtures/vcr_cassettes/Litmus_Instant/client_configurations/returns_a_Hash_of_clients_and_their_available_options.yml +419 -0
  19. data/fixtures/vcr_cassettes/Litmus_Instant/clients/returns_an_array_of_client_names.yml +86 -0
  20. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_invalid_email_Hash_raise_a_request_error.yml +77 -0
  21. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_valid_email_Hash_optional_end_user_id_is_relayed.yml +44 -0
  22. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_valid_email_Hash_prerequest_configurations_is_relayed.yml +55 -0
  23. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_valid_email_Hash_response_.yml +81 -0
  24. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/unauthenticated_raises_an_authentication_error.yml +41 -0
  25. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/raises_NotFound_for_an_expired_email_guid.yml +1668 -0
  26. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/raises_RequestError_for_an_invalid_client.yml +79 -0
  27. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/raises_RequestError_for_an_invalid_email_guid.yml +39 -0
  28. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/returns_a_Hash_of_the_image_types.yml +85 -0
  29. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/supports_optional_capture_configuration.yml +121 -0
  30. data/fixtures/vcr_cassettes/Litmus_Instant/prefetch_previews/raises_RequestError_for_an_invalid_email_guid.yml +39 -0
  31. data/fixtures/vcr_cassettes/Litmus_Instant/prefetch_previews/raises_RequestError_if_any_invalid_configurations_are_present.yml +79 -0
  32. data/fixtures/vcr_cassettes/Litmus_Instant/prefetch_previews/responds_with_an_array_of_the_requested_configurations.yml +88 -0
  33. data/lib/litmus/instant.rb +216 -0
  34. data/lib/litmus/instant/version.rb +5 -0
  35. data/litmus-instant.gemspec +39 -0
  36. metadata +194 -0
@@ -0,0 +1,50 @@
1
+ require "bundler"
2
+ Bundler.require
3
+
4
+ Litmus::Instant.api_key = ENV["API_KEY"] or abort("Error starting server - API_KEY required")
5
+
6
+ get '/' do
7
+ '<a href="/example">Open example</a>'
8
+ end
9
+
10
+ get '/example' do
11
+ result = Litmus::Instant.create_email(
12
+ 'html_text' => File.read('email/test-email.html').gsub(
13
+ "Crafting your perfect subject line",
14
+ "#{params[:message] || Time.now}"
15
+ )
16
+ )
17
+
18
+ email_guid = JSON.parse(result.body)['email_guid']
19
+
20
+ all_clients = Litmus::Instant.clients
21
+ # Server-side ask the API to prefetch all clients (non-blocking)
22
+ capture_configurations = all_clients.map do |client|
23
+ { client: client, orientation: "vertical", images: "allowed" }
24
+ end
25
+ Litmus::Instant.prefetch_previews(email_guid, capture_configurations)
26
+
27
+ # Provide the user's browser the preview URLs, by the time it comes to request
28
+ # them capture will already be in progress, so wait time should be minimised.
29
+ previews = all_clients.map do |client|
30
+ [
31
+ client,
32
+ Litmus::Instant.preview_image_url(email_guid, client, capture_size: 'thumb'),
33
+ Litmus::Instant.preview_image_url(email_guid, client, capture_size: 'full')
34
+ ]
35
+ end
36
+ erb :example, locals: { previews: previews }
37
+ end
38
+
39
+ __END__
40
+
41
+ @@example
42
+ <p>
43
+ Add your custom message as a parameter,
44
+ <a href="?message=I like marmots">eg like this</a>.
45
+ <p>
46
+ <% previews.each do |client, thumb_url, full_url| %>
47
+ <a href="<%= full_url %>">
48
+ <img src="<%= thumb_url %>" title="<%= client %>" width="119" height="84">
49
+ </a>
50
+ <% end %>
@@ -0,0 +1,35 @@
1
+ require "bundler"
2
+ Bundler.require
3
+
4
+ Litmus::Instant.api_key = ENV["API_KEY"] or abort("Error starting server - API_KEY required")
5
+
6
+ get '/' do
7
+ '<a href="/example">Open example</a>'
8
+ end
9
+
10
+ get '/example' do
11
+ message = params[:message] || 'Aloha world!'
12
+
13
+ result = Litmus::Instant.create_email('plain_text' => message)
14
+
15
+ email_guid = JSON.parse(result.body)['email_guid']
16
+ clients = %w(OL2000 GMAILNEW IPHONE6 THUNDERBIRDLATEST)
17
+ previews = clients.map do |client|
18
+ [client, Litmus::Instant.preview_image_url(email_guid, client, capture_size: 'thumb450')]
19
+ end
20
+ erb :example, locals: { previews: previews }
21
+ end
22
+
23
+ __END__
24
+
25
+ @@example
26
+ <p>
27
+ Add your custom message as a parameter,
28
+ <a href="?message=I like marmots">eg like this</a>.
29
+ <p>
30
+ <% previews.each do |client, url| %>
31
+ <figure>
32
+ <figcaption><%= client %></figcaption>
33
+ <img src="<%= url %>">
34
+ </figure>
35
+ <% end %>
@@ -0,0 +1,419 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://instant-api.litmus.com/v1/clients/configurations
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Tue, 06 Oct 2015 11:30:30 GMT
23
+ Content-Type:
24
+ - application/json;charset=utf-8
25
+ Content-Length:
26
+ - '5766'
27
+ Connection:
28
+ - keep-alive
29
+ Strict-Transport-Security:
30
+ - max-age=3600; includeSubdomains; preload
31
+ X-Frame-Options:
32
+ - DENY
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ {
39
+ "OL2000": {
40
+ "orientation_options": [
41
+ "vertical"
42
+ ],
43
+ "images_options": [
44
+ "allowed"
45
+ ]
46
+ },
47
+ "OL2002": {
48
+ "orientation_options": [
49
+ "vertical"
50
+ ],
51
+ "images_options": [
52
+ "allowed"
53
+ ]
54
+ },
55
+ "OL2003": {
56
+ "orientation_options": [
57
+ "vertical"
58
+ ],
59
+ "images_options": [
60
+ "allowed",
61
+ "blocked"
62
+ ]
63
+ },
64
+ "OL2007": {
65
+ "orientation_options": [
66
+ "vertical"
67
+ ],
68
+ "images_options": [
69
+ "allowed",
70
+ "blocked"
71
+ ]
72
+ },
73
+ "OL2010": {
74
+ "orientation_options": [
75
+ "vertical"
76
+ ],
77
+ "images_options": [
78
+ "allowed",
79
+ "blocked"
80
+ ]
81
+ },
82
+ "OL2013": {
83
+ "orientation_options": [
84
+ "vertical"
85
+ ],
86
+ "images_options": [
87
+ "allowed",
88
+ "blocked"
89
+ ]
90
+ },
91
+ "CHROMEYAHOO": {
92
+ "orientation_options": [
93
+ "vertical"
94
+ ],
95
+ "images_options": [
96
+ "allowed",
97
+ "blocked"
98
+ ]
99
+ },
100
+ "FFYAHOO": {
101
+ "orientation_options": [
102
+ "vertical"
103
+ ],
104
+ "images_options": [
105
+ "allowed",
106
+ "blocked"
107
+ ]
108
+ },
109
+ "YAHOO": {
110
+ "orientation_options": [
111
+ "vertical"
112
+ ],
113
+ "images_options": [
114
+ "allowed",
115
+ "blocked"
116
+ ]
117
+ },
118
+ "GMAILNEW": {
119
+ "orientation_options": [
120
+ "vertical"
121
+ ],
122
+ "images_options": [
123
+ "allowed",
124
+ "blocked"
125
+ ]
126
+ },
127
+ "FFGMAILNEW": {
128
+ "orientation_options": [
129
+ "vertical"
130
+ ],
131
+ "images_options": [
132
+ "allowed",
133
+ "blocked"
134
+ ]
135
+ },
136
+ "CHROMEGMAILNEW": {
137
+ "orientation_options": [
138
+ "vertical"
139
+ ],
140
+ "images_options": [
141
+ "allowed",
142
+ "blocked"
143
+ ]
144
+ },
145
+ "OL2015": {
146
+ "orientation_options": [
147
+ "vertical"
148
+ ],
149
+ "images_options": [
150
+ "allowed",
151
+ "blocked"
152
+ ]
153
+ },
154
+ "APPMAIL7": {
155
+ "orientation_options": [
156
+ "vertical"
157
+ ],
158
+ "images_options": [
159
+ "allowed"
160
+ ]
161
+ },
162
+ "APPMAIL8": {
163
+ "orientation_options": [
164
+ "vertical"
165
+ ],
166
+ "images_options": [
167
+ "allowed",
168
+ "blocked"
169
+ ]
170
+ },
171
+ "OL2011": {
172
+ "orientation_options": [
173
+ "vertical"
174
+ ],
175
+ "images_options": [
176
+ "allowed"
177
+ ]
178
+ },
179
+ "OUTLOOKCOM": {
180
+ "orientation_options": [
181
+ "vertical"
182
+ ],
183
+ "images_options": [
184
+ "allowed",
185
+ "blocked"
186
+ ]
187
+ },
188
+ "FFOUTLOOKCOM": {
189
+ "orientation_options": [
190
+ "vertical"
191
+ ],
192
+ "images_options": [
193
+ "allowed",
194
+ "blocked"
195
+ ]
196
+ },
197
+ "CHROMEOUTLOOKCOM": {
198
+ "orientation_options": [
199
+ "vertical"
200
+ ],
201
+ "images_options": [
202
+ "allowed",
203
+ "blocked"
204
+ ]
205
+ },
206
+ "IPAD": {
207
+ "orientation_options": [
208
+ "vertical"
209
+ ],
210
+ "images_options": [
211
+ "allowed"
212
+ ]
213
+ },
214
+ "IPADMINI": {
215
+ "orientation_options": [
216
+ "vertical"
217
+ ],
218
+ "images_options": [
219
+ "allowed"
220
+ ]
221
+ },
222
+ "IPHONE5S": {
223
+ "orientation_options": [
224
+ "vertical"
225
+ ],
226
+ "images_options": [
227
+ "allowed"
228
+ ]
229
+ },
230
+ "IPHONE5SIOS8": {
231
+ "orientation_options": [
232
+ "vertical"
233
+ ],
234
+ "images_options": [
235
+ "allowed"
236
+ ]
237
+ },
238
+ "IPHONE6": {
239
+ "orientation_options": [
240
+ "vertical"
241
+ ],
242
+ "images_options": [
243
+ "allowed"
244
+ ]
245
+ },
246
+ "IPHONE6PLUS": {
247
+ "orientation_options": [
248
+ "vertical"
249
+ ],
250
+ "images_options": [
251
+ "allowed"
252
+ ]
253
+ },
254
+ "THUNDERBIRDLATEST": {
255
+ "orientation_options": [
256
+ "vertical"
257
+ ],
258
+ "images_options": [
259
+ "allowed",
260
+ "blocked"
261
+ ]
262
+ },
263
+ "PLAINTEXT": {
264
+ "orientation_options": [
265
+ "vertical"
266
+ ],
267
+ "images_options": [
268
+ "allowed"
269
+ ]
270
+ },
271
+ "AOLONLINE": {
272
+ "orientation_options": [
273
+ "vertical"
274
+ ],
275
+ "images_options": [
276
+ "allowed",
277
+ "blocked"
278
+ ]
279
+ },
280
+ "FFAOLONLINE": {
281
+ "orientation_options": [
282
+ "vertical"
283
+ ],
284
+ "images_options": [
285
+ "allowed",
286
+ "blocked"
287
+ ]
288
+ },
289
+ "CHROMEAOLONLINE": {
290
+ "orientation_options": [
291
+ "vertical"
292
+ ],
293
+ "images_options": [
294
+ "allowed",
295
+ "blocked"
296
+ ]
297
+ },
298
+ "GOOGLEAPPS": {
299
+ "orientation_options": [
300
+ "vertical"
301
+ ],
302
+ "images_options": [
303
+ "allowed",
304
+ "blocked"
305
+ ]
306
+ },
307
+ "FFGOOGLEAPPS": {
308
+ "orientation_options": [
309
+ "vertical"
310
+ ],
311
+ "images_options": [
312
+ "allowed",
313
+ "blocked"
314
+ ]
315
+ },
316
+ "CHROMEGOOGLEAPPS": {
317
+ "orientation_options": [
318
+ "vertical"
319
+ ],
320
+ "images_options": [
321
+ "allowed",
322
+ "blocked"
323
+ ]
324
+ },
325
+ "COLORBLIND": {
326
+ "orientation_options": [
327
+ "vertical"
328
+ ],
329
+ "images_options": [
330
+ "allowed"
331
+ ]
332
+ },
333
+ "NOTES7": {
334
+ "orientation_options": [
335
+ "vertical"
336
+ ],
337
+ "images_options": [
338
+ "allowed"
339
+ ]
340
+ },
341
+ "NOTES8": {
342
+ "orientation_options": [
343
+ "vertical"
344
+ ],
345
+ "images_options": [
346
+ "allowed"
347
+ ]
348
+ },
349
+ "NOTES85": {
350
+ "orientation_options": [
351
+ "vertical"
352
+ ],
353
+ "images_options": [
354
+ "allowed"
355
+ ]
356
+ },
357
+ "NOTES9": {
358
+ "orientation_options": [
359
+ "vertical"
360
+ ],
361
+ "images_options": [
362
+ "allowed"
363
+ ]
364
+ },
365
+ "OFFICE365": {
366
+ "orientation_options": [
367
+ "vertical"
368
+ ],
369
+ "images_options": [
370
+ "allowed",
371
+ "blocked"
372
+ ]
373
+ },
374
+ "FFOFFICE365": {
375
+ "orientation_options": [
376
+ "vertical"
377
+ ],
378
+ "images_options": [
379
+ "allowed",
380
+ "blocked"
381
+ ]
382
+ },
383
+ "CHROMEOFFICE365": {
384
+ "orientation_options": [
385
+ "vertical"
386
+ ],
387
+ "images_options": [
388
+ "allowed",
389
+ "blocked"
390
+ ]
391
+ },
392
+ "OL2013DPI120": {
393
+ "orientation_options": [
394
+ "vertical"
395
+ ],
396
+ "images_options": [
397
+ "allowed"
398
+ ]
399
+ },
400
+ "ANDROIDGMAILAPP": {
401
+ "orientation_options": [
402
+ "vertical"
403
+ ],
404
+ "images_options": [
405
+ "allowed"
406
+ ]
407
+ },
408
+ "ANDROID4": {
409
+ "orientation_options": [
410
+ "vertical"
411
+ ],
412
+ "images_options": [
413
+ "allowed"
414
+ ]
415
+ }
416
+ }
417
+ http_version:
418
+ recorded_at: Tue, 06 Oct 2015 11:30:33 GMT
419
+ recorded_with: VCR 2.9.3