Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
485ae1c8
Commit
485ae1c8
authored
Aug 04, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apis for users
parent
503bfee8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
app.rb
+23
-0
No files found.
app.rb
View file @
485ae1c8
...
...
@@ -204,10 +204,33 @@ delete '/api/v1/threads/:thread_id/votes' do |thread_id|
undo_vote_for
thread
end
post
'/api/v1/users'
do
user
=
User
.
new
user
.
external_id
=
params
[
"id"
]
user
.
username
=
params
[
"username"
]
user
.
email
=
params
[
"email"
]
user
.
save
if
user
.
errors
.
any?
error
400
,
user
.
errors
.
full_messages
.
to_json
else
user
.
to_hash
.
to_json
end
end
get
'/api/v1/users/:user_id'
do
|
user_id
|
user
.
to_hash
(
complete:
value_to_boolean
(
params
[
"complete"
])).
to_json
end
put
'/api/v1/users/:user_id'
do
|
user_id
|
user
.
update_attributes
(
params
.
slice
(
*
%w[username email]
)
user
.
save
if
user
.
errors
.
any?
error
400
,
user
.
errors
.
full_messages
.
to_json
else
user
.
to_hash
.
to_json
end
end
get
'/api/v1/users/:user_id/notifications'
do
|
user_id
|
user
.
notifications
.
map
(
&
:to_hash
).
to_json
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment