Skip to content

Commit 6d6b8ba

Browse files
authored
Merge pull request #546 from appwrite/feat-member-role-helper
Add `member` function to all role helpers
2 parents 31d9a4c + 9de26b3 commit 6d6b8ba

File tree

27 files changed

+187
-144
lines changed

27 files changed

+187
-144
lines changed

templates/android/library/src/main/java/io/appwrite/Role.kt.twig

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ package {{ sdk.namespace | caseDot }}
22

33
class Role {
44
companion object {
5-
fun any(): String
6-
= "any"
7-
fun user(id: String): String
8-
= "user:$id"
9-
fun users(): String
10-
= "users"
11-
fun guests(): String
12-
= "guests"
13-
fun team(id: String, role: String = ""): String
14-
= if(role.isEmpty()) {
15-
"team:$id"
16-
} else {
17-
"team:$id/$role"
18-
}
19-
fun status(status: String): String
20-
= "status:$status"
5+
fun any(): String = "any"
6+
7+
fun user(id: String): String = "user:$id"
8+
9+
fun users(): String = "users"
10+
11+
fun guests(): String = "guests"
12+
13+
fun team(id: String, role: String = ""): String = if(role.isEmpty()) {
14+
"team:$id"
15+
} else {
16+
"team:$id/$role"
17+
}
18+
19+
fun member(id: String): String = "member:$id"
20+
21+
fun status(status: String): String = "status:$status"
2122
}
2223
}

templates/dart/lib/role.dart.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class Role {
2323
}
2424
return 'team:$id/$role';
2525
}
26+
27+
static String member(String id) {
28+
return 'member:$id';
29+
}
2630

2731
static String status(String status) {
2832
return 'status:$status';

templates/deno/src/role.ts.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export class Role {
2121
}
2222
return `team:${id}/${role}`
2323
}
24+
25+
public static member(id: string): string {
26+
return `member:${id}`
27+
}
2428

2529
public static status(status: string): string {
2630
return `status:${status}`

templates/kotlin/src/main/kotlin/io/appwrite/Role.kt.twig

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ package {{ sdk.namespace | caseDot }}
22

33
class Role {
44
companion object {
5-
fun any(): String
6-
= "any"
7-
fun user(id: String): String
8-
= "user:$id"
9-
fun users(): String
10-
= "users"
11-
fun guests(): String
12-
= "guests"
13-
fun team(id: String, role: String = ""): String
14-
= if(role.isEmpty()) {
15-
"team:$id"
16-
} else {
17-
"team:$id/$role"
18-
}
19-
fun status(status: String): String
20-
= "status:$status"
5+
fun any(): String = "any"
6+
7+
fun user(id: String): String = "user:$id"
8+
9+
fun users(): String = "users"
10+
11+
fun guests(): String= "guests"
12+
13+
fun team(id: String, role: String = ""): String = if(role.isEmpty()) {
14+
"team:$id"
15+
} else {
16+
"team:$id/$role"
17+
}
18+
19+
fun member(id: String): String = "member:$id"
20+
21+
fun status(status: String): String = "status:$status"
2122
}
2223
}

templates/node/lib/role.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Role {
1717
}
1818
return 'team:' + id + '/' + role
1919
}
20+
static member = (id) => {
21+
return 'member:' + id
22+
}
2023
static status = (status) => {
2124
return 'status:' + status
2225
}

templates/php/src/Role.php.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class Role
2727
}
2828
return "team:$id/$role";
2929
}
30+
public static function member(string $id): string
31+
{
32+
return "member:$id";
33+
}
3034
public static function status(string $status): string
3135
{
3236
return "status:$status";

templates/python/package/role.py.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class Role:
2121
return f'team:{id}/{role}'
2222
return f'team:{id}'
2323

24+
@staticmethod
25+
def member(id):
26+
return f'member:{id}'
27+
2428
@staticmethod
2529
def status(status):
2630
return f'status:{status}'

templates/ruby/lib/container/role.rb.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ module {{spec.title | caseUcfirst}}
2323
"team:#{id}/#{role}"
2424
end
2525
end
26+
27+
def self.member(id)
28+
"member:#{id}"
29+
end
2630

2731
def self.status(status)
2832
"status:#{status}"

templates/swift/Sources/Role.swift.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public class Role {
2222
return "team:\(id)/\(role)"
2323
}
2424

25+
public static func member(_ id: String) -> String {
26+
return "member:\(id)"
27+
}
28+
2529
public static func status(_ status: String) -> String {
2630
return "status:\(status)"
2731
}

templates/web/src/role.ts.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export class Role {
2121
}
2222
return `team:${id}/${role}`
2323
}
24+
25+
public static member(id: string): string {
26+
return `member:${id}`
27+
}
2428

2529
public static status(status: string): string {
2630
return `status:${status}`

0 commit comments

Comments
 (0)