aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.go20
-rw-r--r--cmd/x/main.go6
2 files changed, 18 insertions, 8 deletions
diff --git a/client.go b/client.go
index aef6ec0..8efa32c 100644
--- a/client.go
+++ b/client.go
@@ -93,9 +93,7 @@ func (c *Client) request(url string, s Signer, rq, re interface{}) error {
c.nonce <- replyNonce(resp)
c.Link = links(resp)
- if resp.StatusCode == http.StatusCreated {
- c.Location = location(resp)
- }
+ c.Location = location(resp)
return json.NewDecoder(resp.Body).Decode(re)
}
@@ -159,16 +157,22 @@ func (c *Client) Register(a *Account) error {
return err
}
log.Println(re)
+ return err
+}
- // Agree to TOS
- rq.Resource = ResRegister
- rq.Agreement = c.Link["terms-of-service"]
- err = c.request(c.Location, a, rq, &re)
+// Agree to TOS
+func (c *Client) Agree(a *Account) error {
+ rq := Registration{
+ Resource: ResRegister,
+ Contact: a.Contact,
+ Agreement: c.Link["terms-of-service"],
+ }
+ re := RegistrationResp{}
+ err := c.request(c.Location, a, rq, &re)
if err != nil {
return err
}
log.Println(re)
-
return err
}
diff --git a/cmd/x/main.go b/cmd/x/main.go
index 28a1b0c..0e6cf71 100644
--- a/cmd/x/main.go
+++ b/cmd/x/main.go
@@ -43,4 +43,10 @@ func main() {
log.Fatal(err)
}
log.Printf("%+v\n", c)
+
+ err = c.Agree(a)
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Printf("%+v\n", c)
}