aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-12 15:59:51 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-12 15:59:51 +0100
commit79caada10f801c4ef5c4a5554360cb15e566178c (patch)
tree216b3a8f90ac1b4b2001baf75adadd110238ef4e /client.go
parent6ccca7c4e8a6efa649a6b7d96463d30498406bdf (diff)
Split again
Diffstat (limited to 'client.go')
-rw-r--r--client.go20
1 files changed, 12 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
}