// General
// Category sets the aps category on the payload.
// This is a string value that represents the identifier property of the
// UIMutableUserNotificationCategory object you created to define custom actions.
//
//	{"aps":{"category":category}}
965176
func (p *Payload) Category(category string) *Payload {
	p.aps().Category = category
	return p
}
1228325
func (c *Manager) ListCategories(ctx context.Context) ([]string, error) {
	url := internal.URL(c, internal.CategoryPath)
	var res []string
	return res, c.Do(ctx, url.Request(http.MethodGet), &res)
}
873729
func (c *Manager) GetCategories(ctx context.Context) ([]Category, error) {
	ids, err := c.ListCategories(ctx)
	if err != nil {
		return nil, fmt.Errorf("list categories: %s", err)
	}

	var categories []Category
	for _, id := range ids {
		category, err := c.GetCategory(ctx, id)
		if err != nil {
			return nil, fmt.Errorf("get category %s: %s", id, err)
		}

		categories = append(categories, *category)

	}
	return categories, nil
}
48366
func (c *Manager) UpdateCategory(ctx context.Context, category *Category) error {
	spec := struct {
		Category Category `json:"update_spec"`
	}{
		Category: Category{
			AssociableTypes: category.AssociableTypes,
			Cardinality:     category.Cardinality,
			Description:     category.Description,
			Name:            category.Name,
		},
	}
	url := internal.URL(c, internal.CategoryPath).WithID(category.ID)
	return c.Do(ctx, url.Request(http.MethodPatch, spec), nil)
}
1350388
func (s *DeleteCustomActionTypeInput) SetCategory(v string) *DeleteCustomActionTypeInput {
	s.Category = &v
	return s
}
706690
func (c *Manager) DeleteCategory(ctx context.Context, category *Category) error {
	url := internal.URL(c, internal.CategoryPath).WithID(category.ID)
	return c.Do(ctx, url.Request(http.MethodDelete), nil)
}
272102
func (s *EventInfoMap) SetEventCategories(v []*string) *EventInfoMap {
	s.EventCategories = v
	return s
}
202491
func (d Dic) CharacterCategory(r rune) byte {
	if int(r) < len(d.CharCategory) {
		return d.CharCategory[r]
	}
	return d.CharCategory[0] // default
}
375314
func (s *SigningPlatform) SetCategory(v string) *SigningPlatform {
	s.Category = &v
	return s
}
1222910
func (m DeserializedManifest) Payload() (string, []byte, error) {
	return v1.MediaTypeImageManifest, m.canonical, nil
}
1240103
func (a *StartArgs) SetCategories(categories string) *StartArgs {
	a.Categories = &categories
	return a
}
1151115
func (s *ActionTypeId) SetCategory(v string) *ActionTypeId {
	s.Category = &v
	return s
}
674372
func categoriesForOffset(offset uint64, n, k uint) Categories {
	var categories Categories
	for i := uint(0); i < k; i++ {
		current := binomial(n, k-i)
		for current > offset {
			n--
			current = binomial(n, k-i)
		}
		categories = append(categories, uint16(n))
		offset = offset - current
	}
	sort.Sort(categories)
	return categories
}
1155286
func (s *CreateCustomActionTypeInput) SetCategory(v string) *CreateCustomActionTypeInput {
	s.Category = &v
	return s
}
1024656
func (categories Categories) Offset() uint64 {
	k := len(categories)
	r := uint64(0)
	for i := 0; i < k; i++ {
		r += binomial(uint(categories[i]), uint(k-i))
	}
	return r
}
70569
func Payload(r interface{}, act string) {
	if bs, ok := buildSourceDefinition(true); ok {
		var res *design.ResourceDefinition
		var resName string
		if n, ok := r.(string); ok {
			res = design.Design.Resources[n]
			resName = n
		} else {
			res, _ = r.(*design.ResourceDefinition)
		}
		if res == nil {
			dslengine.ReportError("There is no resource %q", resName)
			return
		}
		a, ok := res.Actions[act]
		if !ok {
			dslengine.ReportError("There is no action")
			return
		}
		payload := a.Payload

		// Set UTD in BuildsFrom parent context

		bs.Parent.BuiltFrom[payload.TypeName] = payload
		bs.Parent.PopulateFromModeledType()
	}
}
726434
func (s *CreatePresetInput) SetCategory(v string) *CreatePresetInput {
	s.Category = &v
	return s
}