auth
13:ceba439a0766 Browse Files
Tie client functions to storage functions. Call through to storage functions from client helper functions. For most of them, we're just aliasing a storage call, which calls into question the usefulness of this pattern.
1.1 --- a/client.go Wed Aug 13 08:38:18 2014 -0400 1.2 +++ b/client.go Wed Aug 13 08:39:07 2014 -0400 1.3 @@ -15,26 +15,37 @@ 1.4 } 1.5 1.6 func GetClient(id uuid.ID, ctx Context) (Client, error) { 1.7 - // TODO: pull client from ctx 1.8 - return Client{}, nil 1.9 + return ctx.Clients.GetClient(id) 1.10 } 1.11 1.12 func createClient(name, logo, redirectURI string, owner uuid.ID, ctx Context) (Client, error) { 1.13 - // TODO: store client in ctx 1.14 - return Client{}, nil 1.15 + return ctx.Clients.CreateClient(name, logo, redirectURI, owner) 1.16 } 1.17 1.18 func updateClient(client *Client, name, logo, redirectURI *string, ctx Context) error { 1.19 - // TODO: update client in ctx 1.20 + if client == nil { 1.21 + // TODO: return error 1.22 + } 1.23 + err = ctx.Clients.UpdateClient(client.ID, name, logo, redirectURI) 1.24 + if err != nil { 1.25 + return err 1.26 + } 1.27 + if name != nil { 1.28 + client.Name = *name 1.29 + } 1.30 + if logo != nil { 1.31 + client.Logo = *logo 1.32 + } 1.33 + if redirectURI != nil { 1.34 + client.RedirectURI = *redirectURI 1.35 + } 1.36 return nil 1.37 } 1.38 1.39 func removeClient(id uuid.ID, ctx Context) error { 1.40 - // TODO: delete client from ctx 1.41 - return nil 1.42 + return ctx.Clients.RemoveClient(id) 1.43 } 1.44 1.45 func listClients(id uuid.ID, page, num int, ctx Context) ([]Client, error) { 1.46 - // TODO: retrieve list of clients from ctx 1.47 - return []Client{}, nil 1.48 + return ctx.Clients.ListClients(id, page, num) 1.49 }