github.com/stripe/stripe-go/v76@v76.25.0/search_params.go (about) 1 package stripe 2 3 import ( 4 "context" 5 ) 6 7 // 8 // Public types 9 // 10 11 // SearchContainer is a general interface for which all search result object structs 12 // should comply. They achieve this by embedding a SearchMeta struct and 13 // inheriting its implementation of this interface. 14 type SearchContainer interface { 15 GetSearchMeta() *SearchMeta 16 } 17 18 // SearchMeta is the structure that contains the common properties of the search iterators 19 type SearchMeta struct { 20 HasMore bool `json:"has_more"` 21 NextPage *string `json:"next_page"` 22 URL string `json:"url"` 23 // TotalCount is the total number of objects in the search result (beyond just 24 // on the current page). 25 // The value is returned only when `total_count` is specified in `expand` parameter. 26 TotalCount *uint32 `json:"total_count"` 27 } 28 29 // GetSearchMeta returns a SearchMeta struct (itself). It exists because any 30 // structs that embed SearchMeta will inherit it, and thus implement the 31 // SearchContainer interface. 32 func (l *SearchMeta) GetSearchMeta() *SearchMeta { 33 return l 34 } 35 36 // SearchParams is the structure that contains the common properties 37 // of any *SearchParams structure. 38 type SearchParams struct { 39 // Context used for request. It may carry deadlines, cancelation signals, 40 // and other request-scoped values across API boundaries and between 41 // processes. 42 // 43 // Note that a cancelled or timed out context does not provide any 44 // guarantee whether the operation was or was not completed on Stripe's API 45 // servers. For certainty, you must either retry with the same idempotency 46 // key or query the state of the API. 47 Context context.Context `form:"-"` 48 49 Query string `form:"query"` 50 Limit *int64 `form:"limit"` 51 Page *string `form:"page"` 52 // Deprecated: Please use Expand in the surrounding struct instead. 53 Expand []*string `form:"expand"` 54 55 // Single specifies whether this is a single page iterator. By default, 56 // listing through an iterator will automatically grab additional pages as 57 // the query progresses. To change this behavior and just load a single 58 // page, set this to true. 59 Single bool `form:"-"` // Not an API parameter 60 61 // StripeAccount may contain the ID of a connected account. By including 62 // this field, the request is made as if it originated from the connected 63 // account instead of under the account of the owner of the configured 64 // Stripe key. 65 StripeAccount *string `form:"-"` // Passed as header 66 } 67 68 // AddExpand on the embedded SearchParams struct is deprecated 69 // Deprecated: please use .AddExpand of the surrounding struct instead. 70 func (p *SearchParams) AddExpand(f string) { 71 p.Expand = append(p.Expand, &f) 72 } 73 74 // GetSearchParams returns a SearchParams struct (itself). It exists because any 75 // structs that embed SearchParams will inherit it, and thus implement the 76 // SearchParamsContainer interface. 77 func (p *SearchParams) GetSearchParams() *SearchParams { 78 return p 79 } 80 81 // GetParams returns SearchParams as a Params struct. It exists because any 82 // structs that embed Params will inherit it, and thus implement the 83 // ParamsContainer interface. 84 func (p *SearchParams) GetParams() *Params { 85 return p.ToParams() 86 } 87 88 // SetStripeAccount sets a value for the Stripe-Account header. 89 func (p *SearchParams) SetStripeAccount(val string) { 90 p.StripeAccount = &val 91 } 92 93 // ToParams converts a SearchParams to a Params by moving over any fields that 94 // have valid targets in the new type. This is useful because fields in 95 // Params can be injected directly into an http.Request while generally 96 // SearchParams is only used to build a set of parameters. 97 func (p *SearchParams) ToParams() *Params { 98 return &Params{ 99 Context: p.Context, 100 StripeAccount: p.StripeAccount, 101 } 102 } 103 104 // SearchParamsContainer is a general interface for which all search parameter 105 // structs should comply. They achieve this by embedding a SearchParams struct 106 // and inheriting its implementation of this interface. 107 type SearchParamsContainer interface { 108 GetSearchParams() *SearchParams 109 }