parse-ruby-client 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +2 -1
  3. data/Gemfile +4 -6
  4. data/Gemfile.lock +18 -18
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/example.rb +2 -1
  9. data/fixtures/vcr_cassettes/test_batch_update_nils_delete_keys.yml +57 -0
  10. data/fixtures/vcr_cassettes/test_empty_response.yml +72 -0
  11. data/fixtures/vcr_cassettes/test_get_missing.yml +95 -38
  12. data/fixtures/vcr_cassettes/test_image_file_associate_with_object.yml +2089 -0
  13. data/fixtures/vcr_cassettes/test_image_file_save.yml +1928 -0
  14. data/fixtures/vcr_cassettes/test_object_id.yml +56 -0
  15. data/fixtures/vcr_cassettes/test_reset_password.yml +109 -0
  16. data/fixtures/vcr_cassettes/test_retries.yml +357 -0
  17. data/fixtures/vcr_cassettes/test_retries_404.yml +72 -0
  18. data/fixtures/vcr_cassettes/test_retries_404_correct.yml +72 -0
  19. data/fixtures/vcr_cassettes/test_retries_json_error.yml +357 -0
  20. data/fixtures/vcr_cassettes/test_retries_server_error.yml +357 -0
  21. data/fixtures/vcr_cassettes/test_server_update.yml +248 -191
  22. data/fixtures/vcr_cassettes/test_user_login.yml +276 -0
  23. data/fixtures/vcr_cassettes/test_xget.yml +280 -0
  24. data/lib/faraday/better_retry.rb +94 -0
  25. data/lib/faraday/extended_parse_json.rb +39 -0
  26. data/lib/faraday/get_method_override.rb +32 -0
  27. data/lib/parse-ruby-client.rb +9 -9
  28. data/lib/parse/batch.rb +2 -3
  29. data/lib/parse/client.rb +72 -161
  30. data/lib/parse/cloud.rb +2 -1
  31. data/lib/parse/datatypes.rb +6 -1
  32. data/lib/parse/error.rb +7 -3
  33. data/lib/parse/installation.rb +18 -0
  34. data/lib/parse/model.rb +2 -1
  35. data/lib/parse/object.rb +7 -1
  36. data/lib/parse/protocol.rb +10 -0
  37. data/lib/parse/push.rb +3 -0
  38. data/lib/parse/query.rb +5 -2
  39. data/lib/parse/user.rb +1 -0
  40. data/lib/parse/util.rb +2 -0
  41. data/parse-ruby-client.gemspec +35 -15
  42. data/test/helper.rb +55 -1
  43. data/test/middleware/better_retry_test.rb +57 -0
  44. data/test/middleware/extend_parse_json_test.rb +55 -0
  45. data/test/test_client.rb +78 -28
  46. data/test/test_datatypes.rb +14 -0
  47. data/test/test_object.rb +16 -0
  48. metadata +39 -34
  49. data/lib/parse/http_client.rb +0 -84
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.parse.com/1/classes/Post
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"title\":\"hello world\"}"
9
+ headers:
10
+ User-Agent:
11
+ - Parse for Ruby, 0.0
12
+ X-Parse-Application-Id:
13
+ - <X-Parse-Application-Id>
14
+ X-Parse-Rest-Api-Key:
15
+ - <X-Parse-REST-API-Key>
16
+ Content-Type:
17
+ - application/json
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Access-Control-Request-Method:
28
+ - "*"
29
+ Cache-Control:
30
+ - no-cache
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Date:
34
+ - Sun, 28 Apr 2013 13:34:36 GMT
35
+ Location:
36
+ - https://api.parse.com/1/classes/Post/8q7HUf9da6
37
+ Server:
38
+ - nginx/1.2.2
39
+ Set-Cookie:
40
+ - <COOKIE-KEY>
41
+ Status:
42
+ - 201 Created
43
+ X-Runtime:
44
+ - "0.027185"
45
+ X-Ua-Compatible:
46
+ - IE=Edge,chrome=1
47
+ Content-Length:
48
+ - "64"
49
+ Connection:
50
+ - keep-alive
51
+ body:
52
+ encoding: US-ASCII
53
+ string: "{\"createdAt\":\"2013-04-28T13:34:36.083Z\",\"objectId\":\"8q7HUf9da6\"}"
54
+ http_version:
55
+ recorded_at: Sun, 28 Apr 2013 13:34:36 GMT
56
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.parse.com/1/users
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"username\":\"alan484032810566@gmail.com\",\"password\":\"secret\"}"
9
+ headers:
10
+ User-Agent:
11
+ - Parse for Ruby, 0.0
12
+ X-Parse-Application-Id:
13
+ - <X-Parse-Application-Id>
14
+ X-Parse-Rest-Api-Key:
15
+ - <X-Parse-REST-API-Key>
16
+ Content-Type:
17
+ - application/json
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Access-Control-Request-Method:
28
+ - "*"
29
+ Cache-Control:
30
+ - no-cache
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Date:
34
+ - Sun, 28 Apr 2013 13:39:32 GMT
35
+ Location:
36
+ - https://api.parse.com/1/users/QCdEAzgWvT
37
+ Server:
38
+ - nginx/1.2.2
39
+ Set-Cookie:
40
+ - <COOKIE-KEY>
41
+ Status:
42
+ - 201 Created
43
+ X-Runtime:
44
+ - "0.298831"
45
+ X-Ua-Compatible:
46
+ - IE=Edge,chrome=1
47
+ Content-Length:
48
+ - "107"
49
+ Connection:
50
+ - keep-alive
51
+ body:
52
+ encoding: US-ASCII
53
+ string: "{\"createdAt\":\"2013-04-28T13:39:32.913Z\",\"objectId\":\"QCdEAzgWvT\",\"sessionToken\":\"54q4sb3zxv8l8j3x4ke5p5emh\"}"
54
+ http_version:
55
+ recorded_at: Sun, 28 Apr 2013 13:39:33 GMT
56
+ - request:
57
+ method: post
58
+ uri: https://api.parse.com/1/requestPasswordReset
59
+ body:
60
+ encoding: UTF-8
61
+ string: "{\"email\":\"alan484032810566@gmail.com\"}"
62
+ headers:
63
+ User-Agent:
64
+ - Parse for Ruby, 0.0
65
+ X-Parse-Application-Id:
66
+ - <X-Parse-Application-Id>
67
+ X-Parse-Rest-Api-Key:
68
+ - <X-Parse-REST-API-Key>
69
+ Content-Type:
70
+ - application/json
71
+ Accept:
72
+ - "*/*"
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ Access-Control-Allow-Origin:
79
+ - "*"
80
+ Access-Control-Request-Method:
81
+ - "*"
82
+ Cache-Control:
83
+ - max-age=0, private, must-revalidate
84
+ Content-Type:
85
+ - application/json; charset=utf-8
86
+ Date:
87
+ - Sun, 28 Apr 2013 13:39:34 GMT
88
+ Etag:
89
+ - "\"99914b932bd37a50b983c5e7c90ae93b\""
90
+ Server:
91
+ - nginx/1.2.2
92
+ Set-Cookie:
93
+ - <COOKIE-KEY>
94
+ Status:
95
+ - 200 OK
96
+ X-Runtime:
97
+ - "0.352021"
98
+ X-Ua-Compatible:
99
+ - IE=Edge,chrome=1
100
+ Content-Length:
101
+ - "2"
102
+ Connection:
103
+ - keep-alive
104
+ body:
105
+ encoding: US-ASCII
106
+ string: "{}"
107
+ http_version:
108
+ recorded_at: Sun, 28 Apr 2013 13:39:34 GMT
109
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,357 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.parse.com/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Parse for Ruby, 0.0
12
+ Content-Type:
13
+ - application/json
14
+ X-Parse-Application-Id:
15
+ - <X-Parse-Application-Id>
16
+ X-Parse-Rest-Api-Key:
17
+ - <X-Parse-REST-API-Key>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - '*/*'
22
+ response:
23
+ status:
24
+ code: 404
25
+ message: Not Found
26
+ headers:
27
+ Content-Type:
28
+ - text/html; charset=utf-8
29
+ Date:
30
+ - Wed, 26 Mar 2014 16:48:05 GMT
31
+ Server:
32
+ - nginx/1.4.2
33
+ Status:
34
+ - 404 Not Found
35
+ X-Runtime:
36
+ - '0.036153'
37
+ Content-Length:
38
+ - '433'
39
+ Connection:
40
+ - keep-alive
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ <!DOCTYPE html>
45
+ <html>
46
+ <head>
47
+ <title>The page you were looking for doesn't exist (404)</title>
48
+ <style type="text/css">
49
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
50
+ div.dialog {
51
+ width: 25em;
52
+ padding: 0 4em;
53
+ margin: 4em auto 0 auto;
54
+ border: 1px solid #ccc;
55
+ border-right-color: #999;
56
+ border-bottom-color: #999;
57
+ }
58
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
59
+ </style>
60
+ </head>
61
+
62
+ <body>
63
+ <!-- This file lives in public/404.html -->
64
+ <div class="dialog">
65
+ <h1>The page you were looking for doesn't exist.</h1>
66
+ <p>You may have mistyped the address or the page may have moved.</p>
67
+ </div>
68
+ </body>
69
+ </html>
70
+ http_version:
71
+ recorded_at: Wed, 26 Mar 2014 16:48:06 GMT
72
+ - request:
73
+ method: get
74
+ uri: https://api.parse.com/
75
+ body:
76
+ encoding: UTF-8
77
+ string: |
78
+ <!DOCTYPE html>
79
+ <html>
80
+ <head>
81
+ <title>The page you were looking for doesn't exist (404)</title>
82
+ <style type="text/css">
83
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
84
+ div.dialog {
85
+ width: 25em;
86
+ padding: 0 4em;
87
+ margin: 4em auto 0 auto;
88
+ border: 1px solid #ccc;
89
+ border-right-color: #999;
90
+ border-bottom-color: #999;
91
+ }
92
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
93
+ </style>
94
+ </head>
95
+
96
+ <body>
97
+ <!-- This file lives in public/404.html -->
98
+ <div class="dialog">
99
+ <h1>The page you were looking for doesn't exist.</h1>
100
+ <p>You may have mistyped the address or the page may have moved.</p>
101
+ </div>
102
+ </body>
103
+ </html>
104
+ headers:
105
+ User-Agent:
106
+ - Parse for Ruby, 0.0
107
+ Content-Type:
108
+ - application/json
109
+ X-Parse-Application-Id:
110
+ - <X-Parse-Application-Id>
111
+ X-Parse-Rest-Api-Key:
112
+ - <X-Parse-REST-API-Key>
113
+ Accept-Encoding:
114
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
115
+ Accept:
116
+ - '*/*'
117
+ response:
118
+ status:
119
+ code: 404
120
+ message: Not Found
121
+ headers:
122
+ Content-Type:
123
+ - text/html; charset=utf-8
124
+ Date:
125
+ - Wed, 26 Mar 2014 16:48:07 GMT
126
+ Server:
127
+ - nginx/1.4.4
128
+ Status:
129
+ - 404 Not Found
130
+ X-Runtime:
131
+ - '0.004166'
132
+ Content-Length:
133
+ - '433'
134
+ Connection:
135
+ - keep-alive
136
+ body:
137
+ encoding: UTF-8
138
+ string: |
139
+ <!DOCTYPE html>
140
+ <html>
141
+ <head>
142
+ <title>The page you were looking for doesn't exist (404)</title>
143
+ <style type="text/css">
144
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
145
+ div.dialog {
146
+ width: 25em;
147
+ padding: 0 4em;
148
+ margin: 4em auto 0 auto;
149
+ border: 1px solid #ccc;
150
+ border-right-color: #999;
151
+ border-bottom-color: #999;
152
+ }
153
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
154
+ </style>
155
+ </head>
156
+
157
+ <body>
158
+ <!-- This file lives in public/404.html -->
159
+ <div class="dialog">
160
+ <h1>The page you were looking for doesn't exist.</h1>
161
+ <p>You may have mistyped the address or the page may have moved.</p>
162
+ </div>
163
+ </body>
164
+ </html>
165
+ http_version:
166
+ recorded_at: Wed, 26 Mar 2014 16:48:07 GMT
167
+ - request:
168
+ method: get
169
+ uri: https://api.parse.com/
170
+ body:
171
+ encoding: UTF-8
172
+ string: |
173
+ <!DOCTYPE html>
174
+ <html>
175
+ <head>
176
+ <title>The page you were looking for doesn't exist (404)</title>
177
+ <style type="text/css">
178
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
179
+ div.dialog {
180
+ width: 25em;
181
+ padding: 0 4em;
182
+ margin: 4em auto 0 auto;
183
+ border: 1px solid #ccc;
184
+ border-right-color: #999;
185
+ border-bottom-color: #999;
186
+ }
187
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
188
+ </style>
189
+ </head>
190
+
191
+ <body>
192
+ <!-- This file lives in public/404.html -->
193
+ <div class="dialog">
194
+ <h1>The page you were looking for doesn't exist.</h1>
195
+ <p>You may have mistyped the address or the page may have moved.</p>
196
+ </div>
197
+ </body>
198
+ </html>
199
+ headers:
200
+ User-Agent:
201
+ - Parse for Ruby, 0.0
202
+ Content-Type:
203
+ - application/json
204
+ X-Parse-Application-Id:
205
+ - <X-Parse-Application-Id>
206
+ X-Parse-Rest-Api-Key:
207
+ - <X-Parse-REST-API-Key>
208
+ Accept-Encoding:
209
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
210
+ Accept:
211
+ - '*/*'
212
+ response:
213
+ status:
214
+ code: 404
215
+ message: Not Found
216
+ headers:
217
+ Content-Type:
218
+ - text/html; charset=utf-8
219
+ Date:
220
+ - Wed, 26 Mar 2014 16:48:09 GMT
221
+ Server:
222
+ - nginx/1.4.2
223
+ Status:
224
+ - 404 Not Found
225
+ X-Runtime:
226
+ - '0.005221'
227
+ Content-Length:
228
+ - '433'
229
+ Connection:
230
+ - keep-alive
231
+ body:
232
+ encoding: UTF-8
233
+ string: |
234
+ <!DOCTYPE html>
235
+ <html>
236
+ <head>
237
+ <title>The page you were looking for doesn't exist (404)</title>
238
+ <style type="text/css">
239
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
240
+ div.dialog {
241
+ width: 25em;
242
+ padding: 0 4em;
243
+ margin: 4em auto 0 auto;
244
+ border: 1px solid #ccc;
245
+ border-right-color: #999;
246
+ border-bottom-color: #999;
247
+ }
248
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
249
+ </style>
250
+ </head>
251
+
252
+ <body>
253
+ <!-- This file lives in public/404.html -->
254
+ <div class="dialog">
255
+ <h1>The page you were looking for doesn't exist.</h1>
256
+ <p>You may have mistyped the address or the page may have moved.</p>
257
+ </div>
258
+ </body>
259
+ </html>
260
+ http_version:
261
+ recorded_at: Wed, 26 Mar 2014 16:48:09 GMT
262
+ - request:
263
+ method: get
264
+ uri: https://api.parse.com/
265
+ body:
266
+ encoding: UTF-8
267
+ string: |
268
+ <!DOCTYPE html>
269
+ <html>
270
+ <head>
271
+ <title>The page you were looking for doesn't exist (404)</title>
272
+ <style type="text/css">
273
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
274
+ div.dialog {
275
+ width: 25em;
276
+ padding: 0 4em;
277
+ margin: 4em auto 0 auto;
278
+ border: 1px solid #ccc;
279
+ border-right-color: #999;
280
+ border-bottom-color: #999;
281
+ }
282
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
283
+ </style>
284
+ </head>
285
+
286
+ <body>
287
+ <!-- This file lives in public/404.html -->
288
+ <div class="dialog">
289
+ <h1>The page you were looking for doesn't exist.</h1>
290
+ <p>You may have mistyped the address or the page may have moved.</p>
291
+ </div>
292
+ </body>
293
+ </html>
294
+ headers:
295
+ User-Agent:
296
+ - Parse for Ruby, 0.0
297
+ Content-Type:
298
+ - application/json
299
+ X-Parse-Application-Id:
300
+ - <X-Parse-Application-Id>
301
+ X-Parse-Rest-Api-Key:
302
+ - <X-Parse-REST-API-Key>
303
+ Accept-Encoding:
304
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
305
+ Accept:
306
+ - '*/*'
307
+ response:
308
+ status:
309
+ code: 404
310
+ message: Not Found
311
+ headers:
312
+ Content-Type:
313
+ - text/html; charset=utf-8
314
+ Date:
315
+ - Wed, 26 Mar 2014 16:48:11 GMT
316
+ Server:
317
+ - nginx/1.4.2
318
+ Status:
319
+ - 404 Not Found
320
+ X-Runtime:
321
+ - '0.005602'
322
+ Content-Length:
323
+ - '433'
324
+ Connection:
325
+ - keep-alive
326
+ body:
327
+ encoding: UTF-8
328
+ string: |
329
+ <!DOCTYPE html>
330
+ <html>
331
+ <head>
332
+ <title>The page you were looking for doesn't exist (404)</title>
333
+ <style type="text/css">
334
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
335
+ div.dialog {
336
+ width: 25em;
337
+ padding: 0 4em;
338
+ margin: 4em auto 0 auto;
339
+ border: 1px solid #ccc;
340
+ border-right-color: #999;
341
+ border-bottom-color: #999;
342
+ }
343
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
344
+ </style>
345
+ </head>
346
+
347
+ <body>
348
+ <!-- This file lives in public/404.html -->
349
+ <div class="dialog">
350
+ <h1>The page you were looking for doesn't exist.</h1>
351
+ <p>You may have mistyped the address or the page may have moved.</p>
352
+ </div>
353
+ </body>
354
+ </html>
355
+ http_version:
356
+ recorded_at: Wed, 26 Mar 2014 16:48:11 GMT
357
+ recorded_with: VCR 2.4.0