|
| 1 | +// This file is automatically created by Recurly's OpenAPI generation process |
| 2 | +// and thus any edits you make by hand will be lost. If you wish to make a |
| 3 | +// change to this file, please create a Github issue explaining the changes you |
| 4 | +// need and we will usher them to the appropriate places. |
| 5 | +package recurly |
| 6 | + |
| 7 | +import ( |
| 8 | + "context" |
| 9 | + "net/http" |
| 10 | +) |
| 11 | + |
| 12 | +type TransactionNextAction struct { |
| 13 | + recurlyResponse *ResponseMetadata |
| 14 | + |
| 15 | + // The type of next action required. |
| 16 | + Type string `json:"type,omitempty"` |
| 17 | + |
| 18 | + // The value associated with the next action type. |
| 19 | + Value string `json:"value,omitempty"` |
| 20 | +} |
| 21 | + |
| 22 | +// GetResponse returns the ResponseMetadata that generated this resource |
| 23 | +func (resource *TransactionNextAction) GetResponse() *ResponseMetadata { |
| 24 | + return resource.recurlyResponse |
| 25 | +} |
| 26 | + |
| 27 | +// setResponse sets the ResponseMetadata that generated this resource |
| 28 | +func (resource *TransactionNextAction) setResponse(res *ResponseMetadata) { |
| 29 | + resource.recurlyResponse = res |
| 30 | +} |
| 31 | + |
| 32 | +// internal struct for deserializing accounts |
| 33 | +type transactionNextActionList struct { |
| 34 | + ListMetadata |
| 35 | + Data []TransactionNextAction `json:"data"` |
| 36 | + recurlyResponse *ResponseMetadata |
| 37 | +} |
| 38 | + |
| 39 | +// GetResponse returns the ResponseMetadata that generated this resource |
| 40 | +func (resource *transactionNextActionList) GetResponse() *ResponseMetadata { |
| 41 | + return resource.recurlyResponse |
| 42 | +} |
| 43 | + |
| 44 | +// setResponse sets the ResponseMetadata that generated this resource |
| 45 | +func (resource *transactionNextActionList) setResponse(res *ResponseMetadata) { |
| 46 | + resource.recurlyResponse = res |
| 47 | +} |
| 48 | + |
| 49 | +// TransactionNextActionList allows you to paginate TransactionNextAction objects |
| 50 | +type TransactionNextActionList struct { |
| 51 | + client HTTPCaller |
| 52 | + requestOptions *RequestOptions |
| 53 | + nextPagePath string |
| 54 | + hasMore bool |
| 55 | + data []TransactionNextAction |
| 56 | +} |
| 57 | + |
| 58 | +func NewTransactionNextActionList(client HTTPCaller, nextPagePath string, requestOptions *RequestOptions) *TransactionNextActionList { |
| 59 | + return &TransactionNextActionList{ |
| 60 | + client: client, |
| 61 | + requestOptions: requestOptions, |
| 62 | + nextPagePath: nextPagePath, |
| 63 | + hasMore: true, |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +type TransactionNextActionLister interface { |
| 68 | + Fetch() error |
| 69 | + FetchWithContext(ctx context.Context) error |
| 70 | + Count() (*int64, error) |
| 71 | + CountWithContext(ctx context.Context) (*int64, error) |
| 72 | + Data() []TransactionNextAction |
| 73 | + HasMore() bool |
| 74 | + Next() string |
| 75 | +} |
| 76 | + |
| 77 | +func (list *TransactionNextActionList) HasMore() bool { |
| 78 | + return list.hasMore |
| 79 | +} |
| 80 | + |
| 81 | +func (list *TransactionNextActionList) Next() string { |
| 82 | + return list.nextPagePath |
| 83 | +} |
| 84 | + |
| 85 | +func (list *TransactionNextActionList) Data() []TransactionNextAction { |
| 86 | + return list.data |
| 87 | +} |
| 88 | + |
| 89 | +// Fetch fetches the next page of data into the `Data` property |
| 90 | +func (list *TransactionNextActionList) FetchWithContext(ctx context.Context) error { |
| 91 | + resources := &transactionNextActionList{} |
| 92 | + err := list.client.Call(ctx, http.MethodGet, list.nextPagePath, nil, nil, list.requestOptions, resources) |
| 93 | + if err != nil { |
| 94 | + return err |
| 95 | + } |
| 96 | + // copy over properties from the response |
| 97 | + list.nextPagePath = resources.Next |
| 98 | + list.hasMore = resources.HasMore |
| 99 | + list.data = resources.Data |
| 100 | + return nil |
| 101 | +} |
| 102 | + |
| 103 | +// Fetch fetches the next page of data into the `Data` property |
| 104 | +func (list *TransactionNextActionList) Fetch() error { |
| 105 | + return list.FetchWithContext(context.Background()) |
| 106 | +} |
| 107 | + |
| 108 | +// Count returns the count of items on the server that match this pager |
| 109 | +func (list *TransactionNextActionList) CountWithContext(ctx context.Context) (*int64, error) { |
| 110 | + resources := &transactionNextActionList{} |
| 111 | + err := list.client.Call(ctx, http.MethodHead, list.nextPagePath, nil, nil, list.requestOptions, resources) |
| 112 | + if err != nil { |
| 113 | + return nil, err |
| 114 | + } |
| 115 | + resp := resources.GetResponse() |
| 116 | + return resp.TotalRecords, nil |
| 117 | +} |
| 118 | + |
| 119 | +// Count returns the count of items on the server that match this pager |
| 120 | +func (list *TransactionNextActionList) Count() (*int64, error) { |
| 121 | + return list.CountWithContext(context.Background()) |
| 122 | +} |
0 commit comments