@@ -28,4 +28,85 @@ enum PersonalAccessTokenAbility: string
28
28
case SYSTEM_STATISTICS_READ = 'system-statistics-read ' ;
29
29
case SYSTEM_STATISTICS_UPDATE = 'system-statistics-update ' ;
30
30
case SYSTEM_STATISTICS_DELETE = 'system-statistics-delete ' ;
31
+ case TEAMS_CREATE = 'teams-create ' ;
32
+ case TEAMS_READ = 'teams-read ' ;
33
+ case TEAMS_UPDATE = 'teams-update ' ;
34
+ case TEAMS_DELETE = 'teams-delete ' ;
35
+
36
+
37
+ public static function abilityLabels (): array
38
+ {
39
+ $ returnArray = [
40
+ self ::SUPER_ADMIN ->value => 'Super Admin ' ,
41
+ self ::MY_PROFILE_CREATE ->value => 'My Profile Create ' ,
42
+ self ::MY_PROFILE_READ ->value => 'My Profile Read ' ,
43
+ self ::MY_PROFILE_UPDATE ->value => 'My Profile Update ' ,
44
+ self ::MY_PROFILE_DELETE ->value => 'My Profile Delete ' ,
45
+ self ::MY_TEAM_CREATE ->value => 'My Team Create ' ,
46
+ self ::MY_TEAM_READ ->value => 'My Team Read ' ,
47
+ self ::MY_TEAM_UPDATE ->value => 'My Team Update ' ,
48
+ self ::MY_TEAM_DELETE ->value => 'My Team Delete ' ,
49
+ self ::TEAMS_READ ->value => 'Teams Read ' ,
50
+ self ::TEAMS_CREATE ->value => 'Teams Create ' ,
51
+ self ::SYSTEM_STATISTICS_READ ->value => 'System Statistics Read ' ,
52
+ // MUST MATCH FULL LIS
53
+ ];
54
+
55
+ // Assert$returnArray
56
+ return $ returnArray
57
+ }
58
+
59
+ /**
60
+ * The abilities that a "platform" app API token should have.
61
+ *
62
+ * Example: The OFN platform has a shop in its organisation chart, and the shop opts in to the vouchers' system.
63
+ * The OFN API token needs to create the team in the vouchers API, create a user for the shop, create an API
64
+ * token for that user, and save the API token locally in the OFN DB so that the shop may perform actions like redeeming, etc.
65
+ *
66
+ * @return PersonalAccessTokenAbility[]
67
+ */
68
+ public static function platformAppTokenAbilities (): array
69
+ {
70
+ return [
71
+ self ::TEAMS_READ ->value => self ::abilityLabels ()[self ::TEAMS_READ ->value ],
72
+ self ::TEAMS_CREATE ->value => self ::abilityLabels ()[self ::TEAMS_CREATE ->value ],
73
+ self ::SYSTEM_STATISTICS_READ ->value => self ::abilityLabels ()[self ::SYSTEM_STATISTICS_READ ->value ],
74
+ ];
75
+ }
76
+
77
+
78
+ /**
79
+ * The abilities that a "redemption" app API token should have.
80
+ *
81
+ * @return array
82
+ */
83
+ public static function redemptionAppTokenAbilities (): array
84
+ {
85
+ return [
86
+
87
+ ];
88
+ }
89
+
90
+ public static function groupsAbilityCasesWithDefinitions (): array
91
+ {
92
+ return [
93
+ [
94
+ 'name ' => 'Super admin abilities ' ,
95
+ 'description ' => 'A group of API abilities that allow an app to perform any / all actions on the API. Be careful assigning this ability! ' ,
96
+ 'abilities ' => [
97
+ self ::SUPER_ADMIN
98
+ ]
99
+ ],
100
+ [
101
+ 'name ' => 'Platform App ' ,
102
+ 'description ' => 'Perform administrative tasks for your OFN platform implementation. ' ,
103
+ 'abilities ' => self ::platformAppTokenAbilities ()
104
+ ],
105
+ [
106
+ 'name ' => 'Redemptions ' ,
107
+ 'description ' => 'A group of API abilities that allow an app to perform redemptions on the system. ' ,
108
+ 'abilities ' => self ::redemptionAppTokenAbilities ()
109
+ ],
110
+ ];
111
+ }
31
112
}
0 commit comments