package entitlements import ( "context" "encoding/json" "io" "net/http" "net/url" ) type UpdateDropsEntitlementsRequest struct { // A list of IDs that identify the entitlements to update. You may specify a maximum of 100 IDs. EntitlementIDs *[]string `json:"entitlement_ids,omitempty"` // The fulfillment status to set the entitlements to. FulfillmentStatus *FulfillmentStatus `json:"fulfillment_status,omitempty"` } type UpdateDropsEntitlementsResponse struct { // A list that indicates which entitlements were successfully updated and those that weren’t. Data []UpdateDropsEntitlementsData `json:"data"` } type UpdateDropsEntitlementsData struct { // A string that indicates whether the status of the entitlements in the ids field were successfully updated. Status UpdateStatus `json:"status"` // The list of entitlements that the status in the status field applies to. IDs []string `json:"ids"` } // Updates the Drop entitlement’s fulfillment status. // // The following table identifies which entitlements are updated based on the type of access token used. // Access token type | Data that’s updated // ------------------|------------------------------------------------------------------------------------------------------------------------------------------ // App | Updates all entitlements with benefits owned by the organization in the access token. // User | Updates all entitlements owned by the user in the access token and where the benefits are owned by the organization in the access token. // // Requires an app access token or user access token. The client ID in the access token must own the game. func (c *Entitlements) UpdateDropsEntitlements(ctx context.Context, request *UpdateDropsEntitlementsRequest) (*UpdateDropsEntitlementsResponse, error) { endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "entitlements/drops"}) r, w := io.Pipe() go func() { if err := json.NewEncoder(w).Encode(request); err != nil { w.CloseWithError(err) } else { w.Close() } }() req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r) if err != nil { return nil, err } res, err := c.client.Do(req) if err != nil { return nil, err } var data UpdateDropsEntitlementsResponse if err := json.NewDecoder(res.Body).Decode(&data); err != nil { return nil, err } return &data, nil }