ducky/subscriptions

Paddy 2015-10-04 Parent:2c8250237566

17:7eef47ecc01c Go to Latest

ducky/subscriptions/client/subscription.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/subscription.go	Sun Oct 04 21:58:07 2015 -0700
     1.2 +++ b/client/subscription.go	Sun Oct 04 22:27:54 2015 -0700
     1.3 @@ -8,6 +8,12 @@
     1.4  	"code.secondbit.org/ducky/subscriptions.hg/api"
     1.5  )
     1.6  
     1.7 +// CreateSubscription creates a Subscription using the passed SubscriptionChange.
     1.8 +// It returns the created Subscription on success. It returns ErrSubscriptionAlreadyExists
     1.9 +// if a subscription already exists for that user. It returns ErrStripeSubscriptionAlreadyExists
    1.10 +// if that Stripe subscription is already associated with a user. It returns an
    1.11 +// ErrSubscriptionNotFound if no Subscription is returned in the response, which generally denotes
    1.12 +// a server error.
    1.13  func (c *Client) CreateSubscription(change subscriptions.SubscriptionChange) (subscriptions.Subscription, error) {
    1.14  	resp, err := c.Post("/subscriptions/", change, auth.Scopes{api.ScopeSubscription, api.ScopeSubscriptionAdmin}.Strings(), change.UserID)
    1.15  	if err != nil {
    1.16 @@ -31,9 +37,13 @@
    1.17  	return resp.Subscriptions[0], nil
    1.18  }
    1.19  
    1.20 +// UpdateSubscription applies the passed SubscriptionChange to the API. It returns
    1.21 +// the update Subscription on success. It returns an ErrSubscriptionNotFound if no
    1.22 +// subscription is returned in the response, which generall denotes a server error.
    1.23  func (c *Client) UpdateSubscription(change subscriptions.SubscriptionChange) (subscriptions.Subscription, error) {
    1.24  	resp, err := c.Patch("/subscriptions/"+change.UserID.String(), change, auth.Scopes{api.ScopeSubscription, api.ScopeSubscriptionAdmin}.Strings(), change.UserID)
    1.25  	if err != nil {
    1.26 +		// BUG(paddy): We need to handle and gracefully return errors raised by the API.
    1.27  		return subscriptions.Subscription{}, err
    1.28  	}
    1.29  	if len(resp.Subscriptions) < 1 {