vhx-ruby 0.0.7 → 0.0.8

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/lib/vhx.rb +4 -3
  4. data/lib/vhx/client.rb +6 -3
  5. data/lib/vhx/objects/analytics.rb +9 -0
  6. data/lib/vhx/utilities/vhx_object.rb +2 -2
  7. data/lib/vhx/version.rb +2 -2
  8. data/spec/client_spec.rb +44 -9
  9. data/spec/fixtures/sample_authorization_response.json +19 -0
  10. data/spec/fixtures/sample_collection_response.json +20 -0
  11. data/spec/fixtures/sample_collections_response.json +14 -0
  12. data/spec/fixtures/sample_create_video_response.json +33 -0
  13. data/spec/fixtures/sample_customer_response.json +16 -0
  14. data/spec/fixtures/sample_customers_response.json +28 -0
  15. data/spec/fixtures/sample_files_response.json +16 -0
  16. data/spec/fixtures/sample_product_response.json +30 -0
  17. data/spec/fixtures/sample_products_response.json +14 -0
  18. data/spec/fixtures/sample_video_response.json +47 -31
  19. data/spec/fixtures/sample_videos_response.json +14 -0
  20. data/spec/middleware/error_response_spec.rb +3 -7
  21. data/spec/middleware/oauth2_spec.rb +3 -7
  22. data/spec/objects/analytics_spec.rb +41 -0
  23. data/spec/objects/authorization_spec.rb +58 -0
  24. data/spec/objects/collection_item_spec.rb +53 -0
  25. data/spec/objects/collection_spec.rb +66 -0
  26. data/spec/objects/customer_spec.rb +82 -0
  27. data/spec/objects/product_spec.rb +65 -0
  28. data/spec/objects/site_spec.rb +36 -27
  29. data/spec/objects/user_spec.rb +40 -32
  30. data/spec/objects/video_file_spec.rb +52 -0
  31. data/spec/objects/video_spec.rb +67 -23
  32. data/spec/spec_helper.rb +2 -11
  33. data/spec/utilities/vhx_helper_spec.rb +11 -7
  34. data/spec/utilities/vhx_list_object_spec.rb +27 -0
  35. data/spec/utilities/vhx_object_spec.rb +69 -26
  36. data/vhx.gemspec +4 -4
  37. metadata +59 -66
  38. data/spec/fixtures/sample_package_response.json +0 -185
  39. data/spec/objects/file_spec.rb +0 -29
  40. data/spec/objects/package_spec.rb +0 -74
  41. data/spec/test_data.rb +0 -55
  42. data/spec/utilities/vhx_collection_spec.rb +0 -27
  43. data/spec/vcr/Vhx_Client/application_user/_refresh_access_token/access_token_changed.yml +0 -57
  44. data/spec/vcr/Vhx_Client/application_user/_refresh_access_token/oauth_token_refreshed.yml +0 -57
  45. data/spec/vcr/Vhx_File/associations/are_present.yml +0 -409
  46. data/spec/vcr/Vhx_Middleware_ErrorResponse/unauthorized_user_credentials.yml +0 -122
  47. data/spec/vcr/Vhx_Middleware_OAuth2/access_token_refresh.yml +0 -797
  48. data/spec/vcr/Vhx_Package/_add_video/with_hypermedia/returns_package_object.yml +0 -51
  49. data/spec/vcr/Vhx_Package/_add_video/with_id/returns_package_object.yml +0 -51
  50. data/spec/vcr/Vhx_Package/_create/returns_package_object.yml +0 -140
  51. data/spec/vcr/Vhx_Package/_find/with_hypermedia.yml +0 -243
  52. data/spec/vcr/Vhx_Package/_find/with_id.yml +0 -243
  53. data/spec/vcr/Vhx_Package/_remove_video/with_hypermedia/returns_success.yml +0 -51
  54. data/spec/vcr/Vhx_Package/_remove_video/with_id/returns_success.yml +0 -51
  55. data/spec/vcr/Vhx_Package/associations/are_present.yml +0 -195
  56. data/spec/vcr/Vhx_Site/_create/returns_site_object.yml +0 -91
  57. data/spec/vcr/Vhx_Site/_find/with_hypermedia.yml +0 -195
  58. data/spec/vcr/Vhx_Site/_find/with_id.yml +0 -195
  59. data/spec/vcr/Vhx_User/_find/with_hypermedia.yml +0 -81
  60. data/spec/vcr/Vhx_User/_find/with_id.yml +0 -81
  61. data/spec/vcr/Vhx_User/_me/returns_user_object.yml +0 -720
  62. data/spec/vcr/Vhx_User/_update/returns_user_object.yml +0 -212
  63. data/spec/vcr/Vhx_VhxObject/associations/cache/retreive_if_available.yml +0 -195
  64. data/spec/vcr/Vhx_VhxObject/associations/falls_back_to_links.yml +0 -310
  65. data/spec/vcr/Vhx_Video/_create/returns_video_object.yml +0 -125
  66. data/spec/vcr/Vhx_Video/associations/are_present.yml +0 -294
@@ -1,243 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api.crystal.dev/packages/1025
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Authorization:
11
- - Bearer cc7d6c93bde201968f077b73acd5ee11a2768cbcb9b43122eb294004bf5b4480
12
- User-Agent:
13
- - Faraday v0.9.1
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- Accept:
17
- - "*/*"
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Date:
24
- - Tue, 05 May 2015 18:45:45 GMT
25
- Status:
26
- - 200 OK
27
- Connection:
28
- - close
29
- Cache-Control:
30
- - public, no-cache, must-revalidate
31
- Surrogate-Control:
32
- - max-age=3600
33
- Surrogate-Key:
34
- - packages/1025 sites/1900
35
- Etag:
36
- - '"45ff7920d37d7ddc4663ef9da4e45af8"'
37
- Last-Modified:
38
- - Wed, 18 Feb 2015 16:21:15 GMT
39
- Content-Type:
40
- - application/json; charset=utf-8
41
- Vary:
42
- - Accept-Encoding
43
- X-Ua-Compatible:
44
- - IE=Edge
45
- X-Meta-Request-Version:
46
- - 0.3.4
47
- X-Request-Id:
48
- - 7c4a92545e658bebbe1c8325877d6d0e
49
- X-Runtime:
50
- - '0.641733'
51
- Transfer-Encoding:
52
- - chunked
53
- body:
54
- encoding: UTF-8
55
- string: |
56
- {
57
- "_links": {
58
- "self": {
59
- "href": "http://api.crystal.dev/packages/1025"
60
- },
61
- "site": {
62
- "href": "http://api.crystal.dev/sites/1900"
63
- },
64
- "videos": {
65
- "href": "http://api.crystal.dev/packages/1025/videos"
66
- },
67
- "buy_page": {
68
- "href": "http://sagartestmovie.crystal.dev/buy/testing123"
69
- },
70
- "home_page": {
71
- "href": "http://sagartestmovie.crystal.dev/packages/testing123"
72
- }
73
- },
74
- "_embedded": {
75
- "site": {
76
- "_links": {
77
- "self": {
78
- "href": "http://api.crystal.dev/sites/1900"
79
- },
80
- "home_page": {
81
- "href": "http://sagartestmovie.crystal.dev"
82
- },
83
- "followers": {
84
- "href": "http://api.crystal.dev/sites/1900/followers"
85
- }
86
- },
87
- "id": 1900,
88
- "title": "SagarTestMovie",
89
- "description": "This is my test movie. ",
90
- "domain": "sagartestmovie.crystal.dev",
91
- "subdomain": "sagartestmovie",
92
- "key": "sagartestmovie",
93
- "color": "#28DBF7",
94
- "facebook_url": null,
95
- "twitter_name": null,
96
- "google_analytics_id": "",
97
- "packages_count": 2,
98
- "videos_count": 4,
99
- "followers_count": 31,
100
- "created_at": "2013-12-27T00:20:28Z",
101
- "updated_at": "2015-05-04T20:46:01Z"
102
- },
103
- "videos": [
104
- {
105
- "_links": {
106
- "self": {
107
- "href": "http://api.crystal.dev/videos/3008"
108
- },
109
- "site": {
110
- "href": "http://api.crystal.dev/sites/1900"
111
- },
112
- "files": {
113
- "href": "http://api.crystal.dev/videos/3008/files"
114
- }
115
- },
116
- "_embedded": {
117
- "subtitles": [
118
- {
119
- "_links": {
120
- "self": {
121
- "href": "http://api.crystal.dev/videos/7726"
122
- },
123
- "video": {
124
- "href": "http://api.crystal.dev/videos/3008"
125
- },
126
- "site": {
127
- "href": "http://api.crystal.dev/sites/1900"
128
- }
129
- },
130
- "language": "Bengali",
131
- "type": "video"
132
- },
133
- {
134
- "_links": {
135
- "self": {
136
- "href": "http://api.crystal.dev/videos/5558"
137
- },
138
- "video": {
139
- "href": "http://api.crystal.dev/videos/3008"
140
- },
141
- "site": {
142
- "href": "http://api.crystal.dev/sites/1900"
143
- }
144
- },
145
- "language": "English",
146
- "type": "video"
147
- }
148
- ]
149
- },
150
- "id": 3008,
151
- "title": "Test Movie",
152
- "description": "Testing",
153
- "status": "uploaded",
154
- "duration": {
155
- "seconds": 19,
156
- "formatted": "00:00:19"
157
- },
158
- "thumbnail": {
159
- "small": "https://dv6n47kh00ig2.cloudfront.net/sagartestmovie/assets/images/video-3008-1403716255-240x135.jpg",
160
- "medium": "https://dv6n47kh00ig2.cloudfront.net/sagartestmovie/assets/images/video-3008-1403716255-640x360.jpg",
161
- "large": "https://dv6n47kh00ig2.cloudfront.net/sagartestmovie/assets/images/video-3008-1403716255-1280x720.jpg"
162
- },
163
- "is_drm_enabled": false,
164
- "subtitles_count": 2,
165
- "files_count": 5,
166
- "created_at": "2014-02-06T05:30:18Z",
167
- "updated_at": "2015-02-18T16:21:24Z",
168
- "position": 0
169
- },
170
- {
171
- "_links": {
172
- "self": {
173
- "href": "http://api.crystal.dev/videos/7830"
174
- },
175
- "site": {
176
- "href": "http://api.crystal.dev/sites/1900"
177
- },
178
- "files": {
179
- "href": "http://api.crystal.dev/videos/7830/files"
180
- }
181
- },
182
- "_embedded": {
183
- "subtitles": [
184
-
185
- ]
186
- },
187
- "id": 7830,
188
- "title": "test movie",
189
- "description": null,
190
- "status": null,
191
- "duration": {
192
- "seconds": 0,
193
- "formatted": "00:00:00"
194
- },
195
- "thumbnail": {
196
- "small": "http://cdn.crystal.dev/assets/thumbnails/default-small.png",
197
- "medium": "http://cdn.crystal.dev/assets/thumbnails/default-medium.png",
198
- "large": "http://cdn.crystal.dev/assets/thumbnails/default-large.png"
199
- },
200
- "is_drm_enabled": false,
201
- "subtitles_count": 0,
202
- "files_count": 0,
203
- "created_at": "2014-07-14T15:19:03Z",
204
- "updated_at": "2015-05-04T19:36:50Z",
205
- "position": 1
206
- }
207
- ],
208
- "trailer": null
209
- },
210
- "id": 1025,
211
- "title": "testing123",
212
- "description": "test",
213
- "sku": "testing123",
214
- "price": {
215
- "cents": 200,
216
- "currency": "USD",
217
- "formatted": "$2",
218
- "US": {
219
- "cents": 200,
220
- "currency": "USD",
221
- "formatted": "$2"
222
- }
223
- },
224
- "rental": null,
225
- "trailer_url": null,
226
- "trailer_embed_code": "<iframe src=\"http://embed.crystal.dev/packages/1025\" width=\"640\" height=\"360\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>",
227
- "thumbnail": {
228
- "small": "http://cdn.crystal.dev/assets/thumbnails/default-small.png",
229
- "medium": "http://cdn.crystal.dev/assets/thumbnails/default-medium.png",
230
- "large": "http://cdn.crystal.dev/assets/thumbnails/default-large.png",
231
- "blurred": null
232
- },
233
- "is_active": false,
234
- "is_preorder": false,
235
- "release_date": null,
236
- "videos_count": 2,
237
- "extras_count": 0,
238
- "created_at": "2014-02-06T18:00:39Z",
239
- "updated_at": "2015-02-18T16:21:15Z"
240
- }
241
- http_version:
242
- recorded_at: Tue, 05 May 2015 18:45:45 GMT
243
- recorded_with: VCR 2.9.3
@@ -1,51 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: delete
5
- uri: http://api.crystal.dev/packages/1025/videos
6
- body:
7
- encoding: UTF-8
8
- string: video=http%3A%2F%2Fapi.crystal.dev%2Fvideos%2F7726
9
- headers:
10
- Authorization:
11
- - Bearer 41d2ed8ead125347d38cf13dd7da8df0a32e9c9e839a9ea1b39c0d4f8b9caa92
12
- User-Agent:
13
- - Faraday v0.9.1
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- Accept-Encoding:
17
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
- response:
21
- status:
22
- code: 204
23
- message: No Content
24
- headers:
25
- Date:
26
- - Mon, 04 May 2015 19:37:32 GMT
27
- Status:
28
- - 204 No Content
29
- Connection:
30
- - close
31
- Cache-Control:
32
- - private, no-cache, max-age=0, must-revalidate
33
- Surrogate-Control:
34
- - no-cache
35
- X-Ua-Compatible:
36
- - IE=Edge
37
- Set-Cookie:
38
- - _session=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJWY0M2ZjZTk0MzFlMGFmNTRlY2I2ZWJhZTQyMjFlNzBhBjsAVEkiGGN1cnJlbnRfYXBwbGljYXRpb24GOwBGSSIKc2FnYXIGOwBUSSIRY3VycmVudF91c2VyBjsARkkiEXNhZ2FyQHZoeC50dgY7AFQ%3D--8ba1782fe365ec94d33f81f3631d13b4db62de81;
39
- domain=.crystal.dev; path=/; expires=Wed, 04-May-2016 19:37:32 GMT; HttpOnly
40
- X-Meta-Request-Version:
41
- - 0.3.4
42
- X-Request-Id:
43
- - 524347d8b239ff65c4a4fe3af16b483e
44
- X-Runtime:
45
- - '0.119044'
46
- body:
47
- encoding: UTF-8
48
- string: ''
49
- http_version:
50
- recorded_at: Mon, 04 May 2015 19:37:32 GMT
51
- recorded_with: VCR 2.9.3
@@ -1,51 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: delete
5
- uri: http://api.crystal.dev/packages/1025/videos
6
- body:
7
- encoding: UTF-8
8
- string: video=%2Fvideos%2F7726
9
- headers:
10
- Authorization:
11
- - Bearer 41d2ed8ead125347d38cf13dd7da8df0a32e9c9e839a9ea1b39c0d4f8b9caa92
12
- User-Agent:
13
- - Faraday v0.9.1
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- Accept-Encoding:
17
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
- response:
21
- status:
22
- code: 204
23
- message: No Content
24
- headers:
25
- Date:
26
- - Mon, 04 May 2015 19:37:32 GMT
27
- Status:
28
- - 204 No Content
29
- Connection:
30
- - close
31
- Cache-Control:
32
- - private, no-cache, max-age=0, must-revalidate
33
- Surrogate-Control:
34
- - no-cache
35
- X-Ua-Compatible:
36
- - IE=Edge
37
- Set-Cookie:
38
- - _session=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJWM2YThkZDlhNzkwMjZkYzZmM2Q0ZjRmMmZmZDEyOGUwBjsAVEkiGGN1cnJlbnRfYXBwbGljYXRpb24GOwBGSSIKc2FnYXIGOwBUSSIRY3VycmVudF91c2VyBjsARkkiEXNhZ2FyQHZoeC50dgY7AFQ%3D--c2cd212e7a2c1b044da80b722949c73298641a41;
39
- domain=.crystal.dev; path=/; expires=Wed, 04-May-2016 19:37:32 GMT; HttpOnly
40
- X-Meta-Request-Version:
41
- - 0.3.4
42
- X-Request-Id:
43
- - d4f8415dce0c4382c07bc25302b9e9cc
44
- X-Runtime:
45
- - '0.192340'
46
- body:
47
- encoding: UTF-8
48
- string: ''
49
- http_version:
50
- recorded_at: Mon, 04 May 2015 19:37:32 GMT
51
- recorded_with: VCR 2.9.3
@@ -1,195 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api.crystal.dev/sites/1900
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Authorization:
11
- - Bearer 41d2ed8ead125347d38cf13dd7da8df0a32e9c9e839a9ea1b39c0d4f8b9caa92
12
- User-Agent:
13
- - Faraday v0.9.1
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- Accept:
17
- - "*/*"
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Date:
24
- - Mon, 04 May 2015 19:38:54 GMT
25
- Status:
26
- - 200 OK
27
- Connection:
28
- - close
29
- Cache-Control:
30
- - public, no-cache, must-revalidate
31
- Surrogate-Control:
32
- - max-age=3600
33
- Surrogate-Key:
34
- - sites/1900
35
- Etag:
36
- - '"a4c59eb7508fb0ebf5f7d71af2ab6e57"'
37
- Last-Modified:
38
- - Mon, 04 May 2015 19:37:32 GMT
39
- Content-Type:
40
- - application/json; charset=utf-8
41
- Vary:
42
- - Accept-Encoding
43
- X-Ua-Compatible:
44
- - IE=Edge
45
- X-Meta-Request-Version:
46
- - 0.3.4
47
- X-Request-Id:
48
- - 2a734f41b6f8961d9a7a3f694c0bd1ab
49
- X-Runtime:
50
- - '0.829213'
51
- Transfer-Encoding:
52
- - chunked
53
- body:
54
- encoding: UTF-8
55
- string: |
56
- {
57
- "_links": {
58
- "self": {
59
- "href": "http://api.crystal.dev/sites/1900"
60
- },
61
- "home_page": {
62
- "href": "http://sagartestmovie.crystal.dev"
63
- },
64
- "followers": {
65
- "href": "http://api.crystal.dev/sites/1900/followers"
66
- }
67
- },
68
- "_embedded": {
69
- "subscription": null,
70
- "packages": [
71
- {
72
- "_links": {
73
- "self": {
74
- "href": "http://api.crystal.dev/packages/2780"
75
- },
76
- "site": {
77
- "href": "http://api.crystal.dev/sites/1900"
78
- },
79
- "videos": {
80
- "href": "http://api.crystal.dev/packages/2780/videos"
81
- },
82
- "buy_page": {
83
- "href": "http://sagartestmovie.crystal.dev/buy/pwyw-1"
84
- },
85
- "home_page": {
86
- "href": "http://sagartestmovie.crystal.dev/packages/pwyw-1"
87
- }
88
- },
89
- "_embedded": {
90
- "trailer": null
91
- },
92
- "id": 2780,
93
- "title": "pwyw",
94
- "description": "",
95
- "sku": "pwyw-1",
96
- "price": {
97
- "cents": 500,
98
- "currency": "USD",
99
- "formatted": "$5",
100
- "US": {
101
- "cents": 500,
102
- "currency": "USD",
103
- "formatted": "$5"
104
- }
105
- },
106
- "rental": null,
107
- "trailer_url": null,
108
- "trailer_embed_code": "<iframe src=\"http://embed.crystal.dev/packages/2780\" width=\"640\" height=\"360\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>",
109
- "thumbnail": {
110
- "small": "http://cdn.crystal.dev/assets/thumbnails/default-small.png",
111
- "medium": "http://cdn.crystal.dev/assets/thumbnails/default-medium.png",
112
- "large": "http://cdn.crystal.dev/assets/thumbnails/default-large.png",
113
- "blurred": null
114
- },
115
- "is_active": true,
116
- "is_preorder": false,
117
- "release_date": null,
118
- "videos_count": 0,
119
- "extras_count": 0,
120
- "created_at": "2014-07-15T18:15:36Z",
121
- "updated_at": "2014-08-26T14:48:52Z"
122
- },
123
- {
124
- "_links": {
125
- "self": {
126
- "href": "http://api.crystal.dev/packages/7381"
127
- },
128
- "site": {
129
- "href": "http://api.crystal.dev/sites/1900"
130
- },
131
- "videos": {
132
- "href": "http://api.crystal.dev/packages/7381/videos"
133
- },
134
- "buy_page": {
135
- "href": "http://sagartestmovie.crystal.dev/buy/test-package-2"
136
- },
137
- "home_page": {
138
- "href": "http://sagartestmovie.crystal.dev/packages/test-package-2"
139
- }
140
- },
141
- "_embedded": {
142
- "trailer": null
143
- },
144
- "id": 7381,
145
- "title": "test package",
146
- "description": "test description",
147
- "sku": "test-package-2",
148
- "price": {
149
- "cents": 1000,
150
- "currency": "USD",
151
- "formatted": "$10",
152
- "US": {
153
- "cents": 1000,
154
- "currency": "USD",
155
- "formatted": "$10"
156
- }
157
- },
158
- "rental": null,
159
- "trailer_url": null,
160
- "trailer_embed_code": "<iframe src=\"http://embed.crystal.dev/packages/7381\" width=\"640\" height=\"360\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>",
161
- "thumbnail": {
162
- "small": "http://cdn.crystal.dev/assets/thumbnails/default-small.png",
163
- "medium": "http://cdn.crystal.dev/assets/thumbnails/default-medium.png",
164
- "large": "http://cdn.crystal.dev/assets/thumbnails/default-large.png",
165
- "blurred": null
166
- },
167
- "is_active": true,
168
- "is_preorder": false,
169
- "release_date": null,
170
- "videos_count": 0,
171
- "extras_count": 0,
172
- "created_at": "2015-05-04T19:15:09Z",
173
- "updated_at": "2015-05-04T19:15:09Z"
174
- }
175
- ]
176
- },
177
- "id": 1900,
178
- "title": "SagarTestMovie",
179
- "description": "This is my test movie. ",
180
- "domain": "sagartestmovie.crystal.dev",
181
- "subdomain": "sagartestmovie",
182
- "key": "sagartestmovie",
183
- "color": "#28DBF7",
184
- "facebook_url": null,
185
- "twitter_name": null,
186
- "google_analytics_id": "",
187
- "packages_count": 2,
188
- "videos_count": 3,
189
- "followers_count": 30,
190
- "created_at": "2013-12-27T00:20:28Z",
191
- "updated_at": "2015-05-04T19:37:32Z"
192
- }
193
- http_version:
194
- recorded_at: Mon, 04 May 2015 19:38:54 GMT
195
- recorded_with: VCR 2.9.3