github.com/stripe/stripe-go/v76@v76.25.0/billing/metereventsummary/client.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  // Package metereventsummary provides the /billing/meters/{id}/event_summaries APIs
     8  package metereventsummary
     9  
    10  import (
    11  	"net/http"
    12  
    13  	stripe "github.com/stripe/stripe-go/v76"
    14  	"github.com/stripe/stripe-go/v76/form"
    15  )
    16  
    17  // Client is used to invoke /billing/meters/{id}/event_summaries APIs.
    18  type Client struct {
    19  	B   stripe.Backend
    20  	Key string
    21  }
    22  
    23  // List returns a list of billing meter event summaries.
    24  func List(params *stripe.BillingMeterEventSummaryListParams) *Iter {
    25  	return getC().List(params)
    26  }
    27  
    28  // List returns a list of billing meter event summaries.
    29  func (c Client) List(listParams *stripe.BillingMeterEventSummaryListParams) *Iter {
    30  	path := stripe.FormatURLPath(
    31  		"/v1/billing/meters/%s/event_summaries",
    32  		stripe.StringValue(listParams.ID),
    33  	)
    34  	return &Iter{
    35  		Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
    36  			list := &stripe.BillingMeterEventSummaryList{}
    37  			err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
    38  
    39  			ret := make([]interface{}, len(list.Data))
    40  			for i, v := range list.Data {
    41  				ret[i] = v
    42  			}
    43  
    44  			return ret, list, err
    45  		}),
    46  	}
    47  }
    48  
    49  // Iter is an iterator for billing meter event summaries.
    50  type Iter struct {
    51  	*stripe.Iter
    52  }
    53  
    54  // BillingMeterEventSummary returns the billing meter event summary which the iterator is currently pointing to.
    55  func (i *Iter) BillingMeterEventSummary() *stripe.BillingMeterEventSummary {
    56  	return i.Current().(*stripe.BillingMeterEventSummary)
    57  }
    58  
    59  // BillingMeterEventSummaryList returns the current list object which the iterator is
    60  // currently using. List objects will change as new API calls are made to
    61  // continue pagination.
    62  func (i *Iter) BillingMeterEventSummaryList() *stripe.BillingMeterEventSummaryList {
    63  	return i.List().(*stripe.BillingMeterEventSummaryList)
    64  }
    65  
    66  func getC() Client {
    67  	return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
    68  }