aboutsummaryrefslogtreecommitdiff
path: root/messages.go
diff options
context:
space:
mode:
Diffstat (limited to 'messages.go')
-rw-r--r--messages.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/messages.go b/messages.go
index b5a1738..28d531b 100644
--- a/messages.go
+++ b/messages.go
@@ -1,6 +1,7 @@
package acme
import (
+ "fmt"
"net"
"time"
)
@@ -81,3 +82,30 @@ type Problem struct {
Detail string `json:"detail"`
Instance string `json:"instance"`
}
+
+type Status int
+
+const (
+ StatusUnknown Status = iota
+ StatusPending
+ StatusProcessing
+ StatusValid
+ StatusInvalid
+ StatusRevoked
+)
+
+func (s *Status) UnmarshalJSON(b []byte) error {
+ var status = map[string]Status{
+ "unknown": StatusUnknown,
+ "pending": StatusPending,
+ "processing": StatusProcessing,
+ "valid": StatusValid,
+ "invalid": StatusInvalid,
+ "revoked": StatusRevoked,
+ }
+ if st, ok := status[string(b)]; ok {
+ *s = st
+ return nil
+ }
+ return fmt.Errorf("unknown status %v", string(b))
+}