From 79caada10f801c4ef5c4a5554360cb15e566178c Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 12 Dec 2015 15:59:51 +0100 Subject: Split again --- client.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'client.go') 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 } -- cgit v1.2.3