edools-api 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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +21 -0
  3. data/VERSION +1 -1
  4. data/edools-api.gemspec +121 -0
  5. data/lib/edools/core.rb +1 -0
  6. data/lib/edools/core/enrollment.rb +10 -0
  7. data/lib/edools/core/organization.rb +1 -1
  8. data/lib/edools/core/registration.rb +1 -1
  9. data/lib/edools/core/school.rb +1 -1
  10. data/lib/edools/core/school_class.rb +14 -0
  11. data/lib/edools/core/school_product.rb +7 -1
  12. data/lib/edools/core/student.rb +3 -0
  13. data/spec/edools/core/enrollment_spec.rb +19 -16
  14. data/spec/edools/core/school_class_spec.rb +35 -0
  15. data/spec/edools/core/school_product_spec.rb +18 -16
  16. data/spec/edools/core/school_spec.rb +17 -12
  17. data/spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/create_the_enrollment.yml +183 -0
  18. data/spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/finds_all_enrollment.yml +65 -0
  19. data/spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/finds_the_enrollment.yml +63 -0
  20. data/spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/update_the_enrollment.yml +119 -0
  21. data/spec/fixtures/vcr_cassettes/Edools_Core_School/create_the_school.yml +61 -0
  22. data/spec/fixtures/vcr_cassettes/Edools_Core_School/finds_all_school.yml +61 -0
  23. data/spec/fixtures/vcr_cassettes/Edools_Core_School/finds_the_school.yml +61 -0
  24. data/spec/fixtures/vcr_cassettes/Edools_Core_School/update_the_school.yml +115 -0
  25. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/create_the_school_class.yml +65 -0
  26. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/destroy_the_school_class.yml +113 -0
  27. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/finds_all_school_class.yml +61 -0
  28. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/finds_the_school_class.yml +61 -0
  29. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/update_the_school_class.yml +116 -0
  30. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/create_the_school_product.yml +66 -0
  31. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/destroy_the_school_product.yml +114 -0
  32. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_all_school_product.yml +186 -0
  33. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_the_school_product.yml +62 -0
  34. data/spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/update_the_school_product.yml +118 -0
  35. metadata +24 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3eade3c23eee728077692f503d70ba857c08046
4
- data.tar.gz: 5091623e13c4f66a376c337444a29e92ff01798f
3
+ metadata.gz: d56f4560d47d60772bd66ba32a6070704247b05a
4
+ data.tar.gz: 5832b7c3890b0bb29d94135bee8bfbb8969ba002
5
5
  SHA512:
6
- metadata.gz: 554440efb0345b30a1374dc8df8e6f4ec24b292d2dfd8c5c6fff7fec4a62531c8377da9162a10d458919f1858b401d408fe3a6d7109718ed735882c548881ccf
7
- data.tar.gz: d9d1bdf18515517ba422e2fa5c54481525bb92299d7207a4366623af9ea22c75fedb784ba9f7a7e284f0fa1b818c61166ca120422b60d9845526def719b84b70
6
+ metadata.gz: feb27b20f54868075b9a80a8b3f9a0f6f1c259887fc09aa4a9cbb6d08e67b3dd480f18b49e3d7399cf48fa458339520a64b0e2f97d53746d9d76f2fd1b37de94
7
+ data.tar.gz: bc1a1ff5a8b93d03f556d07107472da4542408fe3959f8dd054273ffbccf1be59e88dfe1a73acbc717529f322d2d678ccc35080c6eeda4d992d28d18106384df
@@ -0,0 +1,21 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ charset = utf-8
7
+ trim_trailing_whitespace = true
8
+ insert_final_newline = true
9
+
10
+ [*.rb]
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ [Rakefile]
15
+ indent_style = space
16
+ indent_size = 2
17
+
18
+ [Gemfile*]
19
+ indent_style = space
20
+ indent_size = 2
21
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,121 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: edools-api 0.2.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "edools-api"
9
+ s.version = "0.2.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Vinicius Kastrup"]
14
+ s.date = "2014-07-30"
15
+ s.description = "\n With this gem you'll be able to access and manipulate all the data of your School or Organization\n hosted at Edools.\n "
16
+ s.email = "viniciusmkm@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".editorconfig",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "edools-api.gemspec",
31
+ "lib/edools.rb",
32
+ "lib/edools/config.rb",
33
+ "lib/edools/core.rb",
34
+ "lib/edools/core/base.rb",
35
+ "lib/edools/core/enrollment.rb",
36
+ "lib/edools/core/organization.rb",
37
+ "lib/edools/core/paginated_collection.rb",
38
+ "lib/edools/core/registration.rb",
39
+ "lib/edools/core/school.rb",
40
+ "lib/edools/core/school_class.rb",
41
+ "lib/edools/core/school_product.rb",
42
+ "lib/edools/core/student.rb",
43
+ "lib/edools/initialization.rb",
44
+ "spec/edools/core/base_spec.rb",
45
+ "spec/edools/core/enrollment_spec.rb",
46
+ "spec/edools/core/organization_spec.rb",
47
+ "spec/edools/core/registration_spec.rb",
48
+ "spec/edools/core/school_class_spec.rb",
49
+ "spec/edools/core/school_product_spec.rb",
50
+ "spec/edools/core/school_spec.rb",
51
+ "spec/edools/core/student_spec.rb",
52
+ "spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/create_the_enrollment.yml",
53
+ "spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/finds_all_enrollment.yml",
54
+ "spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/finds_the_enrollment.yml",
55
+ "spec/fixtures/vcr_cassettes/Edools_Core_Enrollment/update_the_enrollment.yml",
56
+ "spec/fixtures/vcr_cassettes/Edools_Core_School/create_the_school.yml",
57
+ "spec/fixtures/vcr_cassettes/Edools_Core_School/finds_all_school.yml",
58
+ "spec/fixtures/vcr_cassettes/Edools_Core_School/finds_the_school.yml",
59
+ "spec/fixtures/vcr_cassettes/Edools_Core_School/update_the_school.yml",
60
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/create_the_school_class.yml",
61
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/destroy_the_school_class.yml",
62
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/finds_all_school_class.yml",
63
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/finds_the_school_class.yml",
64
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolClass/update_the_school_class.yml",
65
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/create_the_school_product.yml",
66
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/destroy_the_school_product.yml",
67
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_all_school_product.yml",
68
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/finds_the_school_product.yml",
69
+ "spec/fixtures/vcr_cassettes/Edools_Core_SchoolProduct/update_the_school_product.yml",
70
+ "spec/fixtures/vcr_cassettes/Edools_Core_Student/create_the_student.yml",
71
+ "spec/fixtures/vcr_cassettes/Edools_Core_Student/destroy_the_student.yml",
72
+ "spec/fixtures/vcr_cassettes/Edools_Core_Student/finds_all_student.yml",
73
+ "spec/fixtures/vcr_cassettes/Edools_Core_Student/finds_the_student.yml",
74
+ "spec/fixtures/vcr_cassettes/Edools_Core_Student/update_the_student.yml",
75
+ "spec/spec_helper.rb"
76
+ ]
77
+ s.homepage = "http://github.com/Edools/edools-api"
78
+ s.licenses = ["MIT"]
79
+ s.rubygems_version = "2.2.2"
80
+ s.summary = "This gem is a Ruby wrapper for all Edools API's"
81
+
82
+ if s.respond_to? :specification_version then
83
+ s.specification_version = 4
84
+
85
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
86
+ s.add_runtime_dependency(%q<activeresource>, [">= 4.0.0"])
87
+ s.add_development_dependency(%q<rspec>, ["~> 3.0.0"])
88
+ s.add_development_dependency(%q<vcr>, ["~> 2.9.2"])
89
+ s.add_development_dependency(%q<webmock>, ["~> 1.18.0"])
90
+ s.add_development_dependency(%q<pry>, ["~> 0.10.0"])
91
+ s.add_development_dependency(%q<yard>, ["~> 0.7"])
92
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
93
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
94
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
95
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
96
+ else
97
+ s.add_dependency(%q<activeresource>, [">= 4.0.0"])
98
+ s.add_dependency(%q<rspec>, ["~> 3.0.0"])
99
+ s.add_dependency(%q<vcr>, ["~> 2.9.2"])
100
+ s.add_dependency(%q<webmock>, ["~> 1.18.0"])
101
+ s.add_dependency(%q<pry>, ["~> 0.10.0"])
102
+ s.add_dependency(%q<yard>, ["~> 0.7"])
103
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
104
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
105
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
106
+ s.add_dependency(%q<simplecov>, [">= 0"])
107
+ end
108
+ else
109
+ s.add_dependency(%q<activeresource>, [">= 4.0.0"])
110
+ s.add_dependency(%q<rspec>, ["~> 3.0.0"])
111
+ s.add_dependency(%q<vcr>, ["~> 2.9.2"])
112
+ s.add_dependency(%q<webmock>, ["~> 1.18.0"])
113
+ s.add_dependency(%q<pry>, ["~> 0.10.0"])
114
+ s.add_dependency(%q<yard>, ["~> 0.7"])
115
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
116
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
117
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
118
+ s.add_dependency(%q<simplecov>, [">= 0"])
119
+ end
120
+ end
121
+
@@ -3,5 +3,6 @@ require 'edools/core/enrollment'
3
3
  require 'edools/core/organization'
4
4
  require 'edools/core/registration'
5
5
  require 'edools/core/school'
6
+ require 'edools/core/school_class'
6
7
  require 'edools/core/school_product'
7
8
  require 'edools/core/student'
@@ -5,6 +5,16 @@ module Edools
5
5
  module Core
6
6
  class Enrollment < Edools::Core::Base
7
7
  self.collection_parser = PaginatedCollection
8
+
9
+ def self.collection_path(prefix_options = {}, query_options = nil)
10
+ super
11
+ student_id = prefix_options[:student_id] || query_options.try(:[], :student_id)
12
+ if student_id
13
+ "/students/#{student_id}/#{collection_name}.#{format.extension}#{query_string(query_options)}"
14
+ else
15
+ "/#{collection_name}.#{format.extension}#{query_string(query_options)}"
16
+ end
17
+ end
8
18
  end
9
19
  end
10
20
  end
@@ -4,7 +4,7 @@ require 'edools/core/paginated_collection'
4
4
  module Edools
5
5
  module Core
6
6
  class Organization < Edools::Core::Base
7
- self.collection_parser = PaginatedCollection
7
+ # self.collection_parser = PaginatedCollection
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ require 'edools/core/paginated_collection'
4
4
  module Edools
5
5
  module Core
6
6
  class Registration < Edools::Core::Base
7
- self.collection_parser = PaginatedCollection
7
+ # self.collection_parser = PaginatedCollection
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ require 'edools/core/paginated_collection'
4
4
  module Edools
5
5
  module Core
6
6
  class School < Edools::Core::Base
7
- self.collection_parser = PaginatedCollection
7
+ # self.collection_parser = PaginatedCollection
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,14 @@
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
@@ -4,7 +4,13 @@ require 'edools/core/paginated_collection'
4
4
  module Edools
5
5
  module Core
6
6
  class SchoolProduct < Edools::Core::Base
7
- self.collection_parser = PaginatedCollection
7
+ # self.collection_parser = PaginatedCollection
8
+
9
+ def self.collection_path(prefix_options = {}, query_options = nil)
10
+ super
11
+ school_id = prefix_options[:school_id] || query_options.try(:[], :school_id)
12
+ "/schools/#{school_id}/#{collection_name}.#{format.extension}#{query_string(query_options)}"
13
+ end
8
14
  end
9
15
  end
10
16
  end
@@ -1,11 +1,14 @@
1
1
  require 'edools/core/base'
2
2
  require 'edools/core/paginated_collection'
3
+ require 'edools/core/enrollment'
3
4
 
4
5
  module Edools
5
6
  module Core
6
7
  class Student < Edools::Core::Base
7
8
  self.collection_parser = PaginatedCollection
8
9
 
10
+ has_many :enrollments, class_name: 'edools/core/enrollment'
11
+
9
12
  def to_json(options={})
10
13
  super(include_root_in_json ? { root: 'user' }.merge(options) : options)
11
14
  end
@@ -1,33 +1,36 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Edools::Core::Enrollment, :vcr do
4
- xit 'finds the enrollment' do
5
- enrollment = Edools::Core::Enrollment.find(1249)
4
+ it 'finds all enrollment' do
5
+ enrollments = Edools::Core::Enrollment.all(params: { student_id: 1024 })
6
6
 
7
- expect(enrollment.id).to eq 1249
7
+ expect(enrollments.count).to eq 2
8
8
  end
9
9
 
10
- xit 'finds all enrollment' do
11
- enrollments = Edools::Core::Enrollment.all
10
+ it 'finds the enrollment' do
11
+ enrollment = Edools::Core::Enrollment.find(1035)
12
12
 
13
- expect(enrollments.count).to eq 5
13
+ expect(enrollment.id).to eq 1035
14
14
  end
15
15
 
16
- xit 'update the enrollment' do
17
- enrollment = Edools::Core::Enrollment.find(1249)
18
- enrollment.phone = Time.now.to_i.to_s
16
+ it 'update the enrollment' do
17
+ enrollment = Edools::Core::Enrollment.find(1035)
18
+ enrollment.status = 'expired'
19
19
 
20
- expect(enrollment.save).to be_true
20
+ expect(enrollment.save).to eq true
21
21
  end
22
22
 
23
- xit 'create the enrollment' do
23
+ it 'create the enrollment' do
24
+ student = Edools::Core::Student.find(:first)
25
+ school_class = Edools::Core::SchoolClass.find(:first, params: { school_product_id: 156 })
26
+
24
27
  enrollment = Edools::Core::Enrollment.new()
25
28
 
26
- expect(enrollment.save).to be_true
27
- end
29
+ enrollment.registration_id = student.registrations.first.id
30
+ enrollment.school_class_id = school_class.id
31
+ enrollment.unlimited = true
32
+ enrollment.status = 'active'
28
33
 
29
- xit 'destroy the enrollment' do
30
- enrollment = Edools::Core::Enrollment.find(1249)
31
- expect(enrollment.destroy).to be_true
34
+ expect(enrollment.save).to eq true
32
35
  end
33
36
  end
@@ -0,0 +1,35 @@
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
@@ -1,33 +1,35 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Edools::Core::SchoolProduct, :vcr do
4
- xit 'finds the school product' do
5
- schoolproduct = Edools::Core::SchoolProduct.find(1249)
4
+ it 'finds all school product' do
5
+ school_products = Edools::Core::SchoolProduct.all(params: { school_id: 224 })
6
6
 
7
- expect(schoolproduct.id).to eq 1249
7
+ expect(school_products.count).to eq 8
8
8
  end
9
9
 
10
- xit 'finds all school product' do
11
- schoolproducts = Edools::Core::SchoolProduct.all
10
+ it 'finds the school product' do
11
+ school_product = Edools::Core::SchoolProduct.find(170)
12
12
 
13
- expect(schoolproducts.count).to eq 5
13
+ expect(school_product.id).to eq 170
14
14
  end
15
15
 
16
- xit 'update the school product' do
17
- schoolproduct = Edools::Core::SchoolProduct.find(1249)
18
- schoolproduct.phone = Time.now.to_i.to_s
16
+ it 'update the school product' do
17
+ school_product = Edools::Core::SchoolProduct.find(170)
18
+ school_product.description = "test description"
19
19
 
20
- expect(schoolproduct.save).to be_true
20
+ expect(school_product.save).to eq true
21
21
  end
22
22
 
23
- xit 'create the school product' do
24
- schoolproduct = Edools::Core::SchoolProduct.new()
23
+ it 'create the school product' do
24
+ school_product = Edools::Core::SchoolProduct.new()
25
+ school_product.prefix_options[:school_id] = 224
26
+ school_product.title = 'teste'
25
27
 
26
- expect(schoolproduct.save).to be_true
28
+ expect(school_product.save).to eq true
27
29
  end
28
30
 
29
- xit 'destroy the school product' do
30
- schoolproduct = Edools::Core::Schoolproduct.find(1249)
31
- expect(schoolproduct.destroy).to be_true
31
+ it 'destroy the school product' do
32
+ school_product = Edools::Core::SchoolProduct.find(170)
33
+ expect(school_product.destroy.code).to eq '204'
32
34
  end
33
35
  end
@@ -1,32 +1,37 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Edools::Core::School, :vcr do
4
- xit 'finds the school' do
5
- school = Edools::Core::School.find(1249)
4
+ it 'finds all school' do
5
+ schools = Edools::Core::School.all
6
6
 
7
- expect(school.id).to eq 1249
7
+ expect(schools.count).to eq 1
8
8
  end
9
9
 
10
- xit 'finds all school' do
11
- schools = Edools::Core::School.all
10
+ it 'finds the school' do
11
+ school = Edools::Core::School.find(224)
12
12
 
13
- expect(schools.count).to eq 5
13
+ expect(school.id).to eq 224
14
14
  end
15
15
 
16
- xit 'update the school' do
17
- school = Edools::Core::School.find(1249)
18
- school.phone = Time.now.to_i.to_s
16
+ it 'update the school' do
17
+ school = Edools::Core::School.find(224)
18
+ school.phone = "12345678"
19
19
 
20
- expect(school.save).to be_true
20
+ expect(school.save).to eq true
21
21
  end
22
22
 
23
- xit 'create the school' do
23
+ it 'create the school' do
24
+ pending 'should use an ApiKey with Organization as realm'
24
25
  school = Edools::Core::School.new()
26
+ school.name = "Teste"
27
+ school.subdomain = "teste"
28
+ school.status = "trial"
25
29
 
26
- expect(school.save).to be_true
30
+ expect(school.save).to eq true
27
31
  end
28
32
 
29
33
  xit 'destroy the school' do
34
+ pending 'should use an ApiKey with Organization as realm'
30
35
  school = Edools::Core::School.find(1249)
31
36
  expect(school.destroy).to be_true
32
37
  end