|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of CaptainHook arrrrr. |
|
5
|
|
|
* |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
return [ |
|
10
|
|
|
|
|
11
|
|
|
/* |
|
12
|
|
|
|-------------------------------------------------------------------------- |
|
13
|
|
|
| Event listeners |
|
14
|
|
|
|-------------------------------------------------------------------------- |
|
15
|
|
|
| |
|
16
|
|
|
| This array allows you to define all events that Captain Hook should |
|
17
|
|
|
| listen for in the application. By default, the Captain will just |
|
18
|
|
|
| respond to eloquent events, but you may edit this as you like. |
|
19
|
|
|
*/ |
|
20
|
|
|
'listeners' => [ |
|
21
|
|
|
'Eloquent' => 'eloquent.*', |
|
22
|
|
|
], |
|
23
|
|
|
|
|
24
|
|
|
/* |
|
25
|
|
|
|-------------------------------------------------------------------------- |
|
26
|
|
|
| Webhook filter closure |
|
27
|
|
|
|-------------------------------------------------------------------------- |
|
28
|
|
|
| |
|
29
|
|
|
| If your webhooks are scoped to a tenant_id, you can modify |
|
30
|
|
|
| this filter function to return only the webhooks for your |
|
31
|
|
|
| tenant. This function is applied as a collection filter. |
|
32
|
|
|
| The tenant_id field can be used for verification. |
|
33
|
|
|
| |
|
34
|
|
|
*/ |
|
35
|
|
|
'filter' => function ($webhook) { |
|
|
|
|
|
|
36
|
|
|
return true; |
|
37
|
|
|
}, |
|
38
|
|
|
|
|
39
|
|
|
/* |
|
40
|
|
|
|-------------------------------------------------------------------------- |
|
41
|
|
|
| Webhook data transformer |
|
42
|
|
|
|-------------------------------------------------------------------------- |
|
43
|
|
|
| |
|
44
|
|
|
| The data transformer is a simple function that allows you to take the |
|
45
|
|
|
| subject data of an event and convert it to a format that will then |
|
46
|
|
|
| be posted to the webhooks. By default, all data is json encoded. |
|
47
|
|
|
| The second argument is the Webhook that was triggered in case |
|
48
|
|
|
| you want to transform the data in different ways per hook. |
|
49
|
|
|
| |
|
50
|
|
|
| You can also use the 'Foo\Class@transform' notation if you want. |
|
51
|
|
|
| |
|
52
|
|
|
*/ |
|
53
|
|
|
'transformer' => function ($eventData, $webhook) { |
|
|
|
|
|
|
54
|
|
|
return json_encode($eventData); |
|
55
|
|
|
}, |
|
56
|
|
|
|
|
57
|
|
|
/* |
|
58
|
|
|
|-------------------------------------------------------------------------- |
|
59
|
|
|
| Webhook response callback |
|
60
|
|
|
|-------------------------------------------------------------------------- |
|
61
|
|
|
| |
|
62
|
|
|
| The response callback can be used if you want to trigger |
|
63
|
|
|
| certain actions depending on the webhook response. |
|
64
|
|
|
| This is unused by default. |
|
65
|
|
|
| |
|
66
|
|
|
| You can also use the 'Foo\Class@handle' notation if you want. |
|
67
|
|
|
| |
|
68
|
|
|
*/ |
|
69
|
|
|
'response_callback' => function ($webhook, $response) { |
|
|
|
|
|
|
70
|
|
|
// Handle custom response status codes, ... |
|
71
|
|
|
}, |
|
72
|
|
|
|
|
73
|
|
|
/* |
|
74
|
|
|
|-------------------------------------------------------------------------- |
|
75
|
|
|
| Logging configuration |
|
76
|
|
|
|-------------------------------------------------------------------------- |
|
77
|
|
|
| |
|
78
|
|
|
| Captain Hook ships with built-in logging to allow you to store data |
|
79
|
|
|
| about the requests that you have made in a certain time interval. |
|
80
|
|
|
*/ |
|
81
|
|
|
'log' => [ |
|
82
|
|
|
'active' => true, |
|
83
|
|
|
'storage_quantity' => 50, |
|
84
|
|
|
'max_attempts' => 5, |
|
85
|
|
|
], |
|
86
|
|
|
|
|
87
|
|
|
/* |
|
88
|
|
|
|-------------------------------------------------------------------------- |
|
89
|
|
|
| Tenant configuration (Spark specific configuration) |
|
90
|
|
|
|-------------------------------------------------------------------------- |
|
91
|
|
|
| |
|
92
|
|
|
| The tenant model option allows you to associate the tenant_id |
|
93
|
|
|
| to the Spark Team instead of the User like by default. |
|
94
|
|
|
| |
|
95
|
|
|
| Possible options are: 'User' or 'Team' |
|
96
|
|
|
| |
|
97
|
|
|
| If you use 'User' you should add the following to the 'filter' function: |
|
98
|
|
|
| return $webhook->tenant_id == auth()->user()->getKey(); |
|
99
|
|
|
| |
|
100
|
|
|
| If you use 'Team' you should add the following to the 'filter' function: |
|
101
|
|
|
| return $webhook->tenant_id == auth()->user()->currentTeam->id; |
|
102
|
|
|
*/ |
|
103
|
|
|
'tenant_spark_model' => 'Team', |
|
104
|
|
|
|
|
105
|
|
|
/* |
|
106
|
|
|
|-------------------------------------------------------------------------- |
|
107
|
|
|
| API configuration (Spark specific configuration) |
|
108
|
|
|
|-------------------------------------------------------------------------- |
|
109
|
|
|
| |
|
110
|
|
|
| By enabling this option some extra routes will be added under |
|
111
|
|
|
| the /api prefix and with the 'auth:api' middleware, to allow users and |
|
112
|
|
|
| services like Zapier to create, update and delete Webhooks without user |
|
113
|
|
|
| interaction. |
|
114
|
|
|
| See more at http://resthooks.org/ |
|
115
|
|
|
| |
|
116
|
|
|
*/ |
|
117
|
|
|
'uses_api' => true, |
|
118
|
|
|
]; |
|
119
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.