From d494430002d013a6e08aab40a3445fbfe455d246 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Fri, 9 Aug 2019 11:51:22 -0700 Subject: [PATCH] Remove SubscriptionScheduleRevision --- client/api.go | 4 -- subschedule.go | 1 - subschedulerevision.go | 57 ----------------------- subschedulerevision/client.go | 75 ------------------------------ subschedulerevision/client_test.go | 30 ------------ 5 files changed, 167 deletions(-) delete mode 100644 subschedulerevision.go delete mode 100644 subschedulerevision/client.go delete mode 100644 subschedulerevision/client_test.go diff --git a/client/api.go b/client/api.go index c08fb6fcb6..281931c823 100644 --- a/client/api.go +++ b/client/api.go @@ -65,7 +65,6 @@ import ( "github.com/stripe/stripe-go/sub" "github.com/stripe/stripe-go/subitem" "github.com/stripe/stripe-go/subschedule" - "github.com/stripe/stripe-go/subschedulerevision" "github.com/stripe/stripe-go/taxid" "github.com/stripe/stripe-go/taxrate" terminalconnectiontoken "github.com/stripe/stripe-go/terminal/connectiontoken" @@ -206,8 +205,6 @@ type API struct { SubscriptionItems *subitem.Client // SubscriptionSchedules is the client used to invoke subscription schedules related APIs. SubscriptionSchedules *subschedule.Client - // SubscriptionScheduleRevisions is the client used to invoke subscription schedule revision related APIs. - SubscriptionScheduleRevisions *subschedulerevision.Client // TaxIDs is the client used to invoke /tax_ids APIs. TaxIDs *taxid.Client // TaxRates is the client used to invoke /tax_rates APIs. @@ -307,7 +304,6 @@ func (a *API) Init(key string, backends *stripe.Backends) { a.Subscriptions = &sub.Client{B: backends.API, Key: key} a.SubscriptionItems = &subitem.Client{B: backends.API, Key: key} a.SubscriptionSchedules = &subschedule.Client{B: backends.API, Key: key} - a.SubscriptionScheduleRevisions = &subschedulerevision.Client{B: backends.API, Key: key} a.TaxIDs = &taxid.Client{B: backends.API, Key: key} a.TaxRates = &taxrate.Client{B: backends.API, Key: key} a.TerminalConnectionTokens = &terminalconnectiontoken.Client{B: backends.API, Key: key} diff --git a/subschedule.go b/subschedule.go index 66c727ef48..c1b709a031 100644 --- a/subschedule.go +++ b/subschedule.go @@ -175,7 +175,6 @@ type SubscriptionSchedule struct { Object string `json:"object"` Phases []*SubscriptionSchedulePhase `json:"phases"` ReleasedSubscription *Subscription `json:"released_subscription"` - Revision *SubscriptionScheduleRevision `json:"revision"` RenewalBehavior SubscriptionScheduleRenewalBehavior `json:"renewal_behavior"` RenewalInterval *SubscriptionScheduleRenewalInterval `json:"renewal_interval"` Status SubscriptionScheduleStatus `json:"status"` diff --git a/subschedulerevision.go b/subschedulerevision.go deleted file mode 100644 index 5dbd549dcf..0000000000 --- a/subschedulerevision.go +++ /dev/null @@ -1,57 +0,0 @@ -package stripe - -import ( - "encoding/json" -) - -// SubscriptionScheduleRevisionParams is used when retrieving a schedule revision. -type SubscriptionScheduleRevisionParams struct { - Params `form:"*"` - Schedule *string `form:"-"` // Included in the URL -} - -// SubscriptionScheduleRevisionListParams is the set of parameters that can be used when listing -// subscription schedules. -type SubscriptionScheduleRevisionListParams struct { - ListParams `form:"*"` - Schedule *string `form:"-"` // Included in the URL -} - -// SubscriptionScheduleRevision is the resource representing a Stripe subscription schedule revision. -type SubscriptionScheduleRevision struct { - Created int64 `json:"created"` - ID string `json:"id"` - Livemode bool `json:"livemode"` - Metadata map[string]string `json:"metadata"` - Object string `json:"object"` - Phases []*SubscriptionSchedulePhase `json:"phases"` - PreviousRevision *SubscriptionSchedule `json:"previous_revision"` - RenewalBehavior SubscriptionScheduleRenewalBehavior `json:"renewal_behavior"` - RenewalInterval *SubscriptionScheduleRenewalInterval `json:"renewal_interval"` - Schedule *SubscriptionSchedule `json:"schedule"` -} - -// SubscriptionScheduleRevisionList is a list object for subscription schedule revisions. -type SubscriptionScheduleRevisionList struct { - ListMeta - Data []*SubscriptionScheduleRevision `json:"data"` -} - -// UnmarshalJSON handles deserialization of a SubscriptionScheduleRevision. -// This custom unmarshaling is needed because the resulting -// property may be an id or the full struct if it was expanded. -func (s *SubscriptionScheduleRevision) UnmarshalJSON(data []byte) error { - if id, ok := ParseID(data); ok { - s.ID = id - return nil - } - - type revision SubscriptionScheduleRevision - var v revision - if err := json.Unmarshal(data, &v); err != nil { - return err - } - - *s = SubscriptionScheduleRevision(v) - return nil -} diff --git a/subschedulerevision/client.go b/subschedulerevision/client.go deleted file mode 100644 index 643fa19767..0000000000 --- a/subschedulerevision/client.go +++ /dev/null @@ -1,75 +0,0 @@ -// Package subschedulerevision provides the /subscription_schedules/revisions APIs -package subschedulerevision - -import ( - "fmt" - "net/http" - - stripe "github.com/stripe/stripe-go" - "github.com/stripe/stripe-go/form" -) - -// Client is used to invoke /subscription_schedule/revisions APIs. -type Client struct { - B stripe.Backend - Key string -} - -// Get returns the details of a subscription schedule revision -func Get(id string, params *stripe.SubscriptionScheduleRevisionParams) (*stripe.SubscriptionScheduleRevision, error) { - return getC().Get(id, params) -} - -// Get returns the details of a subscription schedule revision -func (c Client) Get(id string, params *stripe.SubscriptionScheduleRevisionParams) (*stripe.SubscriptionScheduleRevision, error) { - if params == nil { - return nil, fmt.Errorf("params cannot be nil") - } - if params.Schedule == nil { - return nil, fmt.Errorf("params.Schedule must be set") - } - - path := stripe.FormatURLPath("/v1/subscription_schedules/%s/revisions/%s", - stripe.StringValue(params.Schedule), id) - rev := &stripe.SubscriptionScheduleRevision{} - err := c.B.Call(http.MethodGet, path, c.Key, params, rev) - return rev, err -} - -// List returns a list of subscription schedule revisions. -func List(params *stripe.SubscriptionScheduleRevisionListParams) *Iter { - return getC().List(params) -} - -// List returns a list of subscription schedule revisions. -func (c Client) List(listParams *stripe.SubscriptionScheduleRevisionListParams) *Iter { - path := stripe.FormatURLPath("/v1/subscription_schedules/%s/revisions", - stripe.StringValue(listParams.Schedule)) - - return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { - list := &stripe.SubscriptionScheduleRevisionList{} - err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) - - ret := make([]interface{}, len(list.Data)) - for i, v := range list.Data { - ret[i] = v - } - - return ret, list.ListMeta, err - })} -} - -// Iter is an iterator for subscription schedule revisions. -type Iter struct { - *stripe.Iter -} - -// SubscriptionScheduleRevision returns the subscription schedule revision which the iterator is -// currently pointing to. -func (i *Iter) SubscriptionScheduleRevision() *stripe.SubscriptionScheduleRevision { - return i.Current().(*stripe.SubscriptionScheduleRevision) -} - -func getC() Client { - return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} -} diff --git a/subschedulerevision/client_test.go b/subschedulerevision/client_test.go deleted file mode 100644 index 49ba74e803..0000000000 --- a/subschedulerevision/client_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package subschedulerevision - -import ( - "testing" - - assert "github.com/stretchr/testify/require" - stripe "github.com/stripe/stripe-go" - _ "github.com/stripe/stripe-go/testing" -) - -func TestSubscriptionScheduleRevisionGet(t *testing.T) { - params := &stripe.SubscriptionScheduleRevisionParams{ - Schedule: stripe.String("sub_sched_123"), - } - revision, err := Get("sub_sched_rev_123", params) - assert.Nil(t, err) - assert.NotNil(t, revision) -} - -func TestSubscriptionScheduleRevisionList(t *testing.T) { - params := &stripe.SubscriptionScheduleRevisionListParams{ - Schedule: stripe.String("sub_sched_123"), - } - i := List(params) - - // Verify that we can get at least one revision - assert.True(t, i.Next()) - assert.Nil(t, i.Err()) - assert.NotNil(t, i.SubscriptionScheduleRevision()) -}