ducky/subscriptions

Paddy 2015-10-04 Parent:8eb19bcbf17d

17:7eef47ecc01c Go to Latest

ducky/subscriptions/client/client.go

Document our client to make golint happy. Take care of all the documentation warnings in the client subpackage, which means golint now returns successfully.

History
     1.1 --- a/client/client.go	Sun Oct 04 21:58:07 2015 -0700
     1.2 +++ b/client/client.go	Sun Oct 04 22:27:54 2015 -0700
     1.3 @@ -17,16 +17,24 @@
     1.4  )
     1.5  
     1.6  var (
     1.7 -	ErrNilClient     = errors.New("nil client wrapper")
     1.8 +	// ErrNilClient is returned when a method is called on a nil Client.
     1.9 +	ErrNilClient = errors.New("nil client wrapper")
    1.10 +	// ErrNilHTTPClient is returned when a method is called on a Client
    1.11 +	// with its http.Client not set.
    1.12  	ErrNilHTTPClient = errors.New("nil client")
    1.13  )
    1.14  
    1.15 +// Client is a wrapper that bundles all the information necessary to interact
    1.16 +// with the subscriptions API.
    1.17  type Client struct {
    1.18  	client  *http.Client
    1.19  	address string
    1.20  	ID      uuid.ID
    1.21  }
    1.22  
    1.23 +// New returns a new Client. The passed address is the base address for the
    1.24 +// subscriptions API, as an absolute or relative URL. The passed ID is the
    1.25 +// OAuth2 client ID to use for the Client.
    1.26  func New(address string, id uuid.ID) *Client {
    1.27  	address = strings.TrimRight(address, "/")
    1.28  	return &Client{
    1.29 @@ -100,14 +108,32 @@
    1.30  	return fmt.Sprintf("%+#v", h)
    1.31  }
    1.32  
    1.33 +// Get returns the api Response object for the passed URL called
    1.34 +// over HTTP GET. The passed scope IDs will be applied to the request,
    1.35 +// and the request will be made on behalf of the subject (user)
    1.36 +// specified by the passed ID. If the zero value is passed for the ID,
    1.37 +// the request will be made without a subject. To request no scopes,
    1.38 +// pass an empty slice or nil.
    1.39  func (c *Client) Get(url string, scopes []string, subject uuid.ID) (api.Response, error) {
    1.40  	return c.do("GET", url, nil, scopes, subject)
    1.41  }
    1.42  
    1.43 +// Post returns the api Response object for the passed URL called
    1.44 +// over HTTP POST. The passed scope IDs will be applied to the request,
    1.45 +// and the request will be made on behalf of the subject (user)
    1.46 +// specified by the passed ID. If the zero value is passed for the ID,
    1.47 +// the request will be made without a subject. To request no scopes,
    1.48 +// pass an empty slice or nil.
    1.49  func (c *Client) Post(url string, request interface{}, scopes []string, subject uuid.ID) (api.Response, error) {
    1.50  	return c.do("POST", url, request, scopes, subject)
    1.51  }
    1.52  
    1.53 +// Patch returns the api Response object for the passed URL called
    1.54 +// over HTTP PATCH. The passed scope IDs will be applied to the request,
    1.55 +// and the request will be made on behalf of the subject (user)
    1.56 +// specified by the passed ID. If the zero value is passed for the ID,
    1.57 +// the request will be made without a subject. To request no scopes,
    1.58 +// pass an empty slice or nil.
    1.59  func (c *Client) Patch(url string, request interface{}, scopes []string, subject uuid.ID) (api.Response, error) {
    1.60  	return c.do("PATCH", url, request, scopes, subject)
    1.61  }