Skip to content

Commit

Permalink
Invitations API (#737)
Browse files Browse the repository at this point in the history
* Invitations API

* Update invitation_example

* Update automatic_paths_for Invitation

* Add resend action
  • Loading branch information
newstler authored Aug 24, 2023
1 parent 927e020 commit 9281a37
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/controllers/api/v1/invitations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Api::V1::InvitationsController < Api::V1::ApplicationController
include Api::V1::Invitations::ControllerBase

private

def permitted_fields
[
# 🚅 super scaffolding will insert new fields above this line.
]
end

def permitted_arrays
{
# 🚅 super scaffolding will insert new arrays above this line.
}
end

def process_params(strong_params)
strong_params
end
end
1 change: 1 addition & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def initialize(user)
can :manage, User, id: user.id
can :read, User, id: user.collaborating_user_ids
can :destroy, Membership, user_id: user.id
can :manage, Invitation, id: user.teams.map(&:invitations).flatten.map(&:id)

can :create, Team

Expand Down
9 changes: 9 additions & 0 deletions app/views/api/v1/invitations/_invitation.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
json.extract! invitation,
:id,
:email,
:uuid,
:from_membership_id,
:team_id,
# 🚅 super scaffolding will insert new fields above this line.
:created_at,
:updated_at
2 changes: 2 additions & 0 deletions app/views/api/v1/open_api/index.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ components:
<%= automatic_components_for Team %>
<%= automatic_components_for User %>
<%= automatic_components_for Membership %>
<%= automatic_components_for Invitation %>
<%= automatic_components_for Webhooks::Outgoing::Endpoint %>
<%= automatic_components_for Webhooks::Outgoing::Event %>
<%= automatic_components_for Scaffolding::CompletelyConcrete::TangibleThing unless scaffolding_things_disabled? %>
Expand Down Expand Up @@ -51,6 +52,7 @@ paths:
<%= paths_for Team %>
<%= paths_for User %>
<%= automatic_paths_for Membership, Team %>
<%= automatic_paths_for Invitation, Team, except: %i[update] %>
<%= automatic_paths_for Webhooks::Outgoing::Endpoint, Team %>
<%= automatic_paths_for Webhooks::Outgoing::Event, Team, except: %i[create update delete] %>
<%= automatic_paths_for Scaffolding::CompletelyConcrete::TangibleThing, Scaffolding::AbsolutelyAbstract::CreativeConcept unless scaffolding_things_disabled? %>
Expand Down
19 changes: 19 additions & 0 deletions app/views/api/v1/open_api/invitations/_paths.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/invitations/{id}/resend:
post:
tags:
- Invitation
summary: "Resend Invitation"
operationId: resendInvitation
parameters:
- $ref: "#/components/parameters/id"
responses:
"404":
description: "Not Found"
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/TeamAttributes"
example:
<%= FactoryBot.get_example(:invitation, version: @version) %>
5 changes: 5 additions & 0 deletions test/factories/invitations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
association :team
association :from_membership, factory: :membership
sequence(:email) { |n| "example#{n}@email.com" }

factory :invitation_example do
team { FactoryBot.example(:team) }
membership { FactoryBot.example(:membership) }
end
end
end

0 comments on commit 9281a37

Please sign in to comment.