Fix type of lte_ext_ant/lte_poe fields (#89)
This commit is contained in:
@@ -339,6 +339,8 @@ func main() {
|
|||||||
if f.FieldType == "string" {
|
if f.FieldType == "string" {
|
||||||
f.CustomUnmarshalType = "numberOrString"
|
f.CustomUnmarshalType = "numberOrString"
|
||||||
}
|
}
|
||||||
|
case "LteExtAnt", "LtePoe":
|
||||||
|
f.CustomUnmarshalType = "booleanishString"
|
||||||
}
|
}
|
||||||
|
|
||||||
f.OmitEmpty = true
|
f.OmitEmpty = true
|
||||||
|
|||||||
18
unifi/device.generated.go
generated
18
unifi/device.generated.go
generated
@@ -101,13 +101,15 @@ type Device struct {
|
|||||||
func (dst *Device) UnmarshalJSON(b []byte) error {
|
func (dst *Device) UnmarshalJSON(b []byte) error {
|
||||||
type Alias Device
|
type Alias Device
|
||||||
aux := &struct {
|
aux := &struct {
|
||||||
LcmBrightness emptyStringInt `json:"lcm_brightness"`
|
LcmBrightness emptyStringInt `json:"lcm_brightness"`
|
||||||
LcmIDleTimeout emptyStringInt `json:"lcm_idle_timeout"`
|
LcmIDleTimeout emptyStringInt `json:"lcm_idle_timeout"`
|
||||||
LedOverrideColorBrightness emptyStringInt `json:"led_override_color_brightness"`
|
LedOverrideColorBrightness emptyStringInt `json:"led_override_color_brightness"`
|
||||||
LteHardLimit emptyStringInt `json:"lte_hard_limit"`
|
LteExtAnt booleanishString `json:"lte_ext_ant"`
|
||||||
LteSimPin emptyStringInt `json:"lte_sim_pin"`
|
LteHardLimit emptyStringInt `json:"lte_hard_limit"`
|
||||||
LteSoftLimit emptyStringInt `json:"lte_soft_limit"`
|
LtePoe booleanishString `json:"lte_poe"`
|
||||||
Volume emptyStringInt `json:"volume"`
|
LteSimPin emptyStringInt `json:"lte_sim_pin"`
|
||||||
|
LteSoftLimit emptyStringInt `json:"lte_soft_limit"`
|
||||||
|
Volume emptyStringInt `json:"volume"`
|
||||||
|
|
||||||
*Alias
|
*Alias
|
||||||
}{
|
}{
|
||||||
@@ -121,7 +123,9 @@ func (dst *Device) UnmarshalJSON(b []byte) error {
|
|||||||
dst.LcmBrightness = int(aux.LcmBrightness)
|
dst.LcmBrightness = int(aux.LcmBrightness)
|
||||||
dst.LcmIDleTimeout = int(aux.LcmIDleTimeout)
|
dst.LcmIDleTimeout = int(aux.LcmIDleTimeout)
|
||||||
dst.LedOverrideColorBrightness = int(aux.LedOverrideColorBrightness)
|
dst.LedOverrideColorBrightness = int(aux.LedOverrideColorBrightness)
|
||||||
|
dst.LteExtAnt = bool(aux.LteExtAnt)
|
||||||
dst.LteHardLimit = int(aux.LteHardLimit)
|
dst.LteHardLimit = int(aux.LteHardLimit)
|
||||||
|
dst.LtePoe = bool(aux.LtePoe)
|
||||||
dst.LteSimPin = int(aux.LteSimPin)
|
dst.LteSimPin = int(aux.LteSimPin)
|
||||||
dst.LteSoftLimit = int(aux.LteSoftLimit)
|
dst.LteSoftLimit = int(aux.LteSoftLimit)
|
||||||
dst.Volume = int(aux.Volume)
|
dst.Volume = int(aux.Volume)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package unifi
|
package unifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -66,3 +67,24 @@ func (e *emptyStringInt) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
return []byte(strconv.Itoa(int(*e))), nil
|
return []byte(strconv.Itoa(int(*e))), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type booleanishString bool
|
||||||
|
|
||||||
|
func (e *booleanishString) UnmarshalJSON(b []byte) error {
|
||||||
|
s := string(b)
|
||||||
|
if s == `"enabled"` {
|
||||||
|
*e = booleanishString(true)
|
||||||
|
return nil
|
||||||
|
} else if s == `"disabled"` {
|
||||||
|
*e = booleanishString(false)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("Could not unmarshal JSON value.")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *booleanishString) MarshalJSON(b []byte) ([]byte, error) {
|
||||||
|
if *e == true {
|
||||||
|
return []byte(`"enabled"`), nil
|
||||||
|
}
|
||||||
|
return []byte(`"disabled"`), nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user