/
integration_models.go
56 lines (48 loc) · 1.74 KB
/
integration_models.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
45
46
47
48
49
50
51
52
53
54
55
56
//nolint:tagliatelle
package models
import (
"encoding/json"
"fmt"
)
type PowertrainType string
const (
ICE PowertrainType = "ICE"
HEV PowertrainType = "HEV"
PHEV PowertrainType = "PHEV"
BEV PowertrainType = "BEV"
FCEV PowertrainType = "FCEV"
)
func (p PowertrainType) String() string {
return string(p)
}
func (p *PowertrainType) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
// Potentially an invalid value.
switch bv := PowertrainType(s); bv {
case ICE, HEV, PHEV, BEV, FCEV:
*p = bv
return nil
default:
return fmt.Errorf("unrecognized value: %s", s)
}
}
// IntegrationsMetadata represents json stored in integrations table metadata jsonb column
type IntegrationsMetadata struct {
AutoPiDefaultTemplateID int `json:"autoPiDefaultTemplateId"`
AutoPiPowertrainToTemplateID map[PowertrainType]int `json:"autoPiPowertrainToTemplateId,omitempty"`
}
type GetIntegrationQueryResult struct {
ID string `json:"id"`
Type string `json:"type"`
Style string `json:"style"`
Vendor string `json:"vendor"`
AutoPiDefaultTemplateID int `json:"auto_pi_default_template_id"`
RefreshLimitSecs int `json:"refresh_limit_secs"`
AutoPiPowertrainToTemplateID map[PowertrainType]int `json:"auto_pi_power_train_to_template_id,omitempty"`
TokenID int `json:"token_id"`
Points int `json:"points"`
ManufacturerTokenID int `json:"manufacturer_token_id"`
}