Add Iroquois/Powow API mocking entrypoint

This commit is contained in:
2020-12-22 15:00:42 +01:00
parent d9a6c14041
commit 9b90eaf240
12 changed files with 358 additions and 91 deletions

View File

@ -11,8 +11,9 @@ import (
)
type Config struct {
HTTP HTTPConfig `yaml:"http"`
Data DataConfig `yaml:"data"`
HTTP HTTPConfig `yaml:"http"`
Data DataConfig `yaml:"data"`
Powow PowowConfig `ymal:"powow"`
}
type HTTPConfig struct {
@ -25,6 +26,18 @@ type DataConfig struct {
Path string `yaml:"path" env:"FAKESMS_DATA_PATH"`
}
type PowowConfig struct {
APIKey string `yaml:"apiKey" env:"FAKESMS_POWOW_API_KEY"`
SMS []PowowSMS `yaml:"sms"`
}
type PowowSMS struct {
Name string `yaml:"name"`
From string `yaml:"from"`
Content string `yaml:"content"`
ShortLink bool `yaml:"shortLink"`
}
// NewFromFile retrieves the configuration from the given file
func NewFromFile(filepath string) (*Config, error) {
config := NewDefault()
@ -57,13 +70,27 @@ func NewDumpDefault() *Config {
func NewDefault() *Config {
return &Config{
HTTP: HTTPConfig{
Address: ":8080",
Address: ":3000",
TemplateDir: "template",
PublicDir: "public",
},
Data: DataConfig{
Path: "fakesms.db",
},
Powow: PowowConfig{
APIKey: "powow",
SMS: []PowowSMS{
{
Name: "Powow SMS",
From: "FakeSMS",
ShortLink: false,
Content: `Bonjour %Subscriber:Firstname%,
Lorem ipsum dolor sit amet...
`,
},
},
},
}
}