package config

import (
	"os"

	"gopkg.in/yaml.v3"
)

var C Config

func Load(path string) error {
	data, err := os.ReadFile(path)
	if err != nil {
		return err
	}
	return yaml.Unmarshal(data, &C)
}

type Config struct {
	Pager PagerConfig `yaml:"pager"`
}

type PagerConfig struct {
	Ali    AliConfig    `yaml:"ali"`
	Twilio TwilioConfig `yaml:"twilio"`
}

type AliConfig struct {
	AccessKeyID    string   `yaml:"accessKeyId"`
	TtsCode        string   `yaml:"ttsCode"`
	CalloutNumbers []string `yaml:"calloutNumbers"`
}

type TwilioConfig struct {
	AccountSID     string              `yaml:"accountSid"`
	CalloutNumbers []TwilioCallerEntry `yaml:"calloutNumbers"`
}

type TwilioCallerEntry struct {
	Prefix string `yaml:"prefix"`
	Number string `yaml:"number"`
}
