@@ -35,6 +35,7 @@ type Configuration struct {
3535 Endpoint string `yaml:"endpoint"`
3636 User string `yaml:"user"`
3737 Password string `yaml:"password"`
38+ Bearer string `yaml:"bearer"`
3839 DefaultInverterSN string `yaml:"default_inverter_sn,omitempty"`
3940 DefaultPlantID int `yaml:"default_plant_id,omitempty"`
4041}
@@ -89,22 +90,22 @@ func ReadConfigurationFromFile(fileName string) (*Configuration, error) {
8990 return configuration , err
9091}
9192
92- // New constructs a configuration object with a specified username/password
93+ // New constructs a configuration object with a specified username/bearer token
9394// combination using the default region 1 (London) endpoint
94- func New (user string , password string ) (* Configuration , error ) {
95+ func New (user string , bearerToken string ) (* Configuration , error ) {
9596 if user == "" {
9697 return nil , errors .New ("'user' cannot be empty" )
9798 }
98- if password == "" {
99+ if bearerToken == "" {
99100 return nil , errors .New ("'password' cannot be empty" )
100101 }
101- return & Configuration {User : user , Password : password , Endpoint : DefaultEndpoint }, nil
102+ return & Configuration {User : user , Bearer : bearerToken , Endpoint : DefaultEndpoint }, nil
102103}
103104
104- // NewWithEndpoint constructs a configuration object with username/password credentials and an
105+ // NewWithEndpoint constructs a configuration object with username/bearer token credentials and an
105106// overridden API endpoint
106- func NewWithEndpoint (user string , password string , endpoint string ) (* Configuration , error ) {
107- config , err := New (user , password )
107+ func NewWithEndpoint (user string , bearerToken string , endpoint string ) (* Configuration , error ) {
108+ config , err := New (user , bearerToken )
108109 if err != nil {
109110 return nil , err
110111 }
0 commit comments