1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5package lunatask
6
7import (
8 "errors"
9 "fmt"
10 "strings"
11)
12
13// RelationshipStrength categorizes the closeness of a relationship.
14type RelationshipStrength string
15
16// Valid relationship strength values.
17const (
18 RelationshipFamily RelationshipStrength = "family"
19 RelationshipIntimateFriend RelationshipStrength = "intimate-friends"
20 RelationshipCloseFriend RelationshipStrength = "close-friends"
21 // RelationshipCasualFriend is the default if not specified.
22 RelationshipCasualFriend RelationshipStrength = "casual-friends"
23 RelationshipAcquaintance RelationshipStrength = "acquaintances"
24 RelationshipBusiness RelationshipStrength = "business-contacts"
25 RelationshipAlmostStranger RelationshipStrength = "almost-strangers"
26)
27
28// Errors returned by RelationshipStrength operations.
29var (
30 // ErrInvalidRelationshipStrength is returned when parsing an unknown relationship strength string.
31 ErrInvalidRelationshipStrength = errors.New("invalid relationship strength")
32)
33
34// String returns the relationship strength value as a string.
35func (r RelationshipStrength) String() string {
36 return string(r)
37}
38
39// AllRelationshipStrengths returns all valid relationship strength values
40// from closest (family) to most distant (almost strangers).
41func AllRelationshipStrengths() []RelationshipStrength {
42 return []RelationshipStrength{
43 RelationshipFamily,
44 RelationshipIntimateFriend,
45 RelationshipCloseFriend,
46 RelationshipCasualFriend,
47 RelationshipAcquaintance,
48 RelationshipBusiness,
49 RelationshipAlmostStranger,
50 }
51}
52
53// ParseRelationshipStrength parses a string to a RelationshipStrength value (case-insensitive).
54// Valid values: "family", "intimate-friends", "close-friends", "casual-friends",
55// "acquaintances", "business-contacts", "almost-strangers".
56func ParseRelationshipStrength(str string) (RelationshipStrength, error) {
57 switch strings.ToLower(str) {
58 case "family":
59 return RelationshipFamily, nil
60 case "intimate-friends":
61 return RelationshipIntimateFriend, nil
62 case "close-friends":
63 return RelationshipCloseFriend, nil
64 case "casual-friends":
65 return RelationshipCasualFriend, nil
66 case "acquaintances":
67 return RelationshipAcquaintance, nil
68 case "business-contacts":
69 return RelationshipBusiness, nil
70 case "almost-strangers":
71 return RelationshipAlmostStranger, nil
72 default:
73 return "", fmt.Errorf("%w: %q", ErrInvalidRelationshipStrength, str)
74 }
75}