edmodo-api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edmodo-api (0.0.1)
4
+ edmodo-api (0.0.3)
5
5
  httparty
6
6
  json
7
7
 
data/README.markdown CHANGED
@@ -1,4 +1,5 @@
1
- Edmodo::API - Edmodo Ruby API client [![Build Status](https://secure.travis-ci.org/gabceb/edmodo-api.png)](http://travis-ci.org/gabceb/edmodo-api) [![Dependency Status](https://gemnasium.com/gabceb/edmodo-api.png)](https://gemnasium.com/gabceb/edmodo-api)
1
+ Edmodo::API - Edmodo Ruby API client [![Build Status](https://secure.travis-ci.org/gabceb/edmodo-api.png)](http://travis-ci.org/gabceb/edmodo-api) [![Dependency Status](https://gemnasium.com/gabceb/edmodo-api.png)](https://gemnasium.com/gabceb/edmodo-api) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/gabceb/edmodo-api)
2
+
2
3
  =======
3
4
 
4
5
  A Ruby wrapper for the Edmodo REST API.
@@ -30,6 +30,9 @@ module Edmodo
30
30
 
31
31
  raise_init_errors
32
32
 
33
+ # Adding the api key as a default parameter to all requests
34
+ self.class.default_params :api_key => @api_key
35
+
33
36
  @endpoint = Edmodo::API::Config.endpoints[@mode]
34
37
 
35
38
  end
@@ -69,7 +72,7 @@ module Edmodo
69
72
  #
70
73
  # => user_token: User token
71
74
  def groups_for_user user_token
72
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
75
+ request :get, resource_uri("groupsForUser", @format), {:user_token => user_token}
73
76
  end
74
77
 
75
78
  # Returns an array of user data for members of a group, specified by group id.
@@ -77,7 +80,7 @@ module Edmodo
77
80
  #
78
81
  # => group_id: integer Group ID
79
82
  def members group_id
80
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
83
+ request :get, resource_uri("members", @format), {:group_id => group_id}
81
84
  end
82
85
 
83
86
  # Returns an array of user data for all students that belong to at least one group with the student specified by user token.
@@ -85,7 +88,7 @@ module Edmodo
85
88
  #
86
89
  # => user_token: User token of the student
87
90
  def classmates user_token
88
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
91
+ request :get, resource_uri("classmates", @format), {:user_token => user_token}
89
92
  end
90
93
 
91
94
  # Returns an array of user data for all teachers for a student specified by user token.
@@ -93,7 +96,7 @@ module Edmodo
93
96
  #
94
97
  # => user_token: User token of the student
95
98
  def teachers user_token
96
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
99
+ request :get, resource_uri("teachers", @format), {:user_token => user_token}
97
100
  end
98
101
 
99
102
  # Returns an array of user data for all teachers that are connected to the teacher specified by user token.
@@ -101,7 +104,7 @@ module Edmodo
101
104
  #
102
105
  # => user_token: User token of the teacher
103
106
  def teachermates user_token
104
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
107
+ request :get, resource_uri("teachermates", @format), {:user_token => user_token}
105
108
  end
106
109
 
107
110
  # Returns an array of assignments coming due (in the next 60 days) for the user specified by the token.
@@ -109,7 +112,7 @@ module Edmodo
109
112
  #
110
113
  # => user_token: User token of the user
111
114
  def teacher_connections user_token
112
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
115
+ request :get, resource_uri("teacherConnections", @format), {:user_token => user_token}
113
116
  end
114
117
 
115
118
  # This call can be used in conjunction with turnInAssignment to allow a user to submit content from the app for a particular assignment in Edmodo.
@@ -117,7 +120,7 @@ module Edmodo
117
120
  #
118
121
  # => user_token: User token of the user
119
122
  def assignments_coming_due user_token
120
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
123
+ request :get, resource_uri("assignmentsComingDue", @format), {:user_token => user_token}
121
124
  end
122
125
 
123
126
  # Returns an array of grades set by the app for the given user token.
@@ -125,7 +128,7 @@ module Edmodo
125
128
  #
126
129
  # => user_token: User token of the user to get grades for
127
130
  def grades_set_by_app_for_user user_token
128
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
131
+ request :get, resource_uri("gradesSetByAppForUser", @format), {:user_token => user_token}
129
132
  end
130
133
 
131
134
  # Returns an array of grades set by the app for the given group.
@@ -133,7 +136,7 @@ module Edmodo
133
136
  #
134
137
  # => group_id: The group to get grades for.
135
138
  def grades_set_by_app_for_group group_id
136
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
139
+ request :get, resource_uri("gradesSetByAppForGroup", @format), {:group_id => group_id}
137
140
  end
138
141
 
139
142
  # Returns an array of badges awarded by the app to the given user token.
@@ -141,7 +144,7 @@ module Edmodo
141
144
  #
142
145
  # => user_token: The user_token to get badges awarded for.
143
146
  def badges_awarded user_token
144
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
147
+ request :get, resource_uri("badgesAwarded", @format), {:user_token => user_token}
145
148
  end
146
149
 
147
150
  # Returns an array of events set on behalf of the specified user by the app.
@@ -149,7 +152,7 @@ module Edmodo
149
152
  #
150
153
  # => user_token: The user token for the user from which events were set for.
151
154
  def events_by_app user_token
152
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
155
+ request :get, resource_uri("eventsByApp", @format), {:user_token => user_token}
153
156
  end
154
157
 
155
158
  # Returns an array of parent user data, given a specified student user token.
@@ -157,7 +160,7 @@ module Edmodo
157
160
  #
158
161
  # => user_token: User token of the student
159
162
  def parents user_token
160
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
163
+ request :get, resource_uri("parents", @format), {:user_token => user_token}
161
164
  end
162
165
 
163
166
  # Returns an array of data for students, given a specified parent user token.
@@ -165,7 +168,7 @@ module Edmodo
165
168
  #
166
169
  # => user_token: User token of the parent
167
170
  def children user_token
168
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
171
+ request :get, resource_uri("children", @format), {:user_token => user_token}
169
172
  end
170
173
 
171
174
  # Fetches user profile information.
@@ -190,7 +193,7 @@ module Edmodo
190
193
  # => recipients: Array of objects specifying the recipients of the post. These can be either users (specified by a user_token) or groups (specified by a group_id).
191
194
  # => attachments (Optional): array of objects specifying links/embed codes to include in the post message.
192
195
  def user_post user_token, content, recipients, attachments = nil
193
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
196
+ request(:post, resource_uri("userPost"), {:user_token => user_token, :content => content, :recipients => recipients, :attachments => attachments}.delete_if{ |k,v| v.nil? })
194
197
  end
195
198
 
196
199
  # Submits a response to the specified assignment for the given user. The id's for assignments coming due can be retrieved using the assignments_coming_due.
@@ -201,7 +204,7 @@ module Edmodo
201
204
  # => content: Text of the submission
202
205
  # => attachments (Optional): Array of objects specifying links/embed codes to include in the assignment submission
203
206
  def turn_in_assignment user_token, assignment_id, content, attachments = nil
204
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
207
+ request(:post, resource_uri("turnInAssignment"), {:user_token => user_token, :assignment_id => assignment_id, :content => content, :attachments => attachments}.delete_if{ |k,v| v.nil? } )
205
208
  end
206
209
 
207
210
  # Registers a badge with Edmodo, returning a badge id that can be used to award a badge that will display on an Edmodo user's profile.
@@ -211,7 +214,7 @@ module Edmodo
211
214
  # => description: limit 140 characters
212
215
  # => image_url: url to badge image, should be 114x114 pixels. Accepted image types: jpg, gif, png
213
216
  def register_badge badge_title, description, image_url
214
- request(:post, resource_uri("registerBadge"), {:badge_title => badge_title, :description => description, :image_url => image_url})
217
+ request(:post, resource_uri("registerBadge"), {:badge_title => badge_title, :description => description, :image_url => image_url}.delete_if { |k,v| v.nil? })
215
218
  end
216
219
 
217
220
  # Returns an array of user data for all teachers for a student specified by user token.
@@ -222,7 +225,7 @@ module Edmodo
222
225
  # => description: limit 140 characters
223
226
  # => image_url (Optional): If you wish to replace the image of the badge, specify the url of the new badge image. Otherwise, to keep the old badge image, you do not need to specify this parameter.
224
227
  def update_badge badge_id, badge_title, description, image_url = nil
225
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
228
+ request(:post, resource_uri("updateBadge"), {:badge_id => badge_id, :badge_title => badge_title, :description => description, :image_url => image_url}. delete_if{ |k,v| v.nil? })
226
229
  end
227
230
 
228
231
  # Awards a badge to a given user.
@@ -231,7 +234,7 @@ module Edmodo
231
234
  # => badge_id: Badge ID of the badge being awarded
232
235
  # => user_token: User token of the user receiving the badge
233
236
  def award_badge user_token, badge_id
234
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
237
+ request(:post, resource_uri("awardBadge"), {:user_token => user_token, :badge_id => badge_id})
235
238
  end
236
239
 
237
240
  # Revokes a badge that has been awarded to a given user.
@@ -239,8 +242,8 @@ module Edmodo
239
242
  #
240
243
  # => badge_id: Badge ID of the badge being revoked
241
244
  # => user_token: User token of the user who has been awarded the badge and whom it will be revoked from.
242
- def revoke_badge badge_id, user_token
243
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
245
+ def revoke_badge user_token, badge_id
246
+ request(:post, resource_uri("revokeBadge"), {:user_token => user_token, :badge_id => badge_id})
244
247
  end
245
248
 
246
249
  # Add a new grade to the gradebook for a given group.
@@ -250,7 +253,7 @@ module Edmodo
250
253
  # => title: The title for this grade
251
254
  # => total: The total grade possible for this grade
252
255
  def new_grade group_id, title, total
253
-
256
+ request(:post, resource_uri("newGrade"), {:group_id => group_id, :title => title, :total => total})
254
257
  end
255
258
 
256
259
  # Set a score for a grade given a specific user token.
@@ -259,8 +262,8 @@ module Edmodo
259
262
  # => grade_id: The grade the score is being set upon
260
263
  # => user_token: The user_token of the user to set the grade for
261
264
  # => score: The score to set for this grade
262
- def set_grade grade_id, user_token, score
263
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
265
+ def set_grade user_token, grade_id, score
266
+ request(:post, resource_uri("setGrade"), {:user_token => user_token, :grade_id => grade_id, :score => score})
264
267
  end
265
268
 
266
269
  # Set a new event on behalf of a user to specified recipients. Events will be seen on the calendar as well as notifications as the event approaches.
@@ -272,7 +275,7 @@ module Edmodo
272
275
  # => end_date: The end date of the event (specified in the format YYYY-MM-DD). If this is a single day event, the end date should simply be the same as the start date.
273
276
  # => recipients: array of objects specifying the recipients of the post. These can be either users (specified by a user_token) or groups (specified by a group_id).
274
277
  def new_event user_token, description, start_date, end_date, recipients
275
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
278
+ request(:post, resource_uri("newEvent"), {:user_token => user_token, :description => description, :start_date => start_date, :end_date => end_date, :recipients => recipients})
276
279
  end
277
280
 
278
281
  # Adds a resource (url or embed code) to a user's Library
@@ -282,7 +285,9 @@ module Edmodo
282
285
  # => publisher_owned: If you want the resources's author to be the publisher account associated with the app, set this parameter. Set to '1' if you want the resource to be publisher owned
283
286
  # => resource: Object specifying the link or embed code to add to the user's library.
284
287
  def add_to_library user_token, publisher_owned, resource
285
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
288
+ publisher_owned_int = publisher_owned ? 1 : 0
289
+
290
+ request(:post, resource_uri("addToLibrary"), {:user_token => user_token, :publisher_owned => publisher_owned_int, :resource => resource })
286
291
  end
287
292
 
288
293
  # Sets a specified count of app notifications for the user.
@@ -290,8 +295,8 @@ module Edmodo
290
295
  #
291
296
  # => user_token: The user_token of the user that will have the resource added to her/his library.
292
297
  # => notification_count: The number to add to the user's notification count for the app
293
- def set_notification user_token, notification
294
- raise EdmodoApiError.new("Edmodo API Error: Method not implemented")
298
+ def set_notification user_token, notification_count
299
+ request(:post, resource_uri("setNotification"), {:user_token => user_token, :notification_count => notification_count})
295
300
  end
296
301
 
297
302
  private
@@ -315,7 +320,7 @@ module Edmodo
315
320
 
316
321
  format = ".#{format}" if format
317
322
 
318
- "#{@endpoint}/#{resource}#{format}?api_key=#{api_key}"
323
+ "#{@endpoint}/#{resource}#{format}"
319
324
  end
320
325
 
321
326
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Edmodo
4
4
  module API
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
@@ -71,13 +71,6 @@ describe Edmodo::API::Client do
71
71
  response.should == {"user_type"=>"TEACHER", "user_token"=>"b020c42d1", "first_name"=>"Bob", "last_name"=>"Smith", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "groups"=>[{"group_id"=>379557, "is_owner"=>1}, {"group_id"=>379562, "is_owner"=>1}]}
72
72
  end
73
73
 
74
- it 'should get the correct hash back from the profiles request' do
75
-
76
- response = @client.profiles("b020c42d1")
77
-
78
- response.should == [{"user_token"=>"b020c42d1", "school"=>{"edmodo_school_id"=>123456, "nces_school_id"=>"ABC987654", "name"=>"Edmodo High", "address"=>"60 E. 3rd Avenue, #390", "city"=>"San Mateo", "state"=>"CA", "zip_code"=>"94401", "country_code"=>"US"}}]
79
- end
80
-
81
74
  it 'should get the correct hash back from the users request' do
82
75
 
83
76
  users_ids = ["b020c42d1","jd3i1c0pl"]
@@ -94,18 +87,127 @@ describe Edmodo::API::Client do
94
87
  response.should == [{"group_id"=>379557, "title"=>"Algebra", "member_count"=>20, "owners"=>["b020c42d1", "693d5c765"], "start_level"=>"9th", "end_level"=>"9th"}, {"group_id"=>379562, "title"=>"Geometry", "member_count"=>28, "owners"=>["b020c42d1"], "start_level"=>"3rd", "end_level"=>"3rd"}]
95
88
  end
96
89
 
97
- it 'should throw an exception if the method is not yet implemented' do
98
- user_id = "b020c42d1"
90
+ it 'should get the correct hash back from the groupsForUser request' do
91
+
92
+ response = @client.groups_for_user("b020c42d1")
93
+
94
+ response.should == [{"group_id"=>379557, "title"=>"Algebra", "member_count"=>20, "owners"=>["b020c42d1", "693d5c765"], "start_level"=>"9th", "end_level"=>"9th"}, {"group_id"=>379562, "title"=>"Geometry", "member_count"=>28, "owners"=>["b020c42d1"], "start_level"=>"3rd", "end_level"=>"3rd"}]
95
+ end
96
+
97
+ it 'should get the correct hash back from the members request' do
98
+
99
+ response = @client.members(379557)
100
+
101
+ response.should == [{"user_type"=>"TEACHER", "user_token"=>"b020c42d1", "first_name"=>"Bob", "last_name"=>"Smith", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"}, {"user_type"=>"TEACHER", "user_token"=>"693d5c765", "first_name"=>"Tom", "last_name"=>"Jefferson", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"}, {"user_type"=>"STUDENT", "user_token"=>"jd3i1c0pl", "first_name"=>"Jane", "last_name"=>"Student", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"}]
102
+ end
103
+
104
+ it 'should get the correct hash back from the classmates request' do
105
+
106
+ response = @client.classmates("jd3i1c0pl")
107
+
108
+ response.should == [{"user_type"=>"STUDENT", "user_token"=>"83a8e614d", "first_name"=>"Allison", "last_name"=>"Student", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "shared_groups"=>[379557, 379558]}, {"user_type"=>"STUDENT", "user_token"=>"7968c39b7", "first_name"=>"Mike", "last_name"=>"Student", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "shared_groups"=>[379558]}]
109
+ end
110
+
111
+ it 'should get the correct hash back from the teachers request' do
112
+
113
+ response = @client.teachers("jd3i1c0pl")
114
+
115
+ response.should == [{"user_type"=>"TEACHER", "user_token"=>"b020c42d1", "first_name"=>"Bob", "last_name"=>"Smith", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "title"=>"MR", "shared_groups"=>[379557]}, {"user_type"=>"TEACHER", "user_token"=>"693d5c765", "first_name"=>"Tom", "last_name"=>"Jefferson", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "title"=>"MR", "shared_groups"=>[379557, 379558]}]
116
+ end
117
+
118
+ it 'should get the correct hash back from the teachermates request' do
119
+
120
+ response = @client.teachermates("jd3i1c0pl")
121
+
122
+ response.should == [{"user_type"=>"TEACHER", "user_token"=>"b020c42d1", "first_name"=>"Bob", "last_name"=>"Smith", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "title"=>"MR", "shared_groups"=>[379557]}, {"user_type"=>"TEACHER", "user_token"=>"693d5c765", "first_name"=>"Tom", "last_name"=>"Jefferson", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "title"=>"MR", "shared_groups"=>[379557, 379558]}]
123
+ end
124
+
125
+ it 'should get the correct hash back from the teacherConnections request' do
126
+
127
+ response = @client.teacher_connections("jd3i1c0pl")
128
+
129
+ response.should == [{"user_type"=>"TEACHER", "user_token"=>"693d5c765", "first_name"=>"Tom", "last_name"=>"Jefferson", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "title"=>"MR"}]
130
+ end
131
+
132
+ it 'should get the correct hash back from the assignmentsComingDue request' do
133
+
134
+ response = @client.assignments_coming_due("jd3i1c0pl")
135
+
136
+ response.should == [{"assignment_id"=>4738052, "assignment_title"=>"Chapter 6 Homework", "description"=>"Do lots of practice problems ", "due_date"=>"2011-10-11", "recipients"=>[{"user_token"=>"9ff85e278"}, {"group_id"=>379557}], "creator"=>{"user_type"=>"TEACHER", "title"=>"MR", "first_name"=>"Bob", "last_name"=>"Smith", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "user_token"=>"b020c42d1"}}]
137
+ end
138
+
139
+ it 'should get the correct hash back from the gradesSetByAppForUser request' do
140
+
141
+ response = @client.grades_set_by_app_for_user("jd3i1c0pl")
142
+
143
+ response.should == [{"grade_id"=>3695, "title"=>"Super Project", "group_id"=>379557, "score"=>"8", "total"=>"10"}]
144
+ end
145
+
146
+ it 'should get the correct hash back from the gradesSetByAppForGroup request' do
147
+
148
+ response = @client.grades_set_by_app_for_group(379557)
149
+
150
+ response.should == [{"grade_id"=>3695, "title"=>"Super Project", "group_id"=>379557, "average_score"=>7, "total"=>"10", "graded_count"=>15}]
151
+ end
152
+
153
+ it 'should get the correct hash back from the badgesAwarded request' do
154
+
155
+ response = @client.badges_awarded("jd3i1c0pl")
156
+
157
+ response.should == [{"badge_id"=>6580, "image_url"=>"http://edmodobadges.s3.amazonaws.com/1234.jpg", "title"=>"Good Job", "description"=>"You did a good job!", "times_awarded"=>1}]
158
+ end
159
+
160
+ it 'should get the correct hash back from the eventsByApp request' do
161
+
162
+ response = @client.events_by_app("b020c42d1")
163
+
164
+ response.should == [{"event_id"=>621119, "description"=>"Pizza party tomorrow", "start_date"=>"2011-12-07", "end_date"=>"2011-12-07", "recipients"=>[{"user_token"=>"b020c42d1"}, {"group_id"=>379557}]}]
165
+ end
166
+
167
+ it 'should get the correct hash back from the parents request' do
168
+
169
+ response = @client.parents("jd3i1c0pl")
99
170
 
100
- expect { @client.children user_id }.to raise_error(EdmodoApiError)
171
+ response.should == [{"user_type"=>"PARENT", "user_token"=>"5e9c0e0f5", "first_name"=>"Mary", "last_name"=>"Smith", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png", "relation"=>"MOM"}]
172
+ end
173
+
174
+ it 'should get the correct hash back from the children request' do
175
+
176
+ response = @client.children("5e9c0e0f5")
177
+
178
+ response.should == [{"user_type"=>"STUDENT", "user_token"=>"jd3i1c0pl", "first_name"=>"Jane", "last_name"=>"Student", "avatar_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar.png", "thumb_url"=>"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"}]
179
+ end
180
+
181
+ it 'should get the correct hash back from the profiles request' do
182
+
183
+ response = @client.profiles("b020c42d1")
184
+
185
+ response.should == [{"user_token"=>"b020c42d1", "school"=>{"edmodo_school_id"=>123456, "nces_school_id"=>"ABC987654", "name"=>"Edmodo High", "address"=>"60 E. 3rd Avenue, #390", "city"=>"San Mateo", "state"=>"CA", "zip_code"=>"94401", "country_code"=>"US"}}]
101
186
  end
102
187
 
103
188
  end
104
189
 
105
190
  describe 'POST Requests' do
106
191
  before do
107
- api_key = "1234567890abcdefghijklmn"
108
- @client = Edmodo::API::Client.new(api_key)
192
+ @client = Edmodo::API::Client.new(@api_key)
193
+ end
194
+
195
+ it 'should get the correct response back from the userPost request' do
196
+
197
+ pending("This call has to be fixed")
198
+
199
+ response = @client.user_post("b020c42d1", "This is my test message", {:user_token => "b020c42d1", :user_token => "693d5c765", :group_id => 379557}, [{:type => "link", :title => "A link", :url => "http://www.edmodo.com"}, {:type => "embed", :title => "An embed with an optional thumbnail url", :thumb_url => "http://images.edmodo.com/images/logos/edmodo_134x43.png"}])
200
+
201
+ response.should == {:status => "success"}
202
+ end
203
+
204
+ it 'should get the correct response back from the turnInAssignment request' do
205
+
206
+ pending("This call has to be fixed")
207
+
208
+ response = @client.turn_in_assignment("83a8e614d", 4738052, "Here is my assignment submission", {:type => "link", :title => "A link", :url => "http://www.edmodo.com"})
209
+
210
+ response.should == {:status => "success"}
109
211
  end
110
212
 
111
213
  it 'should get the correct hash response from the registerBadge request' do
@@ -114,6 +216,63 @@ describe Edmodo::API::Client do
114
216
  response.should == {"badge_id" => 6580}
115
217
  end
116
218
 
219
+ it 'should get the correct hash response from the updateBadge request' do
220
+ response = @client.update_badge(6580, "Very Good Job", "You did a very good job", "http://www.edmodo.com/new_badge_image.png")
221
+
222
+ response.should == {"status" => "success"}
223
+ end
224
+
225
+ it 'should get the correct hash response from the awardBadge request' do
226
+ response = @client.award_badge("jd3i1c0pl", 6580)
227
+
228
+ response.should == {"success"=>1, "times_awarded"=>1}
229
+ end
230
+
231
+ it 'should get the correct hash response from the revokeBadge request' do
232
+ response = @client.revoke_badge("jd3i1c0pl", 6580)
233
+
234
+ response.should == {"success"=>1, "times_awarded"=>0}
235
+ end
236
+
237
+ it 'should get the correct hash response from the newGrade request' do
238
+ response = @client.new_grade(379557, "Super Project", 10)
239
+
240
+ response.should == {"grade_id"=>3694}
241
+ end
242
+
243
+ it 'should get the correct hash response from the setGrade request' do
244
+ response = @client.set_grade("jd3i1c0pl", 3694, 3)
245
+
246
+ response.should == {"user_token"=>"83a8e614d", "score"=>"3", "total" => "10"}
247
+ end
248
+
249
+ it 'should get the correct hash response from the newEvent request' do
250
+
251
+ pending("This call has to be fixed")
252
+
253
+ recipients = [{:user_token => "b020c42d1"},{:group_id => 379557}]
254
+ response = @client.new_event("b020c42d1", "Pizza party tomorrow", "2011-12-07", "2011-12-07", recipients)
255
+
256
+ response.should == {"event_id" => 621119}
257
+ end
258
+
259
+ it 'should get the correct hash response from the addToLibrary request' do
260
+
261
+ pending("This call has to be fixed")
262
+
263
+ resource = {:type => "link", :title => "A link", :url => "http://www.edmodo.com", :thumb_url => "http://images.edmodo.com/images/logos/edmodo_134x43.png" }
264
+ response = @client.add_to_library("b020c42d1", true, resource)
265
+
266
+ response.should == {"library_item_id" => "456"}
267
+ end
268
+
269
+ it 'should get the correct hash response from the setNotification request' do
270
+
271
+ response = @client.set_notification("b020c42d1", 1)
272
+
273
+ response.should == {"updated_notification_count" => "3"}
274
+ end
275
+
117
276
  end
118
277
 
119
278
  end
@@ -0,0 +1,379 @@
1
+ # Unauthorized request
2
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/launchRequests.json?api_key=#{@invalid_api_key}&launch_key=5c18c7"
3
+
4
+ FakeWeb.register_uri(:get, uri, :body => '{"error":{"code":3000,"message":"Unauthorized API request"}}', :status => ["401", "Authorization Required"])
5
+
6
+ # launchRequest request uri
7
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/launchRequests.json?api_key=#{@api_key}&launch_key=5c18c7"
8
+
9
+ FakeWeb.register_uri(:get, uri,
10
+ :body => ' {
11
+ "user_type":"TEACHER",
12
+ "user_token":"b020c42d1",
13
+ "first_name":"Bob",
14
+ "last_name":"Smith",
15
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
16
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
17
+ "groups":[
18
+ {
19
+ "group_id":379557,
20
+ "is_owner":1
21
+ },
22
+ {
23
+ "group_id":379562,
24
+ "is_owner":1
25
+ }
26
+ ]
27
+ }')
28
+
29
+ # Users request uri
30
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/users.json?api_key=#{@api_key}&user_tokens=%5B%22b020c42d1%22%2C%22jd3i1c0pl%22%5D"
31
+
32
+ FakeWeb.register_uri(:get, uri,
33
+ :body => ' [
34
+ {
35
+ "user_type":"TEACHER",
36
+ "user_token":"b020c42d1",
37
+ "first_name":"Bob",
38
+ "last_name":"Smith",
39
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
40
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
41
+ },
42
+ {
43
+ "user_type":"STUDENT",
44
+ "user_token":"jd3i1c0pl",
45
+ "first_name":"Jane",
46
+ "last_name":"Student",
47
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
48
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
49
+ }
50
+ ]')
51
+
52
+ # Profiles request uri
53
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/profiles.json?api_key=#{@api_key}&user_tokens=%5B%22b020c42d1%22%5D"
54
+
55
+ FakeWeb.register_uri(:get, uri,
56
+ :body => '[
57
+ {
58
+ "user_token":"b020c42d1",
59
+ "school":{
60
+ "edmodo_school_id":123456,
61
+ "nces_school_id":"ABC987654",
62
+ "name":"Edmodo High",
63
+ "address":"60 E. 3rd Avenue, #390",
64
+ "city":"San Mateo",
65
+ "state":"CA",
66
+ "zip_code":"94401",
67
+ "country_code":"US"
68
+ }
69
+ }
70
+ ]')
71
+
72
+ # Groups request uri
73
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/groups.json?api_key=#{@api_key}&group_ids=%5B379557%2C379562%5D"
74
+
75
+ FakeWeb.register_uri(:get, uri,
76
+ :body => '[{
77
+ "group_id":379557,
78
+ "title":"Algebra",
79
+ "member_count":20,
80
+ "owners":[
81
+ "b020c42d1",
82
+ "693d5c765"
83
+ ],
84
+ "start_level":"9th",
85
+ "end_level":"9th"
86
+ },
87
+ {
88
+ "group_id":379562,
89
+ "title":"Geometry",
90
+ "member_count":28,
91
+ "owners":[
92
+ "b020c42d1"
93
+ ],
94
+ "start_level":"3rd",
95
+ "end_level":"3rd"
96
+ }
97
+ ]')
98
+
99
+ # GroupsForUser request uri
100
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/groupsForUser.json?api_key=#{@api_key}&user_token=b020c42d1"
101
+
102
+ FakeWeb.register_uri(:get, uri,
103
+ :body => '[
104
+ {
105
+ "group_id":379557,
106
+ "title":"Algebra",
107
+ "member_count":20,
108
+ "owners":[
109
+ "b020c42d1",
110
+ "693d5c765"
111
+ ],
112
+ "start_level":"9th",
113
+ "end_level":"9th"
114
+ },
115
+ {
116
+ "group_id":379562,
117
+ "title":"Geometry",
118
+ "member_count":28,
119
+ "owners":[
120
+ "b020c42d1"
121
+ ],
122
+ "start_level":"3rd",
123
+ "end_level":"3rd"
124
+ }
125
+ ]')
126
+
127
+ # Members request uri
128
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/members.json?api_key=#{@api_key}&group_id=379557"
129
+
130
+ FakeWeb.register_uri(:get, uri,
131
+ :body => '[{
132
+ "user_type":"TEACHER",
133
+ "user_token":"b020c42d1",
134
+ "first_name":"Bob",
135
+ "last_name":"Smith",
136
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
137
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
138
+ },
139
+ {
140
+ "user_type":"TEACHER",
141
+ "user_token":"693d5c765",
142
+ "first_name":"Tom",
143
+ "last_name":"Jefferson",
144
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
145
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
146
+ },
147
+ {
148
+ "user_type":"STUDENT",
149
+ "user_token":"jd3i1c0pl",
150
+ "first_name":"Jane",
151
+ "last_name":"Student",
152
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
153
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
154
+ }
155
+ ]')
156
+
157
+ # Classmates request uri
158
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/classmates.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
159
+
160
+ FakeWeb.register_uri(:get, uri,
161
+ :body => '[{
162
+ "user_type":"STUDENT",
163
+ "user_token":"83a8e614d",
164
+ "first_name":"Allison",
165
+ "last_name":"Student",
166
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
167
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
168
+ "shared_groups":[
169
+ 379557,
170
+ 379558
171
+ ]
172
+ },
173
+ {
174
+ "user_type":"STUDENT",
175
+ "user_token":"7968c39b7",
176
+ "first_name":"Mike",
177
+ "last_name":"Student",
178
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
179
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
180
+ "shared_groups":[
181
+ 379558
182
+ ]
183
+ }
184
+ ]')
185
+
186
+ # Teachers request uri
187
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/teachers.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
188
+
189
+ FakeWeb.register_uri(:get, uri,
190
+ :body => '[{
191
+ "user_type":"TEACHER",
192
+ "user_token":"b020c42d1",
193
+ "first_name":"Bob",
194
+ "last_name":"Smith",
195
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
196
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
197
+ "title":"MR",
198
+ "shared_groups":[
199
+ 379557
200
+ ]
201
+ },
202
+ {
203
+ "user_type":"TEACHER",
204
+ "user_token":"693d5c765",
205
+ "first_name":"Tom",
206
+ "last_name":"Jefferson",
207
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
208
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
209
+ "title":"MR",
210
+ "shared_groups":[
211
+ 379557,
212
+ 379558
213
+ ]
214
+ }
215
+ ]')
216
+
217
+ # Teachermatess request uri
218
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/teachermates.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
219
+
220
+ FakeWeb.register_uri(:get, uri,
221
+ :body => '[{
222
+ "user_type":"TEACHER",
223
+ "user_token":"b020c42d1",
224
+ "first_name":"Bob",
225
+ "last_name":"Smith",
226
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
227
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
228
+ "title":"MR",
229
+ "shared_groups":[
230
+ 379557
231
+ ]
232
+ },
233
+ {
234
+ "user_type":"TEACHER",
235
+ "user_token":"693d5c765",
236
+ "first_name":"Tom",
237
+ "last_name":"Jefferson",
238
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
239
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
240
+ "title":"MR",
241
+ "shared_groups":[
242
+ 379557,
243
+ 379558
244
+ ]
245
+ }
246
+ ]')
247
+
248
+ # Teacher Connections request uri
249
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/teacherConnections.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
250
+
251
+ FakeWeb.register_uri(:get, uri,
252
+ :body => '[{
253
+ "user_type":"TEACHER",
254
+ "user_token":"693d5c765",
255
+ "first_name":"Tom",
256
+ "last_name":"Jefferson",
257
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
258
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
259
+ "title":"MR"
260
+ }
261
+ ]')
262
+
263
+ # AssignmentsComingDue request uri
264
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/assignmentsComingDue.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
265
+
266
+ FakeWeb.register_uri(:get, uri,
267
+ :body => '[{
268
+ "assignment_id":4738052,
269
+ "assignment_title":"Chapter 6 Homework",
270
+ "description":"Do lots of practice problems ",
271
+ "due_date":"2011-10-11",
272
+ "recipients":[
273
+ {
274
+ "user_token":"9ff85e278"
275
+ },
276
+ {
277
+ "group_id":379557
278
+ }
279
+ ],
280
+ "creator":{
281
+ "user_type":"TEACHER",
282
+ "title":"MR",
283
+ "first_name":"Bob",
284
+ "last_name":"Smith",
285
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
286
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
287
+ "user_token":"b020c42d1"
288
+ }
289
+ }
290
+ ]')
291
+
292
+ # gradesSetByAppForUser request uri
293
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/gradesSetByAppForUser.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
294
+
295
+ FakeWeb.register_uri(:get, uri,
296
+ :body => '[{
297
+ "grade_id":3695,
298
+ "title":"Super Project",
299
+ "group_id":379557,
300
+ "score":"8",
301
+ "total":"10"
302
+ }
303
+ ]')
304
+
305
+ # gradesSetByAppForGroup request uri
306
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/gradesSetByAppForGroup.json?api_key=#{@api_key}&group_id=379557"
307
+
308
+ FakeWeb.register_uri(:get, uri,
309
+ :body => '[{
310
+ "grade_id":3695,
311
+ "title":"Super Project",
312
+ "group_id":379557,
313
+ "average_score":7,
314
+ "total":"10",
315
+ "graded_count":15
316
+ }
317
+ ]')
318
+
319
+ # badgesAwarded request uri
320
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/badgesAwarded.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
321
+
322
+ FakeWeb.register_uri(:get, uri,
323
+ :body => '[{
324
+ "badge_id":6580,
325
+ "image_url":"http://edmodobadges.s3.amazonaws.com/1234.jpg",
326
+ "title":"Good Job",
327
+ "description":"You did a good job!",
328
+ "times_awarded":1
329
+ }
330
+ ]')
331
+
332
+ # eventsByApp request uri
333
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/eventsByApp.json?api_key=#{@api_key}&user_token=b020c42d1"
334
+
335
+ FakeWeb.register_uri(:get, uri,
336
+ :body => '[{
337
+ "event_id":621119,
338
+ "description":"Pizza party tomorrow",
339
+ "start_date":"2011-12-07",
340
+ "end_date":"2011-12-07",
341
+ "recipients":[
342
+ {
343
+ "user_token":"b020c42d1"
344
+ },
345
+ {
346
+ "group_id":379557
347
+ }
348
+ ]
349
+ }
350
+ ]')
351
+
352
+ # parents request uri
353
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/parents.json?api_key=#{@api_key}&user_token=jd3i1c0pl"
354
+
355
+ FakeWeb.register_uri(:get, uri,
356
+ :body => '[{
357
+ "user_type":"PARENT",
358
+ "user_token":"5e9c0e0f5",
359
+ "first_name":"Mary",
360
+ "last_name":"Smith",
361
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
362
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
363
+ "relation":"MOM"
364
+ }
365
+ ]')
366
+
367
+ # children request uri
368
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/children.json?api_key=#{@api_key}&user_token=5e9c0e0f5"
369
+
370
+ FakeWeb.register_uri(:get, uri,
371
+ :body => '[{
372
+ "user_type":"STUDENT",
373
+ "user_token":"jd3i1c0pl",
374
+ "first_name":"Jane",
375
+ "last_name":"Student",
376
+ "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
377
+ "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
378
+ }
379
+ ]')
@@ -0,0 +1,65 @@
1
+ # -- POST REQUESTS ---
2
+
3
+ # userPost request uri
4
+ recipients = "[{'user_token':'b020c42d1'},{'user_token':'693d5c765'},{'group_id':379557}]"
5
+ attachments = "[{'type':'link','title':'A link','url':'http://www.edmodo.com'},{'type':'embed','title':'An embed with an optional thumbnail url','thumb_url':'http://images.edmodo.com/images/logos/edmodo_134x43.png'}]"
6
+
7
+ uri = URI.encode "#{Edmodo::API::Config.endpoints[:sandbox]}/userPost?api_key=#{@api_key}&user_token=b020c42d1&content=This%20is%20my%20test%20message&recipients=#{recipients}&attachments=#{attachments}"
8
+
9
+ FakeWeb.register_uri(:post, uri, :body => '{"status":"success"}')
10
+
11
+ # turnInAssignment request uri
12
+ attachments = "[{'type':'link','title':'A link','url':'http://www.edmodo.com'}]"
13
+
14
+ uri = URI.encode "#{Edmodo::API::Config.endpoints[:sandbox]}/turnInAssignment?api_key=#{@api_key}&user_token=b020c42d1&assignment_id=4738052&content=Here%20is%20my%20assignment%20submission&attachments=#{attachments}"
15
+
16
+ FakeWeb.register_uri(:post, uri, :body => '{"status":"success"}')
17
+
18
+ # RegisterBadge request uri
19
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/registerBadge?api_key=#{@api_key}&badge_title=Good%20Job&description=You%20did%20a%20good%20job&image_url=http%3A%2F%2Fwww.edmodo.com%2Fbadge_image.png"
20
+
21
+ FakeWeb.register_uri(:post, uri, :body => '{"badge_id":6580}')
22
+
23
+ # UpdateBadge request uri
24
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/updateBadge?api_key=#{@api_key}&badge_id=6580&badge_title=Very%20Good%20Job&description=You%20did%20a%20very%20good%20job&image_url=http%3A%2F%2Fwww.edmodo.com%2Fnew_badge_image.png"
25
+
26
+ FakeWeb.register_uri(:post, uri, :body => '{"status":"success"}')
27
+
28
+ # awardBadge request uri
29
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/awardBadge?api_key=#{@api_key}&user_token=jd3i1c0pl&badge_id=6580"
30
+
31
+ FakeWeb.register_uri(:post, uri, :body => '{"success":1, "times_awarded":1}')
32
+
33
+ # revokeBadge request uri
34
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/revokeBadge?api_key=#{@api_key}&user_token=jd3i1c0pl&badge_id=6580"
35
+
36
+ FakeWeb.register_uri(:post, uri, :body => '{"success":1, "times_awarded":0}')
37
+
38
+ # newGrade request uri
39
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/newGrade?api_key=#{@api_key}&group_id=379557&title=Super%20Project&total=10"
40
+
41
+ FakeWeb.register_uri(:post, uri, :body => '{"grade_id":3694}')
42
+
43
+ # setGrade request uri
44
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/setGrade?api_key=#{@api_key}&grade_id=3694&user_token=jd3i1c0pl&score=3"
45
+
46
+ FakeWeb.register_uri(:post, uri, :body => '{"user_token":"83a8e614d", "score":"3", "total":"10"}')
47
+
48
+ # newEvent request uri
49
+ receipients = URI.encode '[{"user_token":"b020c42d1"},{"group_id":379557}]'
50
+
51
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/newEvent?api_key=#{@api_key}&user_token=b020c42d1&description=Pizza+party+tomorrow&start_date=2011-12-07&end_date=2011-12-07&recipients=#{receipients}"
52
+
53
+ FakeWeb.register_uri(:post, uri, :body => '{"event_id":621119}')
54
+
55
+ # addToLibrary request uri
56
+ resource = URI.encode '{"type":"link","title":"A link","url":"http://www.edmodo.com","thumb_url":"http://images.edmodo.com/images/logos/edmodo_134x43.png"}'
57
+
58
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/addToLibrary?api_key=#{@api_key}&user_token=b020c42d1&publisher_owned=1&resource=#{resource}"
59
+
60
+ FakeWeb.register_uri(:post, uri, :body => '{"library_item_id":"456"}')
61
+
62
+ # setNotification request uri
63
+ uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/setNotification?api_key=#{@api_key}&user_token=b020c42d1&notification_count=1"
64
+
65
+ FakeWeb.register_uri(:post, uri, :body => '{"updated_notification_count":"3"}')
data/spec/spec_helper.rb CHANGED
@@ -3,111 +3,12 @@
3
3
  $: << File.join(File.dirname(__FILE__), "/../lib")
4
4
  require 'edmodo-api'
5
5
  require 'fakeweb'
6
+ require 'uri'
6
7
 
7
8
  @api_key = "1234567890abcdefghijklmn"
8
9
  @invalid_api_key = "invalid_key"
9
10
 
10
11
  FakeWeb.allow_net_connect = false
11
12
 
12
- # Unauthorized request
13
- uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/launchRequests.json?api_key=#{@invalid_api_key}&launch_key=5c18c7"
14
-
15
- FakeWeb.register_uri(:get, uri, :body => '{"error":{"code":3000,"message":"Unauthorized API request"}}', :status => ["401", "Authorization Required"])
16
-
17
- # launchRequest request uri
18
- uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/launchRequests.json?api_key=#{@api_key}&launch_key=5c18c7"
19
-
20
- FakeWeb.register_uri(:get, uri,
21
- :body => ' {
22
- "user_type":"TEACHER",
23
- "user_token":"b020c42d1",
24
- "first_name":"Bob",
25
- "last_name":"Smith",
26
- "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
27
- "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png",
28
- "groups":[
29
- {
30
- "group_id":379557,
31
- "is_owner":1
32
- },
33
- {
34
- "group_id":379562,
35
- "is_owner":1
36
- }
37
- ]
38
- }')
39
-
40
- # Users request uri
41
- uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/users.json?api_key=#{@api_key}&user_tokens=%5B%22b020c42d1%22%2C%22jd3i1c0pl%22%5D"
42
-
43
- FakeWeb.register_uri(:get, uri,
44
- :body => ' [
45
- {
46
- "user_type":"TEACHER",
47
- "user_token":"b020c42d1",
48
- "first_name":"Bob",
49
- "last_name":"Smith",
50
- "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
51
- "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
52
- },
53
- {
54
- "user_type":"STUDENT",
55
- "user_token":"jd3i1c0pl",
56
- "first_name":"Jane",
57
- "last_name":"Student",
58
- "avatar_url":"http://edmodoimages.s3.amazonaws.com/default_avatar.png",
59
- "thumb_url":"http://edmodoimages.s3.amazonaws.com/default_avatar_t.png"
60
- }
61
- ]')
62
-
63
- # Profiles request uri
64
- uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/profiles.json?api_key=#{@api_key}&user_tokens=%5B%22b020c42d1%22%5D"
65
-
66
- FakeWeb.register_uri(:get, uri,
67
- :body => '[
68
- {
69
- "user_token":"b020c42d1",
70
- "school":{
71
- "edmodo_school_id":123456,
72
- "nces_school_id":"ABC987654",
73
- "name":"Edmodo High",
74
- "address":"60 E. 3rd Avenue, #390",
75
- "city":"San Mateo",
76
- "state":"CA",
77
- "zip_code":"94401",
78
- "country_code":"US"
79
- }
80
- }
81
- ]')
82
-
83
- uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/groups.json?api_key=#{@api_key}&group_ids=%5B379557%2C379562%5D"
84
-
85
- FakeWeb.register_uri(:get, uri,
86
- :body => '[{
87
- "group_id":379557,
88
- "title":"Algebra",
89
- "member_count":20,
90
- "owners":[
91
- "b020c42d1",
92
- "693d5c765"
93
- ],
94
- "start_level":"9th",
95
- "end_level":"9th"
96
- },
97
- {
98
- "group_id":379562,
99
- "title":"Geometry",
100
- "member_count":28,
101
- "owners":[
102
- "b020c42d1"
103
- ],
104
- "start_level":"3rd",
105
- "end_level":"3rd"
106
- }
107
- ]')
108
-
109
- # RegisterBadge request uri
110
- uri = "#{Edmodo::API::Config.endpoints[:sandbox]}/registerBadge?api_key=#{@api_key}&badge_title=Good%20Job&description=You%20did%20a%20good%20job&image_url=http%3A%2F%2Fwww.edmodo.com%2Fbadge_image.png"
111
-
112
- FakeWeb.register_uri(:post, uri, :body => '{"badge_id":6580}')
113
-
13
+ require 'requests/get_requests'
14
+ require 'requests/post_requests'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edmodo-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -128,6 +128,8 @@ files:
128
128
  - lib/edmodo-api/request.rb
129
129
  - lib/edmodo-api/version.rb
130
130
  - spec/edmodo-api_spec.rb
131
+ - spec/requests/get_requests.rb
132
+ - spec/requests/post_requests.rb
131
133
  - spec/spec_helper.rb
132
134
  homepage: https://github.com/gabceb/edmodo-api
133
135
  licenses: