Module: Api::V1::Invitations::ControllerBase

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/concerns/api/v1/invitations/controller_base.rb

Defined Under Namespace

Modules: StrongParameters

Instance Method Summary collapse

Instance Method Details

#createObject

POST /api/v1/teams/:team_id/invitations



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/concerns/api/v1/invitations/controller_base.rb', line 40

def create
  @invitation.membership.team = current_team
  # this allows notifications to be sent to a user before they've accepted their invitation.
  @invitation.membership.user_email = @invitation.email
  @invitation.from_membership = current_membership
  if @invitation.save
    render :show, status: :created, location: [:api, :v1, @invitation]
  else
    render json: @invitation.errors, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /api/v1/invitations/:id



63
64
65
# File 'app/controllers/concerns/api/v1/invitations/controller_base.rb', line 63

def destroy
  @invitation.destroy
end

#indexObject

GET /api/v1/teams/:team_id/invitations



32
33
# File 'app/controllers/concerns/api/v1/invitations/controller_base.rb', line 32

def index
end

#resendObject

POST /api/v1/invitations/1/resend



53
54
55
56
57
58
59
60
# File 'app/controllers/concerns/api/v1/invitations/controller_base.rb', line 53

def resend
  if @invitation.touch
    UserMailer.invited(params[:id]).deliver_later
    render :show, status: :ok, location: [:api, :v1, @invitation]
  else
    render json: @invitation.errors, status: :unprocessable_entity
  end
end

#showObject

GET /api/v1/invitations/:id



36
37
# File 'app/controllers/concerns/api/v1/invitations/controller_base.rb', line 36

def show
end