generated from padok-team/yatas-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotionPluginConfig.go
44 lines (37 loc) · 1.1 KB
/
notionPluginConfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"github.com/stangirard/yatas/plugins/commons"
)
// Notion Config struct
type NotionAccount struct {
Token string `yaml:"token"` // Token of notion connection to use notionapi/v1
AuthToken string `yaml:"authToken,omitempty"` // Token of web application www.notion.so to use notionapi/v3 (optionnal)
PageID string `yaml:"page_id"` // PageID which contains Yatas database
DatabaseID string `yaml:"db_id,omitempty"` // DatabaseID which contains Yatas instances
}
func loadNotionPluginConfig(c *commons.Config) NotionAccount {
var account NotionAccount
for _, r := range c.PluginConfig {
var potentialAccount NotionAccount
isThisPlugin := false
for key, value := range r {
switch key {
case "pluginName":
if value == "notion" {
isThisPlugin = true
}
case "token":
potentialAccount.Token = value.(string)
case "pageID":
potentialAccount.PageID = value.(string)
case "authToken":
potentialAccount.AuthToken = value.(string)
}
}
if isThisPlugin {
account = potentialAccount
break
}
}
return account
}