appolo 1.1.1 → 1.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c6bd7fbebc71c62bf43de47bedd14eea09be9ba
4
- data.tar.gz: dc11a28359fcfeb8e60b179d85b6b4c4ce601014
3
+ metadata.gz: 3a8dce19c2f19fd5335d2a1118e9c06a5f706132
4
+ data.tar.gz: e37dc28eaa44895a5104527f717fea6e32b128c8
5
5
  SHA512:
6
- metadata.gz: 22989f4723378dc4426fdb03d88e9e873a3d62e46dac472d25187e576ff7aa501cebc48277a1adad66a9ca81c540c2434e0d8275d4fce3e69e34cea6d5d9a6bc
7
- data.tar.gz: ac5e0ba1a806812e55609607ec310489b114ae3a437d8fe66c58c2900c1cca0a6dfc86f7762b2856d1567d88bc5b84a17d7117db0cad0994e54d919c3b5e06e3
6
+ metadata.gz: 170b6d32b06d178eaceb1e64aa8da24a4836c6ffce1862e59be3b6137a47ec8bc9ede5a1a47362701814c90be1abdf3f947102e6cf647b1dd5c3ad8933c6a467
7
+ data.tar.gz: cfb7f57bc1d21431c20e7df831726933c5cc78e3a8ac2a4a6364064c5c9516684d8c67db8a79ff2a3d42abf829413391024b2ebb19038bdcc33f64bb5f59e091
data/lib/Appolo.rb CHANGED
@@ -6,7 +6,7 @@ require_relative '../lib/Appolo/Models/main_model/classes'
6
6
  require_relative '../lib/Appolo/Models/main_model/program'
7
7
  require_relative '../lib/Appolo/Models/main_model/courses'
8
8
  require_relative '../lib/Appolo/Models/main_model/lective_semester'
9
-
9
+ require_relative '../lib/Appolo/Models/result'
10
10
  require 'json'
11
11
 
12
12
  ##
@@ -52,6 +52,11 @@ module Appolo
52
52
  end
53
53
  end
54
54
 
55
+ def self.build_result(result,error)
56
+ Result.new(result, error)
57
+ end
58
+
59
+
55
60
  public
56
61
 
57
62
  ##
@@ -69,7 +74,7 @@ module Appolo
69
74
  end
70
75
  $all_students
71
76
  rescue => e
72
- nil #TODO - exceptions
77
+ $all_students
73
78
  end
74
79
  end
75
80
 
@@ -89,7 +94,7 @@ module Appolo
89
94
  end
90
95
  $all_teachers
91
96
  rescue => e
92
- nil
97
+ $all_teachers
93
98
  end
94
99
  end
95
100
 
@@ -109,7 +114,7 @@ module Appolo
109
114
  end
110
115
  $all_programs
111
116
  rescue => e
112
- nil
117
+ $all_programs
113
118
  end
114
119
  end
115
120
 
@@ -129,7 +134,7 @@ module Appolo
129
134
  end
130
135
  $all_courses
131
136
  rescue => e
132
- nil
137
+ $all_courses
133
138
  end
134
139
  end
135
140
 
@@ -149,7 +154,7 @@ module Appolo
149
154
  end
150
155
  $all_lective_sem
151
156
  rescue => e
152
- nil
157
+ $all_lective_sem
153
158
  end
154
159
  end
155
160
 
@@ -169,7 +174,7 @@ module Appolo
169
174
  end
170
175
  $all_classes
171
176
  rescue => e
172
- nil
177
+ $all_classes
173
178
  end
174
179
  end
175
180
 
@@ -177,12 +182,12 @@ module Appolo
177
182
  # Return a single instance of Teacher based upon the +id+ given.
178
183
 
179
184
  def self.get_teacher_by_id(id)
180
- return $all_teachers[id] unless $all_teachers.count == 0
185
+ #return $all_teachers[id] unless $all_teachers.count == 0
181
186
  begin
182
187
  response = RestClient.get TEACHERS_API_LINK + id.to_s
183
188
  Teacher.new(verify_response response)
184
189
  rescue => e
185
- nil
190
+ e
186
191
  end
187
192
  end
188
193
 
@@ -191,12 +196,12 @@ module Appolo
191
196
  # Return a single instance of Classes based upon the +id+ given.
192
197
 
193
198
  def self.get_class_by_id(id)
194
- return $all_classes[id] unless $all_classes.count == 0
199
+ #return $all_classes[id] unless $all_classes.count == 0
195
200
  begin
196
201
  response = RestClient.get CLASSES_API_LINK + id.to_s
197
202
  Classes.new(verify_response response)
198
203
  rescue => e
199
- nil
204
+ e
200
205
  end
201
206
  end
202
207
 
@@ -204,22 +209,25 @@ module Appolo
204
209
  # Return a single instance of Student based upon the +id+ given.
205
210
 
206
211
  def self.get_student_by_id(id)
207
- return $all_students[id] unless $all_students.count == 0
212
+ #return $all_students[id] unless $all_students.count == 0
208
213
  begin
209
214
  response = RestClient.get STUDENTS_API_LINK + id.to_s
210
215
  Student.new(verify_response response)
211
216
  rescue => e
212
- nil
217
+ e
213
218
  end
214
219
  end
215
220
 
221
+ ##
222
+ # Return a single instance of program based upon the +id+ given.
223
+
216
224
  def self.get_program_by_id(id)
217
- return $all_programs[id] unless $all_programs.count == 0
225
+ #return $all_programs[id] unless $all_programs.count == 0
218
226
  begin
219
227
  response = RestClient.get PROGRAMS_API_LINK + id.to_s
220
228
  Program.new(verify_response response)
221
229
  rescue => e
222
- nil
230
+ e
223
231
  end
224
232
  end
225
233
 
@@ -12,7 +12,11 @@ class Student < Element
12
12
  attr_reader :number, :name, :academic_email, :github_username
13
13
  attr_reader :avatar_url, :program, :students
14
14
 
15
- def initialize(json_str)
15
+ def initialize(json_str = nil)
16
+ if json_str.nil?
17
+ return
18
+ end
19
+
16
20
  json_data = Appolo.check_json_info json_str
17
21
 
18
22
  super(json_data[ModelUtils::ID],
@@ -0,0 +1,21 @@
1
+ class Result
2
+
3
+ attr_reader :result, :error, :message
4
+
5
+ def initialize(result, error)
6
+ @result = result
7
+ @error = error
8
+
9
+ @message = @error.message unless @error.nil?
10
+
11
+ end
12
+
13
+ def has_result
14
+ @result.nil?
15
+ end
16
+
17
+ def to_s
18
+ "Has Result: #{has_result} Has Error: #{@has_error}"
19
+ end
20
+
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Appolo
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Gabriel
@@ -120,6 +120,7 @@ files:
120
120
  - lib/Appolo/Models/main_model/student.rb
121
121
  - lib/Appolo/Models/main_model/teacher.rb
122
122
  - lib/Appolo/Models/model_utils.rb
123
+ - lib/Appolo/Models/result.rb
123
124
  - lib/Appolo/Models/secondary/avatar_url.rb
124
125
  - lib/Appolo/Models/secondary/lecture.rb
125
126
  - lib/Appolo/Models/secondary/links.rb