Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 386d654

Browse files
authored
fix: add missing pin status values (#16)
Missing values encountered during testing. Also removed the hard failure condition when parsing an unknown pin status since this prevents returning usable responses from successful requests.
1 parent 924194b commit 386d654

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

status.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const (
2121
PinStatusPinned = PinStatus(api.TrackerStatusPinned)
2222
PinStatusPinning = PinStatus(api.TrackerStatusPinning)
2323
PinStatusPinQueued = PinStatus(api.TrackerStatusPinQueued)
24+
PinStatusRemote = PinStatus(api.TrackerStatusRemote)
25+
PinStatusUnpinned = PinStatus(api.TrackerStatusUnpinned)
26+
PinStatusUnknown = PinStatus(-1)
2427
)
2528

2629
func (s PinStatus) String() string {
@@ -33,6 +36,12 @@ func (s PinStatus) String() string {
3336
if s == PinStatusPinQueued {
3437
return "PinQueued"
3538
}
39+
if s == PinStatusRemote {
40+
return "Remote"
41+
}
42+
if s == PinStatusUnpinned {
43+
return "Unpinned"
44+
}
3645
return "Unknown"
3746
}
3847

@@ -70,8 +79,12 @@ func (p *Pin) UnmarshalJSON(b []byte) error {
7079
p.Status = PinStatusPinning
7180
} else if raw.Status == "PinQueued" {
7281
p.Status = PinStatusPinQueued
82+
} else if raw.Status == "Remote" {
83+
p.Status = PinStatusRemote
84+
} else if raw.Status == "Unpinned" {
85+
p.Status = PinStatusUnpinned
7386
} else {
74-
return fmt.Errorf("unknown pin status: %s", raw.Status)
87+
p.Status = PinStatusUnknown
7588
}
7689
return nil
7790
}

0 commit comments

Comments
 (0)