Skip to content

Instantly share code, notes, and snippets.

@richessler
Created April 21, 2016 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richessler/bd4eca1194af55ebf5c7ef7918f106c7 to your computer and use it in GitHub Desktop.
Save richessler/bd4eca1194af55ebf5c7ef7918f106c7 to your computer and use it in GitHub Desktop.
# 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