github.com/stripe/stripe-go/v76@v76.25.0/reporting/reportrun/client.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  // Package reportrun provides the /reporting/report_runs APIs
     8  package reportrun
     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 /reporting/report_runs APIs.
    18  type Client struct {
    19  	B   stripe.Backend
    20  	Key string
    21  }
    22  
    23  // New creates a new reporting report run.
    24  func New(params *stripe.ReportingReportRunParams) (*stripe.ReportingReportRun, error) {
    25  	return getC().New(params)
    26  }
    27  
    28  // New creates a new reporting report run.
    29  func (c Client) New(params *stripe.ReportingReportRunParams) (*stripe.ReportingReportRun, error) {
    30  	reportrun := &stripe.ReportingReportRun{}
    31  	err := c.B.Call(
    32  		http.MethodPost,
    33  		"/v1/reporting/report_runs",
    34  		c.Key,
    35  		params,
    36  		reportrun,
    37  	)
    38  	return reportrun, err
    39  }
    40  
    41  // Get returns the details of a reporting report run.
    42  func Get(id string, params *stripe.ReportingReportRunParams) (*stripe.ReportingReportRun, error) {
    43  	return getC().Get(id, params)
    44  }
    45  
    46  // Get returns the details of a reporting report run.
    47  func (c Client) Get(id string, params *stripe.ReportingReportRunParams) (*stripe.ReportingReportRun, error) {
    48  	path := stripe.FormatURLPath("/v1/reporting/report_runs/%s", id)
    49  	reportrun := &stripe.ReportingReportRun{}
    50  	err := c.B.Call(http.MethodGet, path, c.Key, params, reportrun)
    51  	return reportrun, err
    52  }
    53  
    54  // List returns a list of reporting report runs.
    55  func List(params *stripe.ReportingReportRunListParams) *Iter {
    56  	return getC().List(params)
    57  }
    58  
    59  // List returns a list of reporting report runs.
    60  func (c Client) List(listParams *stripe.ReportingReportRunListParams) *Iter {
    61  	return &Iter{
    62  		Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
    63  			list := &stripe.ReportingReportRunList{}
    64  			err := c.B.CallRaw(http.MethodGet, "/v1/reporting/report_runs", c.Key, b, p, list)
    65  
    66  			ret := make([]interface{}, len(list.Data))
    67  			for i, v := range list.Data {
    68  				ret[i] = v
    69  			}
    70  
    71  			return ret, list, err
    72  		}),
    73  	}
    74  }
    75  
    76  // Iter is an iterator for reporting report runs.
    77  type Iter struct {
    78  	*stripe.Iter
    79  }
    80  
    81  // ReportingReportRun returns the reporting report run which the iterator is currently pointing to.
    82  func (i *Iter) ReportingReportRun() *stripe.ReportingReportRun {
    83  	return i.Current().(*stripe.ReportingReportRun)
    84  }
    85  
    86  // ReportingReportRunList returns the current list object which the iterator is
    87  // currently using. List objects will change as new API calls are made to
    88  // continue pagination.
    89  func (i *Iter) ReportingReportRunList() *stripe.ReportingReportRunList {
    90  	return i.List().(*stripe.ReportingReportRunList)
    91  }
    92  
    93  func getC() Client {
    94  	return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
    95  }