litmus-instant 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Procfile +1 -0
  4. data/README.md +15 -0
  5. data/examples/Gemfile +1 -0
  6. data/examples/Gemfile.lock +3 -2
  7. data/examples/README.md +2 -0
  8. data/examples/config.ru +2 -0
  9. data/fixtures/vcr_cassettes/Litmus_Instant/Litmus_Instant_Client_provides_Litmus_Instant_class_methods_as_instance_methods.yml +191 -0
  10. data/fixtures/vcr_cassettes/Litmus_Instant/Litmus_Instant_Client_uses_its_own_config.yml +85 -0
  11. data/fixtures/vcr_cassettes/Litmus_Instant/client_configurations/returns_a_Hash_of_clients_and_their_available_options.yml +107 -11
  12. data/fixtures/vcr_cassettes/Litmus_Instant/clients/returns_an_array_of_client_names.yml +15 -4
  13. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_invalid_email_Hash_raise_a_request_error.yml +5 -41
  14. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_valid_email_Hash_optional_end_user_id_is_relayed.yml +6 -4
  15. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_valid_email_Hash_prerequest_configurations_is_relayed.yml +6 -4
  16. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/authenticated_with_valid_email_Hash_response_.yml +6 -42
  17. data/fixtures/vcr_cassettes/Litmus_Instant/create_email/unauthenticated_raises_an_authentication_error.yml +5 -5
  18. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/raises_NotFound_for_an_expired_email_guid.yml +2 -1630
  19. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/raises_RequestError_for_an_invalid_client.yml +9 -7
  20. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/raises_RequestError_for_an_invalid_email_guid.yml +2 -2
  21. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/returns_a_Hash_of_the_image_types.yml +13 -11
  22. data/fixtures/vcr_cassettes/Litmus_Instant/get_preview/supports_optional_capture_configuration.yml +13 -47
  23. data/fixtures/vcr_cassettes/Litmus_Instant/prefetch_previews/raises_RequestError_for_an_invalid_email_guid.yml +2 -2
  24. data/fixtures/vcr_cassettes/Litmus_Instant/prefetch_previews/raises_RequestError_if_any_invalid_configurations_are_present.yml +11 -9
  25. data/fixtures/vcr_cassettes/Litmus_Instant/prefetch_previews/responds_with_an_array_of_the_requested_configurations.yml +9 -7
  26. data/lib/litmus/instant.rb +106 -13
  27. data/lib/litmus/instant/version.rb +2 -2
  28. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b33b2790b147305678f1f7e5a78464370bfe0e30
4
- data.tar.gz: cff4d00209f901e4bb1206de3a8c4bef0eaae521
3
+ metadata.gz: ad9b8fa8bc97d92ca25106dd1099b488861f4b9d
4
+ data.tar.gz: b14bc1abf31ab0bd9c0b9ea0a88551300ec05e73
5
5
  SHA512:
6
- metadata.gz: c3793e2e0cc82c28606803293972475c6c4c7cf9c6952072a4484afae498f1bf24ecb52085e737e38f88d2b5b550bb44ba8bc2aa22cd05ef92b29582a7cf959b
7
- data.tar.gz: c3daaecb703ed155b23d67d5b76513e0f0a6680c2be05a0393378b2cbe2cd098689ed35da32f1073bfd991891e4bbfd2968715b794cdac703180ec40d0a2d3cd
6
+ metadata.gz: aeb6406d2d3776a1a10ce6c4a1735551ff39d7e91ecda76a6ef08c662113c3da44f2c3a60c3972a255923bf9fd95ef895574cffe29b56d312a17ef8ff6b8b261
7
+ data.tar.gz: 3370c2c65e935661b5873433fbc569457dc97baf1483a3e450876a9232cabfb7101ef08b9ccb2ff3d6d0d861f655f12fb6297cd08e0db50c5b37955820857713
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.3.1
4
4
  before_install: gem install bundler -v 1.10.6
@@ -0,0 +1 @@
1
+ web: cd examples && bundle exec rackup config.ru -p $PORT
data/README.md CHANGED
@@ -49,6 +49,19 @@ This could be used in a Rails erb template like so
49
49
  <%= image_tag @preview_url %>
50
50
  ```
51
51
 
52
+ ### OAuth and API client instantiation
53
+
54
+ Individual API client objects can be instantiated and expose an identical
55
+ interface to the class methods on `Litmus::Instant`, this the recommended
56
+ approach for acting on behalf of multiple Litmus users within the same
57
+ application, as each client can be configured with an OAuth token for each
58
+ authorized user in a thread safe manner:
59
+
60
+ ```ruby
61
+ api_client = Litmus::Instant::Client.new(oauth_token: "XXX")
62
+ api_client.create_email(plain_text: "Goodbye world.")
63
+ ```
64
+
52
65
  ### Performance
53
66
 
54
67
  In the example above the capture wouldn't be initiated until the end user's browser made the HTTP GET request to the preview URL. This would mean waiting the full capture time (a number of seconds) before the image data began to transfer.
@@ -87,6 +100,8 @@ Litmus::Instant.prefetch_previews(
87
100
 
88
101
  For further information see the [performance section](https://litmus.com/partners/api/documentation/instant/04-performance/) of the Instant API documentation.
89
102
 
103
+
104
+
90
105
  ### Handling errors
91
106
 
92
107
  Various errors may occur can occur during normal usage of the API, please code defensively to handle these.
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem "sinatra"
4
+ gem "httparty"
4
5
  gem "litmus-instant", path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../instant-api-ruby
3
3
  specs:
4
- litmus-instant (0.1.0)
4
+ litmus-instant (0.2.0)
5
5
  httparty (~> 0.13.5)
6
6
 
7
7
  GEM
@@ -25,8 +25,9 @@ PLATFORMS
25
25
  ruby
26
26
 
27
27
  DEPENDENCIES
28
+ httparty
28
29
  litmus-instant!
29
30
  sinatra
30
31
 
31
32
  BUNDLED WITH
32
- 1.10.6
33
+ 1.12.5
@@ -1,5 +1,7 @@
1
1
  # Examples of InstantAPI usage
2
2
 
3
+ See also https://github.com/litmus/litmus-oauth-example
4
+
3
5
  ## Prerequisites
4
6
 
5
7
  - ruby
@@ -0,0 +1,2 @@
1
+ require "./example_oauth"
2
+ run Sinatra::Application
@@ -0,0 +1,191 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://instant-api.litmus.com/v1/clients
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
+ - Mon, 20 Jun 2016 18:34:56 GMT
23
+ Content-Type:
24
+ - application/json;charset=utf-8
25
+ Content-Length:
26
+ - '845'
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
+ "ANDROID4",
40
+ "ANDROIDGMAILAPP",
41
+ "AOLONLINE",
42
+ "APPMAIL8",
43
+ "APPMAIL9",
44
+ "CHROMEAOLONLINE",
45
+ "CHROMEGMAILNEW",
46
+ "CHROMEGMXDE",
47
+ "CHROMEGOOGLEAPPS",
48
+ "CHROMEGOOGLEINBOX",
49
+ "CHROMEOFFICE365",
50
+ "CHROMEOUTLOOKCOM",
51
+ "CHROMEWEBDE",
52
+ "CHROMEYAHOO",
53
+ "COLORBLIND",
54
+ "FFAOLONLINE",
55
+ "FFGMAILNEW",
56
+ "FFGMXDE",
57
+ "FFGOOGLEAPPS",
58
+ "FFGOOGLEINBOX",
59
+ "FFOFFICE365",
60
+ "FFOUTLOOKCOM",
61
+ "FFWEBDE",
62
+ "FFYAHOO",
63
+ "GMAILNEW",
64
+ "GMXDE",
65
+ "GOOGLEAPPS",
66
+ "IPAD",
67
+ "IPADMINI",
68
+ "IPHONE5S",
69
+ "IPHONE5SIOS8",
70
+ "IPHONE6",
71
+ "IPHONE6PLUS",
72
+ "IPHONE6S",
73
+ "IPHONE6SPLUS",
74
+ "NOTES7",
75
+ "NOTES8",
76
+ "NOTES85",
77
+ "NOTES9",
78
+ "OFFICE365",
79
+ "OL2000",
80
+ "OL2002",
81
+ "OL2003",
82
+ "OL2007",
83
+ "OL2010",
84
+ "OL2011",
85
+ "OL2013",
86
+ "OL2013DPI120",
87
+ "OL2015",
88
+ "OL2016",
89
+ "OUTLOOKCOM",
90
+ "PLAINTEXT",
91
+ "THUNDERBIRDLATEST",
92
+ "WEBDE",
93
+ "YAHOO"
94
+ ]
95
+ http_version:
96
+ recorded_at: Mon, 20 Jun 2016 18:34:58 GMT
97
+ - request:
98
+ method: get
99
+ uri: https://instant-api.litmus.com/v1/clients
100
+ body:
101
+ encoding: US-ASCII
102
+ string: ''
103
+ headers:
104
+ Content-Type:
105
+ - application/json
106
+ Accept:
107
+ - application/json
108
+ response:
109
+ status:
110
+ code: 200
111
+ message: OK
112
+ headers:
113
+ Server:
114
+ - nginx
115
+ Date:
116
+ - Mon, 20 Jun 2016 18:34:57 GMT
117
+ Content-Type:
118
+ - application/json;charset=utf-8
119
+ Content-Length:
120
+ - '845'
121
+ Connection:
122
+ - keep-alive
123
+ Strict-Transport-Security:
124
+ - max-age=3600; includeSubdomains; preload
125
+ X-Frame-Options:
126
+ - DENY
127
+ X-Content-Type-Options:
128
+ - nosniff
129
+ body:
130
+ encoding: UTF-8
131
+ string: |-
132
+ [
133
+ "ANDROID4",
134
+ "ANDROIDGMAILAPP",
135
+ "AOLONLINE",
136
+ "APPMAIL8",
137
+ "APPMAIL9",
138
+ "CHROMEAOLONLINE",
139
+ "CHROMEGMAILNEW",
140
+ "CHROMEGMXDE",
141
+ "CHROMEGOOGLEAPPS",
142
+ "CHROMEGOOGLEINBOX",
143
+ "CHROMEOFFICE365",
144
+ "CHROMEOUTLOOKCOM",
145
+ "CHROMEWEBDE",
146
+ "CHROMEYAHOO",
147
+ "COLORBLIND",
148
+ "FFAOLONLINE",
149
+ "FFGMAILNEW",
150
+ "FFGMXDE",
151
+ "FFGOOGLEAPPS",
152
+ "FFGOOGLEINBOX",
153
+ "FFOFFICE365",
154
+ "FFOUTLOOKCOM",
155
+ "FFWEBDE",
156
+ "FFYAHOO",
157
+ "GMAILNEW",
158
+ "GMXDE",
159
+ "GOOGLEAPPS",
160
+ "IPAD",
161
+ "IPADMINI",
162
+ "IPHONE5S",
163
+ "IPHONE5SIOS8",
164
+ "IPHONE6",
165
+ "IPHONE6PLUS",
166
+ "IPHONE6S",
167
+ "IPHONE6SPLUS",
168
+ "NOTES7",
169
+ "NOTES8",
170
+ "NOTES85",
171
+ "NOTES9",
172
+ "OFFICE365",
173
+ "OL2000",
174
+ "OL2002",
175
+ "OL2003",
176
+ "OL2007",
177
+ "OL2010",
178
+ "OL2011",
179
+ "OL2013",
180
+ "OL2013DPI120",
181
+ "OL2015",
182
+ "OL2016",
183
+ "OUTLOOKCOM",
184
+ "PLAINTEXT",
185
+ "THUNDERBIRDLATEST",
186
+ "WEBDE",
187
+ "YAHOO"
188
+ ]
189
+ http_version:
190
+ recorded_at: Mon, 20 Jun 2016 18:34:59 GMT
191
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,85 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://instant-api.litmus.com/v1/emails
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"plain_text":"boo"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Authorization:
15
+ - Basic aW52YWxpZF9rZXk6
16
+ response:
17
+ status:
18
+ code: 401
19
+ message: Unauthorized
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Mon, 20 Jun 2016 18:34:57 GMT
25
+ Content-Type:
26
+ - application/json;charset=utf-8
27
+ Content-Length:
28
+ - '328'
29
+ Connection:
30
+ - keep-alive
31
+ Www-Authenticate:
32
+ - Basic realm="Litmus Instant API"
33
+ body:
34
+ encoding: UTF-8
35
+ string: |-
36
+ {
37
+ "status": 401,
38
+ "title": "Unauthorized",
39
+ "description": "API Authentication credentials were missing or incorrect. Make sure the credentials you're making the request with match those you were provided. If you're stuck, please email resellers@litmus.com and we'll have a Support Engineer reach out as soon as possible."
40
+ }
41
+ http_version:
42
+ recorded_at: Mon, 20 Jun 2016 18:34:59 GMT
43
+ - request:
44
+ method: post
45
+ uri: https://instant-api.litmus.com/v1/emails
46
+ body:
47
+ encoding: UTF-8
48
+ string: '{"plain_text":"boo"}'
49
+ headers:
50
+ Content-Type:
51
+ - application/json
52
+ Accept:
53
+ - application/json
54
+ Authorization:
55
+ - Basic Y3hkNHR1c3F3b2tnZ2dseGl6ZDl2cDd6bXV4dmo2eG95a2UxOg==
56
+ response:
57
+ status:
58
+ code: 200
59
+ message: OK
60
+ headers:
61
+ Server:
62
+ - nginx
63
+ Date:
64
+ - Mon, 20 Jun 2016 18:34:57 GMT
65
+ Content-Type:
66
+ - application/json;charset=utf-8
67
+ Content-Length:
68
+ - '58'
69
+ Connection:
70
+ - keep-alive
71
+ Strict-Transport-Security:
72
+ - max-age=3600; includeSubdomains; preload
73
+ X-Frame-Options:
74
+ - DENY
75
+ X-Content-Type-Options:
76
+ - nosniff
77
+ body:
78
+ encoding: UTF-8
79
+ string: |-
80
+ {
81
+ "email_guid": "98f7d82b-982d-44f2-8818-45a2284cb974"
82
+ }
83
+ http_version:
84
+ recorded_at: Mon, 20 Jun 2016 18:35:00 GMT
85
+ recorded_with: VCR 2.9.3
@@ -19,11 +19,11 @@ http_interactions:
19
19
  Server:
20
20
  - nginx
21
21
  Date:
22
- - Tue, 06 Oct 2015 11:30:30 GMT
22
+ - Mon, 20 Jun 2016 11:43:49 GMT
23
23
  Content-Type:
24
24
  - application/json;charset=utf-8
25
25
  Content-Length:
26
- - '5766'
26
+ - '7236'
27
27
  Connection:
28
28
  - keep-alive
29
29
  Strict-Transport-Security:
@@ -151,14 +151,6 @@ http_interactions:
151
151
  "blocked"
152
152
  ]
153
153
  },
154
- "APPMAIL7": {
155
- "orientation_options": [
156
- "vertical"
157
- ],
158
- "images_options": [
159
- "allowed"
160
- ]
161
- },
162
154
  "APPMAIL8": {
163
155
  "orientation_options": [
164
156
  "vertical"
@@ -397,6 +389,15 @@ http_interactions:
397
389
  "allowed"
398
390
  ]
399
391
  },
392
+ "OL2016": {
393
+ "orientation_options": [
394
+ "vertical"
395
+ ],
396
+ "images_options": [
397
+ "allowed",
398
+ "blocked"
399
+ ]
400
+ },
400
401
  "ANDROIDGMAILAPP": {
401
402
  "orientation_options": [
402
403
  "vertical"
@@ -412,8 +413,103 @@ http_interactions:
412
413
  "images_options": [
413
414
  "allowed"
414
415
  ]
416
+ },
417
+ "IPHONE6S": {
418
+ "orientation_options": [
419
+ "vertical"
420
+ ],
421
+ "images_options": [
422
+ "allowed"
423
+ ]
424
+ },
425
+ "IPHONE6SPLUS": {
426
+ "orientation_options": [
427
+ "vertical"
428
+ ],
429
+ "images_options": [
430
+ "allowed"
431
+ ]
432
+ },
433
+ "GMXDE": {
434
+ "orientation_options": [
435
+ "vertical"
436
+ ],
437
+ "images_options": [
438
+ "allowed",
439
+ "blocked"
440
+ ]
441
+ },
442
+ "FFGMXDE": {
443
+ "orientation_options": [
444
+ "vertical"
445
+ ],
446
+ "images_options": [
447
+ "allowed",
448
+ "blocked"
449
+ ]
450
+ },
451
+ "CHROMEGMXDE": {
452
+ "orientation_options": [
453
+ "vertical"
454
+ ],
455
+ "images_options": [
456
+ "allowed",
457
+ "blocked"
458
+ ]
459
+ },
460
+ "WEBDE": {
461
+ "orientation_options": [
462
+ "vertical"
463
+ ],
464
+ "images_options": [
465
+ "allowed",
466
+ "blocked"
467
+ ]
468
+ },
469
+ "FFWEBDE": {
470
+ "orientation_options": [
471
+ "vertical"
472
+ ],
473
+ "images_options": [
474
+ "allowed",
475
+ "blocked"
476
+ ]
477
+ },
478
+ "CHROMEWEBDE": {
479
+ "orientation_options": [
480
+ "vertical"
481
+ ],
482
+ "images_options": [
483
+ "allowed",
484
+ "blocked"
485
+ ]
486
+ },
487
+ "APPMAIL9": {
488
+ "orientation_options": [
489
+ "vertical"
490
+ ],
491
+ "images_options": [
492
+ "allowed",
493
+ "blocked"
494
+ ]
495
+ },
496
+ "FFGOOGLEINBOX": {
497
+ "orientation_options": [
498
+ "vertical"
499
+ ],
500
+ "images_options": [
501
+ "allowed"
502
+ ]
503
+ },
504
+ "CHROMEGOOGLEINBOX": {
505
+ "orientation_options": [
506
+ "vertical"
507
+ ],
508
+ "images_options": [
509
+ "allowed"
510
+ ]
415
511
  }
416
512
  }
417
513
  http_version:
418
- recorded_at: Tue, 06 Oct 2015 11:30:33 GMT
514
+ recorded_at: Mon, 20 Jun 2016 11:43:51 GMT
419
515
  recorded_with: VCR 2.9.3