bullet_train-outgoing_webhooks 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/webhooks/outgoing/issuing_model.rb +3 -1
- data/lib/bullet_train/outgoing_webhooks/engine.rb +0 -8
- data/lib/bullet_train/outgoing_webhooks/version.rb +1 -1
- metadata +2 -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: 067e22f503dd4bf72b809ba6cd0d0e43d3930a50876a2bc5c846bc186700a3ff
|
4
|
+
data.tar.gz: fbddcd29981bdb80d81c7a66ed0fb15ef36d971ebeaf7eab50b4e8ae9d54fe99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20128e3bb542c2e40d0b93d331a8e0e5bec6cca33ec5b6a2ceaf0e2cbbb8fd155150c40cf82cd89aaedcc1242bce7a8cd5a8c571ff0cc2bd22d0348057b0ff04
|
7
|
+
data.tar.gz: b4ace453d0be7351e0ce89e9fc451a492c3e8fc11f4b5270c57012494caefba063cd7577f875bb5dccde9a46a9a17a4b188c4393e0926d2999978d9d992163ec
|
@@ -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
|
@@ -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.1.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-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -67,9 +67,6 @@ 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/webhooks/outgoing/deliveries_endpoint.rb
|
71
|
-
- app/controllers/api/v1/webhooks/outgoing/delivery_attempts_endpoint.rb
|
72
|
-
- app/controllers/api/v1/webhooks/outgoing/endpoints_endpoint.rb
|
73
70
|
- app/jobs/webhooks/outgoing/delivery_job.rb
|
74
71
|
- app/jobs/webhooks/outgoing/generate_job.rb
|
75
72
|
- app/models/concerns/webhooks/outgoing/delivery_attempt_support.rb
|
@@ -86,9 +83,6 @@ files:
|
|
86
83
|
- app/models/webhooks/outgoing/endpoint.rb
|
87
84
|
- app/models/webhooks/outgoing/event.rb
|
88
85
|
- 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
86
|
- app/views/account/webhooks/outgoing/deliveries/_breadcrumbs.html.erb
|
93
87
|
- app/views/account/webhooks/outgoing/deliveries/_delivery.json.jbuilder
|
94
88
|
- app/views/account/webhooks/outgoing/deliveries/_form.html.erb
|
@@ -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
|