diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/backend_api.md | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/docs/backend_api.md b/docs/backend_api.md index dc3bfaa..dd7d760 100644 --- a/docs/backend_api.md +++ b/docs/backend_api.md | |||
@@ -3,20 +3,25 @@ | |||
3 | Provides a set of helper functions to integrate the recipe into [Ferdi](https://getferdi.com). | 3 | Provides a set of helper functions to integrate the recipe into [Ferdi](https://getferdi.com). |
4 | 4 | ||
5 | ## Ferdi Backend Class Methods | 5 | ## Ferdi Backend Class Methods |
6 | |||
6 | * [validateUrl](#user-content-validateurl) | 7 | * [validateUrl](#user-content-validateurl) |
7 | * [overrideUserAgent](#user-content-overrideuseragent) | 8 | * [overrideUserAgent](#user-content-overrideuseragent) |
8 | * [modifyRequestHeaders](#user-content-modifyrequestheaders) | 9 | * [modifyRequestHeaders](#user-content-modifyrequestheaders) |
9 | 10 | ||
10 | ## Events | 11 | ## Events |
12 | |||
11 | * [webview events](#user-content-events) | 13 | * [webview events](#user-content-events) |
12 | 14 | ||
13 | ### validateUrl(URL) | 15 | ### validateUrl(URL) |
14 | Validate if the given URL is a valid service instance. | 16 | |
17 | Validate if the given URL is a valid service instance. | ||
15 | 18 | ||
16 | #### Arguments | 19 | #### Arguments |
20 | |||
17 | 1. `string` URL | 21 | 1. `string` URL |
18 | 22 | ||
19 | #### Returns | 23 | #### Returns |
24 | |||
20 | [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) | 25 | [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) |
21 | 26 | ||
22 | #### Usage | 27 | #### Usage |
@@ -45,9 +50,11 @@ module.exports = Ferdi => class RocketChat extends Ferdi { | |||
45 | ``` | 50 | ``` |
46 | 51 | ||
47 | ### overrideUserAgent() | 52 | ### overrideUserAgent() |
48 | Override the user agent used inside the service webview. | 53 | |
54 | Override the user agent used inside the service webview. | ||
49 | 55 | ||
50 | #### Returns | 56 | #### Returns |
57 | |||
51 | `String` | 58 | `String` |
52 | 59 | ||
53 | #### Usage | 60 | #### Usage |
@@ -74,13 +81,16 @@ module.exports = Ferdi => class Example extends Ferdi { | |||
74 | ``` | 81 | ``` |
75 | 82 | ||
76 | ### modifyRequestHeaders() | 83 | ### modifyRequestHeaders() |
84 | |||
77 | Modify headers of HTTP requests sent from a recipe's webview | 85 | Modify headers of HTTP requests sent from a recipe's webview |
78 | Any standard HTTP header can be added to the requests. | 86 | Any standard HTTP header can be added to the requests. |
79 | 87 | ||
80 | #### Returns | 88 | #### Returns |
89 | |||
81 | `Array` containing objects, each of which should have two properties. | 90 | `Array` containing objects, each of which should have two properties. |
82 | - `headers` - Object containing the header params and their values in key-value format | 91 | |
83 | - `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added. | 92 | * `headers` - Object containing the header params and their values in key-value format |
93 | * `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added. | ||
84 | Valid URL patterns can be referred from [here](https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener) | 94 | Valid URL patterns can be referred from [here](https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener) |
85 | 95 | ||
86 | #### Usage | 96 | #### Usage |
@@ -101,11 +111,13 @@ module.exports = Ferdi => class HangoutsChat extends Ferdi { | |||
101 | ``` | 111 | ``` |
102 | 112 | ||
103 | ### Events | 113 | ### Events |
114 | |||
104 | Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. | 115 | Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. |
105 | 116 | ||
106 | This is necessary for services like TweetDeck where custom URL forwarding is needed during login. | 117 | This is necessary for services like TweetDeck where custom URL forwarding is needed during login. |
107 | 118 | ||
108 | #### Usage | 119 | #### Usage |
120 | |||
109 | ```js | 121 | ```js |
110 | module.exports = Ferdi => class Tweetdeck extends Ferdi { | 122 | module.exports = Ferdi => class Tweetdeck extends Ferdi { |
111 | events = { | 123 | events = { |
@@ -114,12 +126,9 @@ module.exports = Ferdi => class Tweetdeck extends Ferdi { | |||
114 | 126 | ||
115 | _redirectFix(event) { | 127 | _redirectFix(event) { |
116 | if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) { | 128 | if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) { |
117 | if (event.isMainFrame) { | 129 | setTimeout(() => this.send('redirect-url', event.newURL), 100); |
118 | setTimeout(() => this.send('redirect-url', event.newURL), 100); | 130 | event.preventDefault(); |
119 | event.preventDefault(); | ||
120 | } | ||
121 | } | 131 | } |
122 | } | 132 | } |
123 | }; | 133 | }; |
124 | ``` | 134 | ``` |
125 | |||