package channelpoints import ( "context" "encoding/json" "net/http" "net/url" "github.com/google/go-querystring/query" "go.fifitido.net/twitch/api/types" ) type GetCustomRewardRedemptionParams struct { // The ID of the broadcaster that owns the custom reward. This ID must match the user ID found in the user OAuth token. BroadcasterID string `url:"broadcaster_id"` // The ID that identifies the custom reward whose redemptions you want to get. RewardID string `url:"reward_id"` // The status of the redemptions to return. The possible case-sensitive values are: // // NOTE: This field is required only if you don’t specify the id query parameter. // // NOTE: Canceled and fulfilled redemptions are returned for only a few days after they’re canceled or fulfilled. Status *RewardRedemptionStatus `url:"status,omitempty"` // A list of IDs to filter the redemptions by. To specify more than one ID, include this parameter for each redemption you want to get. // For example, id=1234&id=5678. You may specify a maximum of 50 IDs. // // Duplicate IDs are ignored. The response contains only the IDs that were found. If none of the IDs were found, the response is 404 Not Found. IDs []string `url:"id,omitempty"` // The order to sort redemptions by. The default is OLDEST. Sort *types.SortOrder `url:"sort,omitempty"` // The cursor used to get the next page of results. The Pagination object in the response contains the cursor’s value. // Read more: https://dev.twitch.tv/docs/api/guide/#pagination After *string `url:"after,omitempty"` // The maximum number of redemptions to return per page in the response. // The minimum page size is 1 redemption per page and the maximum is 50. // The default is 20. First *int `url:"first,omitempty"` } type GetCustomRewardRedemptionResponse struct { // The list of redemptions for the specified reward. The list is empty if there are no redemptions that match the redemption criteria. Data []CustomRewardRedemption `json:"data"` } // Gets a list of redemptions for the specified custom reward. The app used to create the reward is the only app that may get the redemptions. // // Requires a user access token that includes the channel:read:redemptions or channel:manage:redemptions scope. func (c *ChannelPoints) GetCustomRewardRedemption(ctx context.Context, params *GetCustomRewardRedemptionParams) (*GetCustomRewardRedemptionResponse, error) { v, _ := query.Values(params) endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards/redemptions", RawQuery: v.Encode()}) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil) if err != nil { return nil, err } res, err := c.client.Do(req) if err != nil { return nil, err } defer res.Body.Close() var data GetCustomRewardRedemptionResponse if err := json.NewDecoder(res.Body).Decode(&data); err != nil { return nil, err } return &data, nil }