package main

import (
	"encoding/json"
	"errors"
	"io/ioutil"
	"log"
)

//ConfigIntraAPI config for intra server api
type ConfigIntraAPI struct {
	CRMSecrete string `json:"CRMScrete,omitempty"`
}

//IntraAPIConfig Configuration Data for Intra Server API
var IntraAPIConfig ConfigIntraAPI

func (m *ConfigIntraAPI) readConfig() (err error) {
	path := "intrapi_config.json"
	log.Printf("read Intra API config from %s\r\n", path)
	body, err := ioutil.ReadFile(path)
	if err != nil {
		log.Fatalf("Cannot read config from %s ", path)
		return err
	}
	err = json.Unmarshal(body, &IntraAPIConfig)
	if IntraAPIConfig.CRMSecrete == "" {
		return errors.New("CRM CRMSecrete not available not available")
	}

	return
}
