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,51 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
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%2F7830
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:36:51 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=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJTZlOGNjNzgwOTY1MjI2NjgyNTZmYTdlMzM0NjRkZmQwBjsAVEkiGGN1cnJlbnRfYXBwbGljYXRpb24GOwBGSSIKc2FnYXIGOwBUSSIRY3VycmVudF91c2VyBjsARkkiEXNhZ2FyQHZoeC50dgY7AFQ%3D--d77da61b6ae52fb5a6ec1baa27b6c706dd110629;
39
- domain=.crystal.dev; path=/; expires=Wed, 04-May-2016 19:36:51 GMT; HttpOnly
40
- X-Meta-Request-Version:
41
- - 0.3.4
42
- X-Request-Id:
43
- - 1268358763b548b784c1cb5beac1f8ff
44
- X-Runtime:
45
- - '0.116914'
46
- body:
47
- encoding: UTF-8
48
- string: ''
49
- http_version:
50
- recorded_at: Mon, 04 May 2015 19:36:51 GMT
51
- recorded_with: VCR 2.9.3
@@ -1,51 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
5
- uri: http://api.crystal.dev/packages/1025/videos
6
- body:
7
- encoding: UTF-8
8
- string: video=%2Fvideos%2F7830
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:36:50 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=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJWE4NWU5YzExMTEzMjIyNmZkNDg3NzlkNTczODgyMWI5BjsAVEkiGGN1cnJlbnRfYXBwbGljYXRpb24GOwBGSSIKc2FnYXIGOwBUSSIRY3VycmVudF91c2VyBjsARkkiEXNhZ2FyQHZoeC50dgY7AFQ%3D--6cf7ca1616eba66d982c54a595ee5ebe9bf571a8;
39
- domain=.crystal.dev; path=/; expires=Wed, 04-May-2016 19:36:50 GMT; HttpOnly
40
- X-Meta-Request-Version:
41
- - 0.3.4
42
- X-Request-Id:
43
- - 7d391caa7d651535128b72ea5b9d0542
44
- X-Runtime:
45
- - '1.679324'
46
- body:
47
- encoding: UTF-8
48
- string: ''
49
- http_version:
50
- recorded_at: Mon, 04 May 2015 19:36:50 GMT
51
- recorded_with: VCR 2.9.3
@@ -1,140 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://api.crystal.dev/packages
6
- body:
7
- encoding: UTF-8
8
- string: description=test+description&price_cents=1000&site=http%3A%2F%2Fapi.crystal.dev%2Fsites%2F1900&title=test+package
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: 201
23
- message: Created
24
- headers:
25
- Date:
26
- - Mon, 04 May 2015 19:15:09 GMT
27
- Status:
28
- - 201 Created
29
- Connection:
30
- - close
31
- Cache-Control:
32
- - private, no-cache, max-age=0, must-revalidate
33
- Surrogate-Control:
34
- - no-cache
35
- Content-Type:
36
- - application/json; charset=utf-8
37
- Vary:
38
- - Accept-Encoding
39
- X-Ua-Compatible:
40
- - IE=Edge
41
- Set-Cookie:
42
- - _session=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJWU3NmQzNTk4MjZmY2I3YjViN2Y1MTBjMzQxOTRhYmIzBjsAVEkiGGN1cnJlbnRfYXBwbGljYXRpb24GOwBGSSIKc2FnYXIGOwBUSSIRY3VycmVudF91c2VyBjsARkkiEXNhZ2FyQHZoeC50dgY7AFQ%3D--6530f691e6b413550d219aafb399cbf30faac4a6;
43
- domain=.crystal.dev; path=/; expires=Wed, 04-May-2016 19:15:09 GMT; HttpOnly
44
- X-Meta-Request-Version:
45
- - 0.3.4
46
- X-Request-Id:
47
- - dbfb03c3cf1da02548ff2b0ee19c1805
48
- X-Runtime:
49
- - '0.326435'
50
- Transfer-Encoding:
51
- - chunked
52
- body:
53
- encoding: UTF-8
54
- string: |
55
- {
56
- "_links": {
57
- "self": {
58
- "href": "http://api.crystal.dev/packages/7381"
59
- },
60
- "site": {
61
- "href": "http://api.crystal.dev/sites/1900"
62
- },
63
- "videos": {
64
- "href": "http://api.crystal.dev/packages/7381/videos"
65
- },
66
- "buy_page": {
67
- "href": "http://sagartestmovie.crystal.dev/buy/test-package-2"
68
- },
69
- "home_page": {
70
- "href": "http://sagartestmovie.crystal.dev/packages/test-package-2"
71
- }
72
- },
73
- "_embedded": {
74
- "site": {
75
- "_links": {
76
- "self": {
77
- "href": "http://api.crystal.dev/sites/1900"
78
- },
79
- "home_page": {
80
- "href": "http://sagartestmovie.crystal.dev"
81
- },
82
- "followers": {
83
- "href": "http://api.crystal.dev/sites/1900/followers"
84
- }
85
- },
86
- "id": 1900,
87
- "title": "SagarTestMovie",
88
- "description": "This is my test movie. ",
89
- "domain": "sagartestmovie.crystal.dev",
90
- "subdomain": "sagartestmovie",
91
- "key": "sagartestmovie",
92
- "color": "#28DBF7",
93
- "facebook_url": null,
94
- "twitter_name": null,
95
- "google_analytics_id": "",
96
- "packages_count": 2,
97
- "videos_count": 3,
98
- "followers_count": 30,
99
- "created_at": "2013-12-27T00:20:28Z",
100
- "updated_at": "2015-05-04T19:15:09Z"
101
- },
102
- "videos": [
103
-
104
- ],
105
- "trailer": null
106
- },
107
- "id": 7381,
108
- "title": "test package",
109
- "description": "test description",
110
- "sku": "test-package-2",
111
- "price": {
112
- "cents": 1000,
113
- "currency": "USD",
114
- "formatted": "$10",
115
- "US": {
116
- "cents": 1000,
117
- "currency": "USD",
118
- "formatted": "$10"
119
- }
120
- },
121
- "rental": null,
122
- "trailer_url": null,
123
- "trailer_embed_code": "<iframe src=\"http://embed.crystal.dev/packages/7381\" width=\"640\" height=\"360\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>",
124
- "thumbnail": {
125
- "small": "http://cdn.crystal.dev/assets/thumbnails/default-small.png",
126
- "medium": "http://cdn.crystal.dev/assets/thumbnails/default-medium.png",
127
- "large": "http://cdn.crystal.dev/assets/thumbnails/default-large.png",
128
- "blurred": null
129
- },
130
- "is_active": true,
131
- "is_preorder": false,
132
- "release_date": null,
133
- "videos_count": 0,
134
- "extras_count": 0,
135
- "created_at": "2015-05-04T19:15:09Z",
136
- "updated_at": "2015-05-04T19:15:09Z"
137
- }
138
- http_version:
139
- recorded_at: Mon, 04 May 2015 19:15:09 GMT
140
- recorded_with: VCR 2.9.3
@@ -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
- - 31bc6f4501d48d6a276ac8a561fa4f5c
49
- X-Runtime:
50
- - '0.346345'
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