Created
April 21, 2016 20:23
-
-
Save richessler/bd4eca1194af55ebf5c7ef7918f106c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module API | |
module V1 | |
module Resources | |
module Messaging | |
class Conversations < API::V1::Root | |
resources :conversations, decs: 'Operations related to Conversations' do | |
desc 'Get existing Conversations for a User' do | |
headers API::V1::Defaults.auth_headers | |
success API::V1::Entities::Messaging::Conversation | |
end | |
oauth2 | |
get do | |
present current_user.conversations, with: API::V1::Entities::Messaging::Conversation | |
end | |
desc 'Get all Messages for Conversation' do | |
headers API::V1::Defaults.auth_headers | |
success API::V1::Entities::Messaging::Message | |
end | |
params do | |
requires :conversation_id, type: Integer, desc: 'The Conversation ID' | |
end | |
oauth2 | |
route_param :conversation_id do | |
get 'messages' do | |
messages = current_user.conversations.find(params[:conversation_id]).messages | |
present messages, with: API::V1::Entities::Messaging::Message | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment