Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@ API endpoints that Operation Code's Rails backend makes available to its React f
errors: "Some error message"
}

## Slack User | Invite [/api/v1/slack_users]

### Invite a User to Slack [POST]

+ Request (application/json)

+ Headers

Authorization: Bearer Access-Token

+ Response 200 (application/json)

+ Body

{
status: 200
}

+ Response 422 (application/json)

{
errors: "Some error message"
}

## Tag | Collection [/api/v1/tags]

### List All Tags [GET]
Expand Down
17 changes: 17 additions & 0 deletions app/controllers/api/v1/slack_users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Api
module V1
class SlackUsersController < ApplicationController
before_action :authenticate_user!

def create
raise "User id #{current_user.id} does not have a saved email address." unless current_user.email.present?

SlackJobs::InviterJob.perform_now current_user.email

render json: { status: :ok }
rescue StandardError => e
render json: { errors: e.message }, status: :unprocessable_entity
end
end
end
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
get '/status', to: 'status#all'
get '/status/protected', to: 'status#protected'

post '/users/profile/verify', to: 'users#verify'
get '/users/by_location', to: 'users#by_location'
post '/users/profile/verify', to: 'users#verify'

resources :code_schools, only: :index
resources :events, only: :index
Expand All @@ -19,6 +19,7 @@
resources :votes, only: [:create, :destroy]
end
resources :services, only: :index
resources :slack_users, only: :create
resources :squads, only: [:index, :create, :show] do
member do
post 'join'
Expand Down