bullet_train-api 1.3.14 → 1.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/api/controllers/base.rb +4 -0
- data/app/controllers/concerns/api/v1/invitations/controller_base.rb +66 -0
- data/app/views/api/v1/invitations/index.json.jbuilder +1 -0
- data/app/views/api/v1/invitations/show.json.jbuilder +1 -0
- data/config/routes.rb +5 -1
- data/lib/bullet_train/api/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d34df0b90eff4a61fb172e3d966a16ee832727a46d776422ea256d6037c4295
|
4
|
+
data.tar.gz: af6fec4a834593145936feb0b211dfa341672ed84a882fa5fae52ba7ebcb2032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ce192380dc8b1e9d19af67bc6f66c5d16c628ded83377823bd122c02d218071dcab63dc29f588bf683336b1501dfa66feddde3f9e92c20de4b2345306108afa
|
7
|
+
data.tar.gz: c8f309f01d27deafa830bf59676a388b0639eb6e76c4deb21e750933342c45921f3c8491399b0013c1cdb78dfc1e49475b4777f4cd088fbaf0d8a0bb75cf1e7d
|
@@ -89,6 +89,10 @@ module Api::Controllers::Base
|
|
89
89
|
current_user&.teams&.first
|
90
90
|
end
|
91
91
|
|
92
|
+
def current_membership
|
93
|
+
current_user.memberships.where(team: current_team).first
|
94
|
+
end
|
95
|
+
|
92
96
|
def collection_variable
|
93
97
|
@collection_variable ||= "@#{self.class.name.split("::").last.gsub("Controller", "").underscore}"
|
94
98
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Api::V1::Invitations::ControllerBase
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module StrongParameters
|
5
|
+
# Only allow a list of trusted parameters through.
|
6
|
+
def invitation_params
|
7
|
+
strong_params = params.require(:invitation).permit(
|
8
|
+
*permitted_fields,
|
9
|
+
:email,
|
10
|
+
# 🚅 super scaffolding will insert new fields above this line.
|
11
|
+
*permitted_arrays,
|
12
|
+
# 🚅 super scaffolding will insert new arrays above this line
|
13
|
+
)
|
14
|
+
|
15
|
+
process_params(strong_params)
|
16
|
+
|
17
|
+
strong_params
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
included do
|
22
|
+
load_and_authorize_resource :invitation, class: "Invitation", prepend: true,
|
23
|
+
member_actions: (defined?(MEMBER_ACTIONS) ? MEMBER_ACTIONS : []),
|
24
|
+
collection_actions: (defined?(COLLECTION_ACTIONS) ? COLLECTION_ACTIONS : [])
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
include StrongParameters
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /api/v1/teams/:team_id/invitations
|
32
|
+
def index
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /api/v1/invitations/:id
|
36
|
+
def show
|
37
|
+
end
|
38
|
+
|
39
|
+
# POST /api/v1/teams/:team_id/invitations
|
40
|
+
def create
|
41
|
+
@invitation.membership.team = current_team
|
42
|
+
# this allows notifications to be sent to a user before they've accepted their invitation.
|
43
|
+
@invitation.membership.user_email = @invitation.email
|
44
|
+
@invitation.from_membership = current_membership
|
45
|
+
if @invitation.save
|
46
|
+
render :show, status: :created, location: [:api, :v1, @invitation]
|
47
|
+
else
|
48
|
+
render json: @invitation.errors, status: :unprocessable_entity
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# POST /api/v1/invitations/1/resend
|
53
|
+
def resend
|
54
|
+
if @invitation.touch
|
55
|
+
UserMailer.invited(params[:id]).deliver_later
|
56
|
+
render :show, status: :ok, location: [:api, :v1, @invitation]
|
57
|
+
else
|
58
|
+
render json: @invitation.errors, status: :unprocessable_entity
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# DELETE /api/v1/invitations/:id
|
63
|
+
def destroy
|
64
|
+
@invitation.destroy
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @invitations, partial: "api/v1/invitations/invitation", as: :invitation
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "api/v1/invitations/invitation", invitation: @invitation
|
data/config/routes.rb
CHANGED
@@ -27,7 +27,11 @@ Rails.application.routes.draw do
|
|
27
27
|
shallow do
|
28
28
|
resources :users
|
29
29
|
resources :teams do
|
30
|
-
resources :invitations
|
30
|
+
resources :invitations do
|
31
|
+
member do
|
32
|
+
post :resend
|
33
|
+
end
|
34
|
+
end
|
31
35
|
resources :memberships
|
32
36
|
namespace :platform do
|
33
37
|
resources :applications do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- app/controllers/api/open_api_controller.rb
|
154
154
|
- app/controllers/api/v1/platform/access_tokens_controller.rb
|
155
155
|
- app/controllers/concerns/api/controllers/base.rb
|
156
|
+
- app/controllers/concerns/api/v1/invitations/controller_base.rb
|
156
157
|
- app/controllers/concerns/api/v1/memberships/controller_base.rb
|
157
158
|
- app/controllers/concerns/api/v1/teams/controller_base.rb
|
158
159
|
- app/controllers/concerns/api/v1/users/controller_base.rb
|
@@ -176,6 +177,8 @@ files:
|
|
176
177
|
- app/views/account/platform/applications/new.html.erb
|
177
178
|
- app/views/account/platform/applications/show.html.erb
|
178
179
|
- app/views/account/platform/connections/new.html.erb
|
180
|
+
- app/views/api/v1/invitations/index.json.jbuilder
|
181
|
+
- app/views/api/v1/invitations/show.json.jbuilder
|
179
182
|
- app/views/api/v1/memberships/index.json.jbuilder
|
180
183
|
- app/views/api/v1/memberships/show.json.jbuilder
|
181
184
|
- app/views/api/v1/open_api/shared/_paths.yaml.erb
|