edools-api 0.4.0 → 0.5.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/edools-api.gemspec +57 -11
  4. data/lib/edools.rb +2 -1
  5. data/lib/edools/base.rb +25 -0
  6. data/lib/edools/config.rb +2 -2
  7. data/lib/edools/core.rb +6 -1
  8. data/lib/edools/core/base.rb +3 -12
  9. data/lib/edools/core/course.rb +10 -0
  10. data/lib/edools/core/course_content.rb +15 -0
  11. data/lib/edools/core/course_module.rb +15 -0
  12. data/lib/edools/core/enrollment.rb +2 -2
  13. data/lib/edools/core/lesson.rb +10 -0
  14. data/lib/edools/core/media.rb +10 -0
  15. data/lib/edools/core/organization.rb +2 -2
  16. data/lib/edools/core/path.rb +10 -0
  17. data/lib/edools/core/registration.rb +2 -2
  18. data/lib/edools/core/school.rb +2 -2
  19. data/lib/edools/core/school_product.rb +2 -2
  20. data/lib/edools/core/session.rb +1 -1
  21. data/lib/edools/core/student.rb +2 -2
  22. data/lib/edools/ecommerce.rb +2 -0
  23. data/lib/edools/ecommerce/base.rb +8 -0
  24. data/lib/edools/ecommerce/product.rb +21 -0
  25. data/lib/edools/initialization.rb +4 -1
  26. data/lib/edools/paginated_collection.rb +37 -0
  27. data/spec/edools/core/course_content_spec.rb +35 -0
  28. data/spec/edools/core/course_module_spec.rb +35 -0
  29. data/spec/edools/core/course_spec.rb +36 -0
  30. data/spec/edools/core/enrollment_spec.rb +1 -3
  31. data/spec/edools/core/lesson_spec.rb +39 -0
  32. data/spec/edools/core/media_spec.rb +40 -0
  33. data/spec/edools/core/path_spec.rb +36 -0
  34. data/spec/edools/core/school_product_spec.rb +10 -6
  35. data/spec/edools/ecommerce/base_spec.rb +9 -0
  36. data/spec/edools/ecommerce/product_spec.rb +38 -0
  37. data/spec/fixtures/vcr_cassettes/Edools_Core_Course/create_the_course.yml +66 -0
  38. data/spec/fixtures/vcr_cassettes/Edools_Core_Course/destroy_the_course.yml +114 -0
  39. data/spec/fixtures/vcr_cassettes/Edools_Core_Course/finds_all_course.yml +146 -0
  40. data/spec/fixtures/vcr_cassettes/Edools_Core_Course/finds_the_course.yml +62 -0
  41. data/spec/fixtures/vcr_cassettes/Edools_Core_Course/update_the_course.yml +118 -0
  42. data/spec/fixtures/vcr_cassettes/{Edools_Core_SchoolClass/create_the_school_class.yml → Edools_Core_CourseContent/create_the_course_content.yml} +11 -11
  43. data/spec/fixtures/vcr_cassettes/{Edools_Core_SchoolClass/destroy_the_school_class.yml → Edools_Core_CourseContent/destroy_the_course_content.yml} +14 -14
  44. data/spec/fixtures/vcr_cassettes/Edools_Core_CourseContent/finds_all_course_content.yml +64 -0
  45. data/spec/fixtures/vcr_cassettes/{Edools_Core_SchoolClass/finds_the_school_class.yml → Edools_Core_CourseContent/finds_the_course_content.yml} +9 -9
  46. data/spec/fixtures/vcr_cassettes/{Edools_Core_SchoolClass/update_the_school_class.yml → Edools_Core_CourseContent/update_the_course_content.yml} +17 -17
  47. data/spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/create_the_course_module.yml +66 -0
  48. data/spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/destroy_the_course_module.yml +114 -0
  49. data/spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/finds_all_course_module.yml +78 -0
  50. data/spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/finds_the_course_module.yml +67 -0
  51. data/spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/update_the_course_module.yml +123 -0
  52. data/spec/fixtures/vcr_cassettes/Edools_Core_Lesson/create_the_lesson.yml +66 -0
  53. data/spec/fixtures/vcr_cassettes/Edools_Core_Lesson/destroy_the_lesson.yml +115 -0
  54. data/spec/fixtures/vcr_cassettes/Edools_Core_Lesson/finds_all_lesson.yml +154 -0
  55. data/spec/fixtures/vcr_cassettes/Edools_Core_Lesson/finds_the_lesson.yml +62 -0
  56. data/spec/fixtures/vcr_cassettes/Edools_Core_Lesson/update_the_lesson.yml +118 -0
  57. data/spec/fixtures/vcr_cassettes/Edools_Core_Media/create_the_media.yml +68 -0
  58. data/spec/fixtures/vcr_cassettes/Edools_Core_Media/destroy_the_media.yml +116 -0
  59. data/spec/fixtures/vcr_cassettes/Edools_Core_Media/finds_all_media.yml +212 -0
  60. data/spec/fixtures/vcr_cassettes/Edools_Core_Media/finds_the_media.yml +63 -0
  61. data/spec/fixtures/vcr_cassettes/Edools_Core_Media/update_the_media.yml +120 -0
  62. data/spec/fixtures/vcr_cassettes/Edools_Core_Path/create_the_path.yml +66 -0
  63. data/spec/fixtures/vcr_cassettes/Edools_Core_Path/destroy_the_path.yml +114 -0
  64. data/spec/fixtures/vcr_cassettes/Edools_Core_Path/finds_all_path.yml +78 -0
  65. data/spec/fixtures/vcr_cassettes/{Edools_Core_SchoolClass/finds_all_school_class.yml → Edools_Core_Path/finds_the_path.yml} +11 -10
  66. data/spec/fixtures/vcr_cassettes/Edools_Core_Path/update_the_path.yml +117 -0
  67. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/create_the_school_product.yml +11 -11
  68. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/destroy_the_school_product.yml +17 -16
  69. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_all_school_product.yml +173 -125
  70. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_the_school_product.yml +10 -10
  71. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/update_the_school_product.yml +18 -18
  72. data/spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/create_the_product.yml +65 -0
  73. data/spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/destroy_the_product.yml +114 -0
  74. data/spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/finds_all_product.yml +179 -0
  75. data/spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/finds_the_product.yml +62 -0
  76. data/spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/update_the_product.yml +117 -0
  77. metadata +56 -10
  78. data/lib/edools/core/paginated_collection.rb +0 -30
  79. data/lib/edools/core/school_class.rb +0 -14
  80. data/spec/edools/core/school_class_spec.rb +0 -35
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://ecommerce.edools.com/products/123.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/+json
12
+ Authorization:
13
+ - Token token=84cc0400cd52f62f2e12309b502889ab:2fee1e06d56ab6394ab9acd4c6a8c62f
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - max-age=0, private, must-revalidate
25
+ Content-Security-Policy-Report-Only:
26
+ - default-src https://* 'self'; connect-src https://* 'self'; font-src https://*
27
+ 'self'; frame-src https://* 'self'; img-src https://* 'self' data:; media-src
28
+ https://* 'self'; object-src https://* 'self'; script-src https://* 'self';
29
+ style-src https://* 'self'; report-uri https://core.edools.com/uri-directive;
30
+ Content-Type:
31
+ - application/vnd.edools.ecommerce.v1+json; charset=utf-8
32
+ Date:
33
+ - Mon, 06 Jul 2015 21:21:25 GMT
34
+ Etag:
35
+ - '"52c2a3ed8ff5cfb9e3ee4aa9c0a69450"'
36
+ Server:
37
+ - nginx/1.4.7
38
+ Status:
39
+ - 200 OK
40
+ Strict-Transport-Security:
41
+ - max-age=631152000; includeSubdomains
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ X-Frame-Options:
45
+ - DENY
46
+ X-Request-Id:
47
+ - d915ab26-1fb8-421e-95ec-56b8edbe15e0
48
+ X-Runtime:
49
+ - '0.053448'
50
+ X-Xss-Protection:
51
+ - 1; mode=block
52
+ Transfer-Encoding:
53
+ - chunked
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"id":2671,"guid":"123","name":"Edools API Test","description":null,"price":0,"price_in_credits":0,"active":true,"credits":null,"school_id":1,"base_price":0,"promotional":false,"expiration_period":null,"type":null,"created_at":"2015-07-06
59
+ 21:20:33 UTC","updated_at":"2015-07-06 21:20:33 UTC","plans":[]}'
60
+ http_version:
61
+ recorded_at: Mon, 06 Jul 2015 21:21:24 GMT
62
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,117 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://ecommerce.edools.com/products/123.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/+json
12
+ Authorization:
13
+ - Token token=84cc0400cd52f62f2e12309b502889ab:2fee1e06d56ab6394ab9acd4c6a8c62f
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - max-age=0, private, must-revalidate
25
+ Content-Security-Policy-Report-Only:
26
+ - default-src https://* 'self'; connect-src https://* 'self'; font-src https://*
27
+ 'self'; frame-src https://* 'self'; img-src https://* 'self' data:; media-src
28
+ https://* 'self'; object-src https://* 'self'; script-src https://* 'self';
29
+ style-src https://* 'self'; report-uri https://core.edools.com/uri-directive;
30
+ Content-Type:
31
+ - application/vnd.edools.ecommerce.v1+json; charset=utf-8
32
+ Date:
33
+ - Tue, 07 Jul 2015 13:14:07 GMT
34
+ Etag:
35
+ - '"52c2a3ed8ff5cfb9e3ee4aa9c0a69450"'
36
+ Server:
37
+ - nginx/1.4.7
38
+ Status:
39
+ - 200 OK
40
+ Strict-Transport-Security:
41
+ - max-age=631152000; includeSubdomains
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ X-Frame-Options:
45
+ - DENY
46
+ X-Request-Id:
47
+ - db7ca2db-d701-49de-b008-005d339fd216
48
+ X-Runtime:
49
+ - '0.043499'
50
+ X-Xss-Protection:
51
+ - 1; mode=block
52
+ Content-Length:
53
+ - '303'
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"id":2671,"guid":"123","name":"Edools API Test","description":null,"price":0,"price_in_credits":0,"active":true,"credits":null,"school_id":1,"base_price":0,"promotional":false,"expiration_period":null,"type":null,"created_at":"2015-07-06
59
+ 21:20:33 UTC","updated_at":"2015-07-06 21:20:33 UTC","plans":[]}'
60
+ http_version:
61
+ recorded_at: Tue, 07 Jul 2015 13:14:07 GMT
62
+ - request:
63
+ method: put
64
+ uri: https://ecommerce.edools.com/products/123.json
65
+ body:
66
+ encoding: UTF-8
67
+ string: '{"product":{"id":2671,"guid":"123","name":"Edools API Test UPDATED","description":null,"price":0,"price_in_credits":0,"active":true,"credits":null,"school_id":1,"base_price":0,"promotional":false,"expiration_period":null,"type":null,"created_at":"2015-07-06
68
+ 21:20:33 UTC","updated_at":"2015-07-06 21:20:33 UTC","plans":[]}}'
69
+ headers:
70
+ Content-Type:
71
+ - application/json
72
+ Authorization:
73
+ - Token token=84cc0400cd52f62f2e12309b502889ab:2fee1e06d56ab6394ab9acd4c6a8c62f
74
+ Accept:
75
+ - application/+json
76
+ Accept-Encoding:
77
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
78
+ User-Agent:
79
+ - Ruby
80
+ response:
81
+ status:
82
+ code: 204
83
+ message: No Content
84
+ headers:
85
+ Cache-Control:
86
+ - no-cache
87
+ Content-Security-Policy-Report-Only:
88
+ - default-src https://* 'self'; connect-src https://* 'self'; font-src https://*
89
+ 'self'; frame-src https://* 'self'; img-src https://* 'self' data:; media-src
90
+ https://* 'self'; object-src https://* 'self'; script-src https://* 'self';
91
+ style-src https://* 'self'; report-uri https://core.edools.com/uri-directive;
92
+ Date:
93
+ - Tue, 07 Jul 2015 13:14:08 GMT
94
+ Server:
95
+ - nginx/1.4.7
96
+ Status:
97
+ - 204 No Content
98
+ Strict-Transport-Security:
99
+ - max-age=631152000; includeSubdomains
100
+ X-Content-Type-Options:
101
+ - nosniff
102
+ X-Frame-Options:
103
+ - DENY
104
+ X-Request-Id:
105
+ - 159af622-b2a5-40bc-a438-6c0b88e4bae7
106
+ X-Runtime:
107
+ - '0.063516'
108
+ X-Xss-Protection:
109
+ - 1; mode=block
110
+ Connection:
111
+ - keep-alive
112
+ body:
113
+ encoding: UTF-8
114
+ string: ''
115
+ http_version:
116
+ recorded_at: Tue, 07 Jul 2015 13:14:08 GMT
117
+ recorded_with: VCR 2.9.2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edools-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinicius Kastrup
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -169,44 +169,85 @@ files:
169
169
  - VERSION
170
170
  - edools-api.gemspec
171
171
  - lib/edools.rb
172
+ - lib/edools/base.rb
172
173
  - lib/edools/config.rb
173
174
  - lib/edools/core.rb
174
175
  - lib/edools/core/api_key.rb
175
176
  - lib/edools/core/base.rb
177
+ - lib/edools/core/course.rb
178
+ - lib/edools/core/course_content.rb
179
+ - lib/edools/core/course_module.rb
176
180
  - lib/edools/core/enrollment.rb
181
+ - lib/edools/core/lesson.rb
182
+ - lib/edools/core/media.rb
177
183
  - lib/edools/core/organization.rb
178
- - lib/edools/core/paginated_collection.rb
184
+ - lib/edools/core/path.rb
179
185
  - lib/edools/core/registration.rb
180
186
  - lib/edools/core/school.rb
181
- - lib/edools/core/school_class.rb
182
187
  - lib/edools/core/school_product.rb
183
188
  - lib/edools/core/session.rb
184
189
  - lib/edools/core/student.rb
190
+ - lib/edools/ecommerce.rb
191
+ - lib/edools/ecommerce/base.rb
192
+ - lib/edools/ecommerce/product.rb
185
193
  - lib/edools/initialization.rb
194
+ - lib/edools/paginated_collection.rb
186
195
  - spec/edools/core/api_key_spec.rb
187
196
  - spec/edools/core/base_spec.rb
197
+ - spec/edools/core/course_content_spec.rb
198
+ - spec/edools/core/course_module_spec.rb
199
+ - spec/edools/core/course_spec.rb
188
200
  - spec/edools/core/enrollment_spec.rb
201
+ - spec/edools/core/lesson_spec.rb
202
+ - spec/edools/core/media_spec.rb
189
203
  - spec/edools/core/organization_spec.rb
204
+ - spec/edools/core/path_spec.rb
190
205
  - spec/edools/core/registration_spec.rb
191
- - spec/edools/core/school_class_spec.rb
192
206
  - spec/edools/core/school_product_spec.rb
193
207
  - spec/edools/core/school_spec.rb
194
208
  - spec/edools/core/session_spec.rb
195
209
  - spec/edools/core/student_spec.rb
210
+ - spec/edools/ecommerce/base_spec.rb
211
+ - spec/edools/ecommerce/product_spec.rb
196
212
  - spec/fixtures/vcr_cassettes/Edools_Core_ApiKey/finds_the_api_key.yml
213
+ - spec/fixtures/vcr_cassettes/Edools_Core_Course/create_the_course.yml
214
+ - spec/fixtures/vcr_cassettes/Edools_Core_Course/destroy_the_course.yml
215
+ - spec/fixtures/vcr_cassettes/Edools_Core_Course/finds_all_course.yml
216
+ - spec/fixtures/vcr_cassettes/Edools_Core_Course/finds_the_course.yml
217
+ - spec/fixtures/vcr_cassettes/Edools_Core_Course/update_the_course.yml
218
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseContent/create_the_course_content.yml
219
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseContent/destroy_the_course_content.yml
220
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseContent/finds_all_course_content.yml
221
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseContent/finds_the_course_content.yml
222
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseContent/update_the_course_content.yml
223
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/create_the_course_module.yml
224
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/destroy_the_course_module.yml
225
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/finds_all_course_module.yml
226
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/finds_the_course_module.yml
227
+ - spec/fixtures/vcr_cassettes/Edools_Core_CourseModule/update_the_course_module.yml
197
228
  - spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/create_the_enrollment.yml
198
229
  - spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/finds_all_enrollment.yml
199
230
  - spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/finds_the_enrollment.yml
200
231
  - spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/update_the_enrollment.yml
232
+ - spec/fixtures/vcr_cassettes/Edools_Core_Lesson/create_the_lesson.yml
233
+ - spec/fixtures/vcr_cassettes/Edools_Core_Lesson/destroy_the_lesson.yml
234
+ - spec/fixtures/vcr_cassettes/Edools_Core_Lesson/finds_all_lesson.yml
235
+ - spec/fixtures/vcr_cassettes/Edools_Core_Lesson/finds_the_lesson.yml
236
+ - spec/fixtures/vcr_cassettes/Edools_Core_Lesson/update_the_lesson.yml
237
+ - spec/fixtures/vcr_cassettes/Edools_Core_Media/create_the_media.yml
238
+ - spec/fixtures/vcr_cassettes/Edools_Core_Media/destroy_the_media.yml
239
+ - spec/fixtures/vcr_cassettes/Edools_Core_Media/finds_all_media.yml
240
+ - spec/fixtures/vcr_cassettes/Edools_Core_Media/finds_the_media.yml
241
+ - spec/fixtures/vcr_cassettes/Edools_Core_Media/update_the_media.yml
242
+ - spec/fixtures/vcr_cassettes/Edools_Core_Path/create_the_path.yml
243
+ - spec/fixtures/vcr_cassettes/Edools_Core_Path/destroy_the_path.yml
244
+ - spec/fixtures/vcr_cassettes/Edools_Core_Path/finds_all_path.yml
245
+ - spec/fixtures/vcr_cassettes/Edools_Core_Path/finds_the_path.yml
246
+ - spec/fixtures/vcr_cassettes/Edools_Core_Path/update_the_path.yml
201
247
  - spec/fixtures/vcr_cassettes/Edools_Core_School/create_the_school.yml
202
248
  - spec/fixtures/vcr_cassettes/Edools_Core_School/finds_all_school.yml
203
249
  - spec/fixtures/vcr_cassettes/Edools_Core_School/finds_the_school.yml
204
250
  - spec/fixtures/vcr_cassettes/Edools_Core_School/update_the_school.yml
205
- - spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/create_the_school_class.yml
206
- - spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/destroy_the_school_class.yml
207
- - spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/finds_all_school_class.yml
208
- - spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/finds_the_school_class.yml
209
- - spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/update_the_school_class.yml
210
251
  - spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/create_the_school_product.yml
211
252
  - spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/destroy_the_school_product.yml
212
253
  - spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_all_school_product.yml
@@ -218,6 +259,11 @@ files:
218
259
  - spec/fixtures/vcr_cassettes/Edools_Core_Student/finds_all_student.yml
219
260
  - spec/fixtures/vcr_cassettes/Edools_Core_Student/finds_the_student.yml
220
261
  - spec/fixtures/vcr_cassettes/Edools_Core_Student/update_the_student.yml
262
+ - spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/create_the_product.yml
263
+ - spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/destroy_the_product.yml
264
+ - spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/finds_all_product.yml
265
+ - spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/finds_the_product.yml
266
+ - spec/fixtures/vcr_cassettes/Edools_Ecommerce_Product/update_the_product.yml
221
267
  - spec/spec_helper.rb
222
268
  homepage: http://github.com/Edools/edools-api
223
269
  licenses:
@@ -1,30 +0,0 @@
1
- require 'active_resource'
2
-
3
- module Edools
4
- module Core
5
- class PaginatedCollection < ActiveResource::Collection
6
-
7
- # Our custom array to handle pagination methods
8
- attr_accessor :total_pages, :per_page, :total_count, :current_page
9
-
10
- # The initialize method will receive the ActiveResource parsed result
11
- # and set @elements.
12
- def initialize(parsed = {})
13
- @elements = parsed[resource_key(parsed.keys)]
14
- @total_pages = parsed["total_pages"]
15
- @per_page = parsed["per_page"]
16
- @total_count = parsed["total_count"]
17
- @current_page = parsed["current_page"]
18
- end
19
-
20
- private
21
-
22
- def resource_key(keys)
23
- (ObjectSpace.each_object(Class)
24
- .select{ |klass| klass < Edools::Core::Base }
25
- .collect { |klass| klass.name.split("::").last.downcase.pluralize } & keys).first
26
- end
27
-
28
- end
29
- end
30
- end
@@ -1,14 +0,0 @@
1
- require 'edools/core/base'
2
- require 'edools/core/paginated_collection'
3
-
4
- module Edools
5
- module Core
6
- class SchoolClass < Edools::Core::Base
7
- def self.collection_path(prefix_options = {}, query_options = nil)
8
- super
9
- school_product_id = prefix_options[:school_product_id] || query_options.try(:[], :school_product_id)
10
- "/school_products/#{school_product_id}/#{collection_name}.#{format.extension}#{query_string(query_options)}"
11
- end
12
- end
13
- end
14
- end
@@ -1,35 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Edools::Core::SchoolClass, :vcr do
4
- it 'finds all school class' do
5
- school_classs = Edools::Core::SchoolClass.all(params: { school_product_id: 156 })
6
-
7
- expect(school_classs.count).to eq 3
8
- end
9
-
10
- it 'finds the school class' do
11
- school_class = Edools::Core::SchoolClass.find(168)
12
-
13
- expect(school_class.id).to eq 168
14
- end
15
-
16
- it 'update the school class' do
17
- school_class = Edools::Core::SchoolClass.find(168)
18
- school_class.description = "test description"
19
-
20
- expect(school_class.save).to eq true
21
- end
22
-
23
- it 'create the school class' do
24
- school_class = Edools::Core::SchoolClass.new()
25
- school_class.prefix_options[:school_product_id] = 156
26
- school_class.title = 'teste'
27
-
28
- expect(school_class.save).to eq true
29
- end
30
-
31
- it 'destroy the school class' do
32
- school_class = Edools::Core::SchoolClass.find(168)
33
- expect(school_class.destroy.code).to eq '204'
34
- end
35
- end