bullet_train-outgoing_webhooks 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +12 -0
- data/app/controllers/account/webhooks/outgoing/endpoints_controller.rb +1 -0
- data/app/controllers/api/v1/webhooks/outgoing/endpoints_controller.rb +56 -0
- data/app/controllers/api/v1/webhooks/outgoing.rb +2 -0
- data/app/controllers/api/v1/webhooks.rb +2 -0
- data/app/controllers/api/v1.rb +2 -0
- data/app/models/concerns/webhooks/outgoing/endpoint_support.rb +5 -0
- data/app/models/concerns/webhooks/outgoing/event_support.rb +10 -1
- data/app/models/concerns/webhooks/outgoing/uri_filtering.rb +1 -1
- data/app/models/webhooks/outgoing/event_type.rb +1 -1
- data/app/views/account/webhooks/outgoing/endpoints/_form.html.erb +2 -0
- data/app/views/api/v1/open_api/index.yaml.erb +31 -0
- data/app/views/api/v1/webhooks/outgoing/endpoints/_endpoint.json.jbuilder +9 -0
- data/app/views/api/v1/webhooks/outgoing/endpoints/index.json.jbuilder +1 -0
- data/app/views/api/v1/webhooks/outgoing/endpoints/show.json.jbuilder +1 -0
- data/config/locales/en/webhooks/outgoing/endpoints.en.yml +12 -0
- data/config/routes.rb +16 -0
- data/db/migrate/20221130063357_add_creative_concept_to_endpoints.rb +10 -0
- data/lib/bullet_train/outgoing_webhooks/version.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23e370f35fe3576ece3f53bf90646d3a9123b21332fdb4d51c4c13114a39a68f
|
4
|
+
data.tar.gz: 478c93ba922ee9902b8ac0a596d7375d28d0ad0d06f7e4dc82406d15092683ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad5301b39cb85072c2f7554f74e6612a0fc49a8e81ea625530d170411105c9b5a252c6865f28036ff21edd93647c54fc135aa7584f996772411819a16e9029ca
|
7
|
+
data.tar.gz: d1089060d13d3847a172e44970004a9609f4ce7b12f0d3f6a7f5b3063ca7d99a4665ecd5f9ffefbd9e3cebe91d08986b49a3aa32af5de21e6ded26ad5c8593f4
|
data/Rakefile
CHANGED
@@ -6,3 +6,15 @@ load "rails/tasks/engine.rake"
|
|
6
6
|
load "rails/tasks/statistics.rake"
|
7
7
|
|
8
8
|
require "bundler/gem_tasks"
|
9
|
+
|
10
|
+
require "rake/testtask"
|
11
|
+
require "standard/rake"
|
12
|
+
|
13
|
+
Rake::TestTask.new do |t|
|
14
|
+
t.libs << "test"
|
15
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
16
|
+
t.verbose = true
|
17
|
+
t.warning = false
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: %i[test standard]
|
@@ -67,6 +67,7 @@ class Account::Webhooks::Outgoing::EndpointsController < Account::ApplicationCon
|
|
67
67
|
strong_params = params.require(:webhooks_outgoing_endpoint).permit(
|
68
68
|
:name,
|
69
69
|
:url,
|
70
|
+
:scaffolding_absolutely_abstract_creative_concept_id,
|
70
71
|
# 🚅 super scaffolding will insert new fields above this line.
|
71
72
|
event_type_ids: [],
|
72
73
|
# 🚅 super scaffolding will insert new arrays above this line.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class Api::V1::Webhooks::Outgoing::EndpointsController < Api::V1::ApplicationController
|
2
|
+
account_load_and_authorize_resource :endpoint, through: :team, through_association: :webhooks_outgoing_endpoints
|
3
|
+
|
4
|
+
# GET /api/v1/teams/:team_id/webhooks/outgoing/endpoints
|
5
|
+
def index
|
6
|
+
end
|
7
|
+
|
8
|
+
# GET /api/v1/webhooks/outgoing/endpoints/:id
|
9
|
+
def show
|
10
|
+
end
|
11
|
+
|
12
|
+
# POST /api/v1/teams/:team_id/webhooks/outgoing/endpoints
|
13
|
+
def create
|
14
|
+
if @endpoint.save
|
15
|
+
render :show, status: :created, location: [:api, :v1, @endpoint]
|
16
|
+
else
|
17
|
+
render json: @endpoint.errors, status: :unprocessable_entity
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# PATCH/PUT /api/v1/webhooks/outgoing/endpoints/:id
|
22
|
+
def update
|
23
|
+
if @endpoint.update(endpoint_params)
|
24
|
+
render :show
|
25
|
+
else
|
26
|
+
render json: @endpoint.errors, status: :unprocessable_entity
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# DELETE /api/v1/webhooks/outgoing/endpoints/:id
|
31
|
+
def destroy
|
32
|
+
@endpoint.destroy
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
module StrongParameters
|
38
|
+
# Only allow a list of trusted parameters through.
|
39
|
+
def endpoint_params
|
40
|
+
strong_params = params.require(:webhooks_outgoing_endpoint).permit(
|
41
|
+
*permitted_fields,
|
42
|
+
:url,
|
43
|
+
:name,
|
44
|
+
# 🚅 super scaffolding will insert new fields above this line.
|
45
|
+
*permitted_arrays,
|
46
|
+
# 🚅 super scaffolding will insert new arrays above this line.
|
47
|
+
)
|
48
|
+
|
49
|
+
process_params(strong_params)
|
50
|
+
|
51
|
+
strong_params
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
include StrongParameters
|
56
|
+
end
|
@@ -4,6 +4,7 @@ module Webhooks::Outgoing::EndpointSupport
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
belongs_to BulletTrain::OutgoingWebhooks.parent_association
|
7
|
+
belongs_to :scaffolding_absolutely_abstract_creative_concept, optional: true, class_name: "Scaffolding::AbsolutelyAbstract::CreativeConcept"
|
7
8
|
|
8
9
|
has_many :deliveries, class_name: "Webhooks::Outgoing::Delivery", dependent: :destroy, foreign_key: :endpoint_id
|
9
10
|
has_many :events, -> { distinct }, through: :deliveries
|
@@ -27,6 +28,10 @@ module Webhooks::Outgoing::EndpointSupport
|
|
27
28
|
Webhooks::Outgoing::EventType.all
|
28
29
|
end
|
29
30
|
|
31
|
+
def creative_concepts
|
32
|
+
team.scaffolding_absolutely_abstract_creative_concepts
|
33
|
+
end
|
34
|
+
|
30
35
|
def event_types
|
31
36
|
event_type_ids.map { |id| Webhooks::Outgoing::EventType.find(id) }
|
32
37
|
end
|
@@ -28,7 +28,16 @@ module Webhooks::Outgoing::EventSupport
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def endpoints
|
31
|
-
send(BulletTrain::OutgoingWebhooks.parent_association).webhooks_outgoing_endpoints.listening_for_event_type_id(event_type_id)
|
31
|
+
endpoints = send(BulletTrain::OutgoingWebhooks.parent_association).webhooks_outgoing_endpoints.listening_for_event_type_id(event_type_id)
|
32
|
+
|
33
|
+
case self.class.name
|
34
|
+
when "Scaffolding::AbsolutelyAbstract::CreativeConcept"
|
35
|
+
endpoints.where(scaffolding_absolutely_abstract_creative_concept_id: [object.id, nil])
|
36
|
+
when "Scaffolding::CompletelyConcrete::TangibleThing"
|
37
|
+
endpoints.where(scaffolding_absolutely_abstract_creative_concept_id: [object.absolutely_abstract_creative_concept_id, nil])
|
38
|
+
else
|
39
|
+
endpoints
|
40
|
+
end
|
32
41
|
end
|
33
42
|
|
34
43
|
def deliver
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Webhooks::Outgoing::EventType < ApplicationHash
|
2
2
|
self.data = YAML.load_file("config/models/webhooks/outgoing/event_types.yml").map do |topic, events|
|
3
|
-
events.map { |event| event == "crud" ? ["created", "updated", "deleted"] : event }.flatten.map { |event| {id: "#{topic}.#{event}"} }
|
3
|
+
events.map { |event| (event == "crud") ? ["created", "updated", "deleted"] : event }.flatten.map { |event| {id: "#{topic}.#{event}"} }
|
4
4
|
end.flatten
|
5
5
|
|
6
6
|
def label_string
|
@@ -4,6 +4,8 @@
|
|
4
4
|
<% with_field_settings form: form do %>
|
5
5
|
<%= render 'shared/fields/text_field', method: :name, options: {autofocus: true} %>
|
6
6
|
<%= render 'shared/fields/text_field', method: :url %>
|
7
|
+
<%= render 'shared/fields/super_select', method: :scaffolding_absolutely_abstract_creative_concept_id,
|
8
|
+
choices: [['None', '']] + @endpoint.creative_concepts.map { |event_type| [event_type.name, event_type.id] }, other_options: {search: true} %>
|
7
9
|
<%= render 'shared/fields/super_select', method: :event_type_ids, html_options: {multiple: true},
|
8
10
|
choices: @endpoint.valid_event_types.map { |event_type| [event_type.label_string, event_type.id] } %>
|
9
11
|
<%# 🚅 super scaffolding will insert new fields above this line. %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
openapi: 3.1.0
|
2
|
+
info:
|
3
|
+
title: Bullet Train API
|
4
|
+
description: |
|
5
|
+
The baseline API of a new Bullet Train application.
|
6
|
+
license:
|
7
|
+
name: MIT
|
8
|
+
url: https://opensource.org/licenses/MIT
|
9
|
+
version: "<%= @version.upcase %>"
|
10
|
+
servers:
|
11
|
+
- url: <%= ENV["BASE_URL"] %>/api/<%= @version %>
|
12
|
+
components:
|
13
|
+
securitySchemes:
|
14
|
+
BearerAuth:
|
15
|
+
type: http
|
16
|
+
scheme: bearer
|
17
|
+
schemas:
|
18
|
+
<%= automatic_components_for Webhooks::Outgoing::Endpoint %>
|
19
|
+
<%# 🚅 super scaffolding will insert new components above this line. %>
|
20
|
+
parameters:
|
21
|
+
id:
|
22
|
+
name: id
|
23
|
+
in: path
|
24
|
+
required: true
|
25
|
+
schema:
|
26
|
+
type: string
|
27
|
+
security:
|
28
|
+
- BearerAuth: []
|
29
|
+
paths:
|
30
|
+
<%= automatic_paths_for Webhooks::Outgoing::Endpoint, Team %>
|
31
|
+
<%# 🚅 super scaffolding will insert new paths above this line. %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @endpoints, partial: "api/v1/webhooks/outgoing/endpoints/endpoint", as: :endpoint
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "api/v1/webhooks/outgoing/endpoints/endpoint", endpoint: @endpoint
|
@@ -24,6 +24,11 @@ en:
|
|
24
24
|
label: *id
|
25
25
|
heading: *id
|
26
26
|
|
27
|
+
team_id:
|
28
|
+
_: &team_id Team ID
|
29
|
+
label: *team_id
|
30
|
+
heading: *team_id
|
31
|
+
|
27
32
|
name:
|
28
33
|
_: &name Name
|
29
34
|
label: *name
|
@@ -41,6 +46,12 @@ en:
|
|
41
46
|
all: All Events
|
42
47
|
event_types: *event_types
|
43
48
|
|
49
|
+
scaffolding_absolutely_abstract_creative_concept_id:
|
50
|
+
_: &scaffolding_absolutely_abstract_creative_concept_id Creative Concept
|
51
|
+
label: *scaffolding_absolutely_abstract_creative_concept_id
|
52
|
+
heading: *scaffolding_absolutely_abstract_creative_concept_id
|
53
|
+
placeholder: "Type your response here"
|
54
|
+
|
44
55
|
# 🚅 super scaffolding will insert new fields above this line.
|
45
56
|
created_at:
|
46
57
|
_: &created_at Added
|
@@ -106,3 +117,4 @@ en:
|
|
106
117
|
# 🚅 super scaffolding will insert new activerecord attributes above this line.
|
107
118
|
created_at: *created_at
|
108
119
|
updated_at: *updated_at
|
120
|
+
scaffolding_absolutely_abstract_creative_concept_id: *scaffolding_absolutely_abstract_creative_concept_id
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
+
extending = {only: []}
|
3
|
+
|
2
4
|
namespace :account do
|
3
5
|
shallow do
|
4
6
|
resources BulletTrain::OutgoingWebhooks.parent_resource do
|
@@ -15,4 +17,18 @@ Rails.application.routes.draw do
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
20
|
+
|
21
|
+
namespace :api do
|
22
|
+
namespace :v1 do
|
23
|
+
shallow do
|
24
|
+
resources :teams, extending do
|
25
|
+
namespace :webhooks do
|
26
|
+
namespace :outgoing do
|
27
|
+
resources :endpoints, defaults: {format: :json}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
18
34
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AddCreativeConceptToEndpoints < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
add_reference(
|
4
|
+
:webhooks_outgoing_endpoints,
|
5
|
+
:scaffolding_absolutely_abstract_creative_concept,
|
6
|
+
foreign_key: true,
|
7
|
+
index: {name: "index_endpoints_on_abstract_creative_concept_id"}
|
8
|
+
)
|
9
|
+
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-outgoing_webhooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -67,6 +67,10 @@ files:
|
|
67
67
|
- app/controllers/account/webhooks/outgoing/deliveries_controller.rb
|
68
68
|
- app/controllers/account/webhooks/outgoing/delivery_attempts_controller.rb
|
69
69
|
- app/controllers/account/webhooks/outgoing/endpoints_controller.rb
|
70
|
+
- app/controllers/api/v1.rb
|
71
|
+
- app/controllers/api/v1/webhooks.rb
|
72
|
+
- app/controllers/api/v1/webhooks/outgoing.rb
|
73
|
+
- app/controllers/api/v1/webhooks/outgoing/endpoints_controller.rb
|
70
74
|
- app/jobs/webhooks/outgoing/delivery_job.rb
|
71
75
|
- app/jobs/webhooks/outgoing/generate_job.rb
|
72
76
|
- app/models/concerns/webhooks/outgoing/delivery_attempt_support.rb
|
@@ -118,6 +122,10 @@ files:
|
|
118
122
|
- app/views/account/webhooks/outgoing/endpoints/new.html.erb
|
119
123
|
- app/views/account/webhooks/outgoing/endpoints/show.html.erb
|
120
124
|
- app/views/account/webhooks/outgoing/endpoints/show.json.jbuilder
|
125
|
+
- app/views/api/v1/open_api/index.yaml.erb
|
126
|
+
- app/views/api/v1/webhooks/outgoing/endpoints/_endpoint.json.jbuilder
|
127
|
+
- app/views/api/v1/webhooks/outgoing/endpoints/index.json.jbuilder
|
128
|
+
- app/views/api/v1/webhooks/outgoing/endpoints/show.json.jbuilder
|
121
129
|
- config/locales/en/webhooks/outgoing/deliveries.en.yml
|
122
130
|
- config/locales/en/webhooks/outgoing/delivery_attempts.en.yml
|
123
131
|
- config/locales/en/webhooks/outgoing/endpoints.en.yml
|
@@ -144,6 +152,7 @@ files:
|
|
144
152
|
- db/migrate/20211127014001_migrate_event_types_on_webhooks_outgoing_events.rb
|
145
153
|
- db/migrate/20211127015712_drop_webhooks_outgoing_endpoint_event_types.rb
|
146
154
|
- db/migrate/20211127015713_drop_webhooks_outgoing_event_types.rb
|
155
|
+
- db/migrate/20221130063357_add_creative_concept_to_endpoints.rb
|
147
156
|
- lib/bullet_train/outgoing_webhooks.rb
|
148
157
|
- lib/bullet_train/outgoing_webhooks/engine.rb
|
149
158
|
- lib/bullet_train/outgoing_webhooks/version.rb
|