ducky/subscriptions
ducky/subscriptions/subscription.go
Add comments, move ChangingSystemProperties to the api package. Add comments to all our exported types and variables in subscription.go, both to make golint happy and because it's good to have comments. Move the subscriptions.ChangingSystemProperties helper to api.changingSystemProperties, because it returns API-specific strings and there's no real reason it has to be in the subscriptions package--everything it needs to work on is exported.
1.1 --- a/subscription.go Sat Jul 18 03:28:51 2015 -0400 1.2 +++ b/subscription.go Sun Sep 27 21:18:45 2015 -0700 1.3 @@ -35,6 +35,8 @@ 1.4 PendingPlan: true, 1.5 } 1.6 1.7 + // Version tracks the build ID of the binary, set using 1.8 + // ldflags. 1.9 Version string 1.10 ) 1.11 1.12 @@ -172,41 +174,12 @@ 1.13 } 1.14 } 1.15 1.16 -func ChangingSystemProperties(change SubscriptionChange) []string { 1.17 - var changes []string 1.18 - if change.StripeSubscription != nil { 1.19 - changes = append(changes, "/stripe_subscription") 1.20 - } 1.21 - if change.Status != nil { 1.22 - changes = append(changes, "/status") 1.23 - } 1.24 - if change.TrialStart != nil { 1.25 - changes = append(changes, "/trial_start") 1.26 - } 1.27 - if change.TrialEnd != nil { 1.28 - changes = append(changes, "/trial_end") 1.29 - } 1.30 - if change.PeriodStart != nil { 1.31 - changes = append(changes, "/period_start") 1.32 - } 1.33 - if change.PeriodEnd != nil { 1.34 - changes = append(changes, "/period_end") 1.35 - } 1.36 - if change.CanceledAt != nil { 1.37 - changes = append(changes, "/canceled_at") 1.38 - } 1.39 - if change.FailedChargeAttempts != nil { 1.40 - changes = append(changes, "/failed_charge_attempts") 1.41 - } 1.42 - if change.LastFailedCharge != nil { 1.43 - changes = append(changes, "/last_failed_charge") 1.44 - } 1.45 - if change.LastNotified != nil { 1.46 - changes = append(changes, "/last_notified") 1.47 - } 1.48 - return changes 1.49 -} 1.50 - 1.51 +// IsAcceptablePlan returns true if the user can select the specified 1.52 +// plan, taking into account their admin status. If a plan exists, and 1.53 +// is not designated as an admin-only plan, any user selecting it will 1.54 +// return true. If a plan exists, but is designated as admin-only, 1.55 +// IsAcceptablePlan will only return true if admin is true. If the plan 1.56 +// doesn't exist, IsAcceptablePlan always returns false. 1.57 func IsAcceptablePlan(plan string, admin bool) bool { 1.58 for p, adminOnly := range planOptions { 1.59 if plan == p { 1.60 @@ -238,6 +211,8 @@ 1.61 // was omitted." 1.62 } 1.63 1.64 +// SubscriptionStore is an interface describing datastore interactions for 1.65 +// Subscriptions. 1.66 type SubscriptionStore interface { 1.67 Reset() error 1.68 CreateSubscription(sub Subscription) error