bullet_train-outgoing_webhooks 1.0.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/issuing_model.rb +3 -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/engine.rb +0 -8
- data/lib/bullet_train/outgoing_webhooks/version.rb +1 -1
- metadata +11 -8
- data/app/controllers/api/v1/webhooks/outgoing/deliveries_endpoint.rb +0 -63
- data/app/controllers/api/v1/webhooks/outgoing/delivery_attempts_endpoint.rb +0 -65
- data/app/controllers/api/v1/webhooks/outgoing/endpoints_endpoint.rb +0 -119
- data/app/serializers/api/v1/webhooks/outgoing/delivery_attempt_serializer.rb +0 -16
- data/app/serializers/api/v1/webhooks/outgoing/delivery_serializer.rb +0 -14
- data/app/serializers/api/v1/webhooks/outgoing/endpoint_serializer.rb +0 -14
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
|
@@ -45,7 +45,9 @@ module Webhooks::Outgoing::IssuingModel
|
|
45
45
|
|
46
46
|
def generate_webhook_perform(action)
|
47
47
|
event_type = Webhooks::Outgoing::EventType.find_by(id: "#{self.class.name.underscore}.#{action}")
|
48
|
-
|
48
|
+
# TODO This is crazy that we generate JSON just to parse it. Can't be good for performance.
|
49
|
+
# Does Jbuilder support generating a hash instead of a JSON string?
|
50
|
+
data = JSON.parse(to_api_json)
|
49
51
|
webhook = send(BulletTrain::OutgoingWebhooks.parent_association).webhooks_outgoing_events.create(event_type_id: event_type.id, subject: self, data: data)
|
50
52
|
webhook.deliver
|
51
53
|
end
|
@@ -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
|
@@ -25,14 +25,6 @@ module BulletTrain
|
|
25
25
|
audit_callback: ->(obj, uri) { Rails.logger.error("BlockedURI obj=#{obj.persisted? ? obj.to_global_id : "New #{obj.class}"} uri=#{uri}") }
|
26
26
|
}
|
27
27
|
end
|
28
|
-
|
29
|
-
initializer "bullet_train.outgoing_webhooks.register_api_endpoints" do |app|
|
30
|
-
if Object.const_defined?("BulletTrain::Api")
|
31
|
-
BulletTrain::Api.endpoints << "Api::V1::Webhooks::Outgoing::EndpointsEndpoint"
|
32
|
-
BulletTrain::Api.endpoints << "Api::V1::Webhooks::Outgoing::DeliveriesEndpoint"
|
33
|
-
BulletTrain::Api.endpoints << "Api::V1::Webhooks::Outgoing::DeliveryAttemptsEndpoint"
|
34
|
-
end
|
35
|
-
end
|
36
28
|
end
|
37
29
|
end
|
38
30
|
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.0
|
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,9 +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
|
71
|
-
- app/controllers/api/v1/webhooks
|
72
|
-
- app/controllers/api/v1/webhooks/outgoing
|
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
|
73
74
|
- app/jobs/webhooks/outgoing/delivery_job.rb
|
74
75
|
- app/jobs/webhooks/outgoing/generate_job.rb
|
75
76
|
- app/models/concerns/webhooks/outgoing/delivery_attempt_support.rb
|
@@ -86,9 +87,6 @@ files:
|
|
86
87
|
- app/models/webhooks/outgoing/endpoint.rb
|
87
88
|
- app/models/webhooks/outgoing/event.rb
|
88
89
|
- app/models/webhooks/outgoing/event_type.rb
|
89
|
-
- app/serializers/api/v1/webhooks/outgoing/delivery_attempt_serializer.rb
|
90
|
-
- app/serializers/api/v1/webhooks/outgoing/delivery_serializer.rb
|
91
|
-
- app/serializers/api/v1/webhooks/outgoing/endpoint_serializer.rb
|
92
90
|
- app/views/account/webhooks/outgoing/deliveries/_breadcrumbs.html.erb
|
93
91
|
- app/views/account/webhooks/outgoing/deliveries/_delivery.json.jbuilder
|
94
92
|
- app/views/account/webhooks/outgoing/deliveries/_form.html.erb
|
@@ -124,6 +122,10 @@ files:
|
|
124
122
|
- app/views/account/webhooks/outgoing/endpoints/new.html.erb
|
125
123
|
- app/views/account/webhooks/outgoing/endpoints/show.html.erb
|
126
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
|
127
129
|
- config/locales/en/webhooks/outgoing/deliveries.en.yml
|
128
130
|
- config/locales/en/webhooks/outgoing/delivery_attempts.en.yml
|
129
131
|
- config/locales/en/webhooks/outgoing/endpoints.en.yml
|
@@ -150,6 +152,7 @@ files:
|
|
150
152
|
- db/migrate/20211127014001_migrate_event_types_on_webhooks_outgoing_events.rb
|
151
153
|
- db/migrate/20211127015712_drop_webhooks_outgoing_endpoint_event_types.rb
|
152
154
|
- db/migrate/20211127015713_drop_webhooks_outgoing_event_types.rb
|
155
|
+
- db/migrate/20221130063357_add_creative_concept_to_endpoints.rb
|
153
156
|
- lib/bullet_train/outgoing_webhooks.rb
|
154
157
|
- lib/bullet_train/outgoing_webhooks/engine.rb
|
155
158
|
- lib/bullet_train/outgoing_webhooks/version.rb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
class Api::V1::Webhooks::Outgoing::DeliveriesEndpoint < Api::V1::Root
|
2
|
-
helpers do
|
3
|
-
params :endpoint_id do
|
4
|
-
requires :endpoint_id, type: Integer, allow_blank: false, desc: "Endpoint ID"
|
5
|
-
end
|
6
|
-
|
7
|
-
params :id do
|
8
|
-
requires :id, type: Integer, allow_blank: false, desc: "Delivery ID"
|
9
|
-
end
|
10
|
-
|
11
|
-
params :delivery do
|
12
|
-
optional :event_id, type: String, desc: Api.heading(:event_id)
|
13
|
-
optional :endpoint_url, type: String, desc: Api.heading(:endpoint_url)
|
14
|
-
optional :delivered_at, type: DateTime, desc: Api.heading(:delivered_at)
|
15
|
-
# 🚅 super scaffolding will insert new fields above this line.
|
16
|
-
# 🚅 super scaffolding will insert new arrays above this line.
|
17
|
-
|
18
|
-
# 🚅 super scaffolding will insert processing for new fields above this line.
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
resource "webhooks/outgoing/endpoints", desc: Api.title(:collection_actions) do
|
23
|
-
after_validation do
|
24
|
-
load_and_authorize_api_resource Webhooks::Outgoing::Delivery
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# INDEX
|
29
|
-
#
|
30
|
-
|
31
|
-
desc Api.title(:index), &Api.index_desc
|
32
|
-
params do
|
33
|
-
use :endpoint_id
|
34
|
-
end
|
35
|
-
oauth2
|
36
|
-
paginate per_page: 100
|
37
|
-
get "/:endpoint_id/deliveries" do
|
38
|
-
@paginated_deliveries = paginate @deliveries
|
39
|
-
render @paginated_deliveries, serializer: Api.serializer
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
resource "webhooks/outgoing/deliveries", desc: Api.title(:member_actions) do
|
44
|
-
after_validation do
|
45
|
-
load_and_authorize_api_resource Webhooks::Outgoing::Delivery
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# SHOW
|
50
|
-
#
|
51
|
-
|
52
|
-
desc Api.title(:show), &Api.show_desc
|
53
|
-
params do
|
54
|
-
use :id
|
55
|
-
end
|
56
|
-
oauth2
|
57
|
-
route_param :id do
|
58
|
-
get do
|
59
|
-
render @delivery, serializer: Api.serializer
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
class Api::V1::Webhooks::Outgoing::DeliveryAttemptsEndpoint < Api::V1::Root
|
2
|
-
helpers do
|
3
|
-
params :delivery_id do
|
4
|
-
requires :delivery_id, type: Integer, allow_blank: false, desc: "Delivery ID"
|
5
|
-
end
|
6
|
-
|
7
|
-
params :id do
|
8
|
-
requires :id, type: Integer, allow_blank: false, desc: "Delivery Attempt ID"
|
9
|
-
end
|
10
|
-
|
11
|
-
params :delivery_attempt do
|
12
|
-
optional :response_code, type: String, desc: Api.heading(:response_code)
|
13
|
-
optional :response_body, type: String, desc: Api.heading(:response_body)
|
14
|
-
optional :response_message, type: String, desc: Api.heading(:response_message)
|
15
|
-
optional :error_message, type: String, desc: Api.heading(:error_message)
|
16
|
-
optional :attempt_number, type: String, desc: Api.heading(:attempt_number)
|
17
|
-
# 🚅 super scaffolding will insert new fields above this line.
|
18
|
-
# 🚅 super scaffolding will insert new arrays above this line.
|
19
|
-
|
20
|
-
# 🚅 super scaffolding will insert processing for new fields above this line.
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
resource "webhooks/outgoing/deliveries", desc: Api.title(:collection_actions) do
|
25
|
-
after_validation do
|
26
|
-
load_and_authorize_api_resource Webhooks::Outgoing::DeliveryAttempt
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# INDEX
|
31
|
-
#
|
32
|
-
|
33
|
-
desc Api.title(:index), &Api.index_desc
|
34
|
-
params do
|
35
|
-
use :delivery_id
|
36
|
-
end
|
37
|
-
oauth2
|
38
|
-
paginate per_page: 100
|
39
|
-
get "/:delivery_id/delivery_attempts" do
|
40
|
-
@paginated_delivery_attempts = paginate @delivery_attempts
|
41
|
-
render @paginated_delivery_attempts, serializer: Api.serializer
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
resource "webhooks/outgoing/delivery_attempts", desc: Api.title(:member_actions) do
|
46
|
-
after_validation do
|
47
|
-
load_and_authorize_api_resource Webhooks::Outgoing::DeliveryAttempt
|
48
|
-
end
|
49
|
-
|
50
|
-
#
|
51
|
-
# SHOW
|
52
|
-
#
|
53
|
-
|
54
|
-
desc Api.title(:show), &Api.show_desc
|
55
|
-
params do
|
56
|
-
use :id
|
57
|
-
end
|
58
|
-
oauth2
|
59
|
-
route_param :id do
|
60
|
-
get do
|
61
|
-
render @delivery_attempt, serializer: Api.serializer
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
class Api::V1::Webhooks::Outgoing::EndpointsEndpoint < Api::V1::Root
|
2
|
-
helpers do
|
3
|
-
params BulletTrain::OutgoingWebhooks.parent_association_id do
|
4
|
-
requires BulletTrain::OutgoingWebhooks.parent_association_id, type: Integer, allow_blank: false, desc: "#{BulletTrain::OutgoingWebhooks.parent_class} ID"
|
5
|
-
end
|
6
|
-
|
7
|
-
params :id do
|
8
|
-
requires :id, type: Integer, allow_blank: false, desc: "Endpoint ID"
|
9
|
-
end
|
10
|
-
|
11
|
-
params :endpoint do
|
12
|
-
optional :name, type: String, desc: Api.heading(:name)
|
13
|
-
optional :url, type: String, desc: Api.heading(:url)
|
14
|
-
# 🚅 super scaffolding will insert new fields above this line.
|
15
|
-
optional :event_type_ids, type: Array, desc: Api.heading(:event_type_ids)
|
16
|
-
# 🚅 super scaffolding will insert new arrays above this line.
|
17
|
-
|
18
|
-
# 🚅 super scaffolding will insert processing for new fields above this line.
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
resource BulletTrain::OutgoingWebhooks.parent_resource, desc: Api.title(:collection_actions) do
|
23
|
-
after_validation do
|
24
|
-
load_and_authorize_api_resource Webhooks::Outgoing::Endpoint
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# INDEX
|
29
|
-
#
|
30
|
-
|
31
|
-
desc Api.title(:index), &Api.index_desc
|
32
|
-
params do
|
33
|
-
use BulletTrain::OutgoingWebhooks.parent_association_id
|
34
|
-
end
|
35
|
-
oauth2
|
36
|
-
paginate per_page: 100
|
37
|
-
get "/:#{BulletTrain::OutgoingWebhooks.parent_association_id}/webhooks/outgoing/endpoints" do
|
38
|
-
@paginated_endpoints = paginate @endpoints
|
39
|
-
render @paginated_endpoints, serializer: Api.serializer
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
# CREATE
|
44
|
-
#
|
45
|
-
|
46
|
-
desc Api.title(:create), &Api.create_desc
|
47
|
-
params do
|
48
|
-
use BulletTrain::OutgoingWebhooks.parent_association_id
|
49
|
-
use :endpoint
|
50
|
-
end
|
51
|
-
route_setting :api_resource_options, permission: :create
|
52
|
-
oauth2 "write"
|
53
|
-
post "/:#{BulletTrain::OutgoingWebhooks.parent_association_id}/webhooks/outgoing/endpoints" do
|
54
|
-
if @endpoint.save
|
55
|
-
render @endpoint, serializer: Api.serializer
|
56
|
-
else
|
57
|
-
record_not_saved @endpoint
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
resource "webhooks/outgoing/endpoints", desc: Api.title(:member_actions) do
|
63
|
-
after_validation do
|
64
|
-
load_and_authorize_api_resource Webhooks::Outgoing::Endpoint
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# SHOW
|
69
|
-
#
|
70
|
-
|
71
|
-
desc Api.title(:show), &Api.show_desc
|
72
|
-
params do
|
73
|
-
use :id
|
74
|
-
end
|
75
|
-
oauth2
|
76
|
-
route_param :id do
|
77
|
-
get do
|
78
|
-
render @endpoint, serializer: Api.serializer
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# UPDATE
|
84
|
-
#
|
85
|
-
|
86
|
-
desc Api.title(:update), &Api.update_desc
|
87
|
-
params do
|
88
|
-
use :id
|
89
|
-
use :endpoint
|
90
|
-
end
|
91
|
-
route_setting :api_resource_options, permission: :update
|
92
|
-
oauth2 "write"
|
93
|
-
route_param :id do
|
94
|
-
put do
|
95
|
-
if @endpoint.update(declared(params, include_missing: false))
|
96
|
-
render @endpoint, serializer: Api.serializer
|
97
|
-
else
|
98
|
-
record_not_saved @endpoint
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
#
|
104
|
-
# DESTROY
|
105
|
-
#
|
106
|
-
|
107
|
-
desc Api.title(:destroy), &Api.destroy_desc
|
108
|
-
params do
|
109
|
-
use :id
|
110
|
-
end
|
111
|
-
route_setting :api_resource_options, permission: :destroy
|
112
|
-
oauth2 "delete"
|
113
|
-
route_param :id do
|
114
|
-
delete do
|
115
|
-
render @endpoint.destroy, serializer: Api.serializer
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Api::V1::Webhooks::Outgoing::DeliveryAttemptSerializer < Api::V1::ApplicationSerializer
|
2
|
-
set_type "webhooks/outgoing/delivery_attempt"
|
3
|
-
|
4
|
-
attributes :id,
|
5
|
-
:delivery_id,
|
6
|
-
:response_code,
|
7
|
-
:response_body,
|
8
|
-
:response_message,
|
9
|
-
:error_message,
|
10
|
-
:attempt_number,
|
11
|
-
# 🚅 super scaffolding will insert new fields above this line.
|
12
|
-
:created_at,
|
13
|
-
:updated_at
|
14
|
-
|
15
|
-
belongs_to :delivery, serializer: Api::V1::Webhooks::Outgoing::DeliverySerializer
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Api::V1::Webhooks::Outgoing::DeliverySerializer < Api::V1::ApplicationSerializer
|
2
|
-
set_type "webhooks/outgoing/delivery"
|
3
|
-
|
4
|
-
attributes :id,
|
5
|
-
:endpoint_id,
|
6
|
-
:event_id,
|
7
|
-
:endpoint_url,
|
8
|
-
:delivered_at,
|
9
|
-
# 🚅 super scaffolding will insert new fields above this line.
|
10
|
-
:created_at,
|
11
|
-
:updated_at
|
12
|
-
|
13
|
-
belongs_to :endpoint, serializer: Api::V1::Webhooks::Outgoing::EndpointSerializer
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Api::V1::Webhooks::Outgoing::EndpointSerializer < Api::V1::ApplicationSerializer
|
2
|
-
set_type "webhooks/outgoing/endpoint"
|
3
|
-
|
4
|
-
attributes :id,
|
5
|
-
:team_id,
|
6
|
-
:name,
|
7
|
-
:url,
|
8
|
-
:event_type_ids,
|
9
|
-
# 🚅 super scaffolding will insert new fields above this line.
|
10
|
-
:created_at,
|
11
|
-
:updated_at
|
12
|
-
|
13
|
-
belongs_to :team, serializer: Api::V1::TeamSerializer
|
14
|
-
end
|