bullet_train-api 1.3.15 → 1.3.17
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/helpers/api/open_api_helper.rb +0 -23
- data/app/views/api/v1/invitations/index.json.jbuilder +1 -0
- data/app/views/api/v1/invitations/show.json.jbuilder +1 -0
- data/app/views/api/v1/open_api/invitations/_paths.yaml.erb +19 -0
- data/config/routes.rb +5 -1
- data/lib/bullet_train/api/example_bot.rb +4 -4
- data/lib/bullet_train/api/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bd21b8d9bef3aaf2459c4bce32197d88a29b9346a499695a0d94d078e1e8591
|
4
|
+
data.tar.gz: 67757160ccf1b7a5a072047d11f7a203f881e08e1383cd9ab7dc51a81e211cd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77d721f4bf15c2f1fe3d3f41372073f1d7a6db69b5777f32a0325df655a31f6bb4d5866683eff92b0c145dffa5d81b24afc3bb273fdc2d15d81f4de53e1987ed
|
7
|
+
data.tar.gz: 65a9b312db8dd9ced25f98ea8df1c205cdf14d8ab6bd8b35bec8382371ea212e2986ca038cf42047b7f80116d17d6acc3de0b4ce40bcddacda77c871e55b4485
|
@@ -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
|
@@ -7,13 +7,6 @@ module Api
|
|
7
7
|
lines.unshift(first_line).join.html_safe
|
8
8
|
end
|
9
9
|
|
10
|
-
# TODO: Remove this method? It's not being used anywhere
|
11
|
-
def components_for(model)
|
12
|
-
for_model model do
|
13
|
-
indent(render("api/#{@version}/open_api/#{model.name.underscore.pluralize}/components"), 2)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
10
|
def current_model
|
18
11
|
@model_stack.last
|
19
12
|
end
|
@@ -112,22 +105,6 @@ module Api
|
|
112
105
|
end
|
113
106
|
end
|
114
107
|
|
115
|
-
def attribute(attribute)
|
116
|
-
heading = t("#{current_model.name.underscore.pluralize}.fields.#{attribute}.heading")
|
117
|
-
attribute_data = current_model.columns_hash[attribute.to_s]
|
118
|
-
|
119
|
-
# Default to `string` when the type returns nil.
|
120
|
-
type = attribute_data.nil? ? "string" : attribute_data.type
|
121
|
-
|
122
|
-
attribute_block = <<~YAML
|
123
|
-
#{attribute}:
|
124
|
-
description: "#{heading}"
|
125
|
-
type: #{type}
|
126
|
-
YAML
|
127
|
-
indent(attribute_block.chomp, 2)
|
128
|
-
end
|
129
|
-
alias_method :parameter, :attribute
|
130
|
-
|
131
108
|
private
|
132
109
|
|
133
110
|
def has_strong_parameters?(controller)
|
@@ -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
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/invitations/{id}/resend:
|
2
|
+
post:
|
3
|
+
tags:
|
4
|
+
- Invitation
|
5
|
+
summary: "Resend Invitation"
|
6
|
+
operationId: resendInvitation
|
7
|
+
parameters:
|
8
|
+
- $ref: "#/components/parameters/id"
|
9
|
+
responses:
|
10
|
+
"404":
|
11
|
+
description: "Not Found"
|
12
|
+
"200":
|
13
|
+
description: "OK"
|
14
|
+
content:
|
15
|
+
application/json:
|
16
|
+
schema:
|
17
|
+
$ref: "#/components/schemas/InvitationAttributes"
|
18
|
+
example:
|
19
|
+
<%= FactoryBot.get_example(:invitation, version: @version) %>
|
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
|
@@ -4,13 +4,13 @@ module FactoryBot
|
|
4
4
|
module ExampleBot
|
5
5
|
attr_accessor :tables_to_reset
|
6
6
|
|
7
|
-
def example(model, **
|
7
|
+
def example(model, **)
|
8
8
|
@tables_to_reset = [model.to_s.pluralize]
|
9
9
|
|
10
10
|
object = nil
|
11
11
|
|
12
12
|
ActiveRecord::Base.transaction do
|
13
|
-
instance = FactoryBot.create(factory(model), **
|
13
|
+
instance = FactoryBot.create(factory(model), **)
|
14
14
|
object = deep_clone(instance)
|
15
15
|
|
16
16
|
raise ActiveRecord::Rollback
|
@@ -20,13 +20,13 @@ module FactoryBot
|
|
20
20
|
object
|
21
21
|
end
|
22
22
|
|
23
|
-
def example_list(model, quantity, **
|
23
|
+
def example_list(model, quantity, **)
|
24
24
|
@tables_to_reset = [model.to_s.pluralize]
|
25
25
|
|
26
26
|
objects = []
|
27
27
|
|
28
28
|
ActiveRecord::Base.transaction do
|
29
|
-
instances = FactoryBot.create_list(factory(model), quantity, **
|
29
|
+
instances = FactoryBot.create_list(factory(model), quantity, **)
|
30
30
|
|
31
31
|
instances.each do |instance|
|
32
32
|
objects << deep_clone(instance)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -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,8 +177,11 @@ 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
|
184
|
+
- app/views/api/v1/open_api/invitations/_paths.yaml.erb
|
181
185
|
- app/views/api/v1/open_api/shared/_paths.yaml.erb
|
182
186
|
- app/views/api/v1/open_api/teams/_paths.yaml.erb
|
183
187
|
- app/views/api/v1/open_api/users/_paths.yaml.erb
|