Class: Appwrite::Teams
- Defined in:
- lib/appwrite/services/teams.rb
Instance Method Summary collapse
-
#create(team_id:, name:, roles: nil) ⇒ Team
Create a new team.
-
#create_installation(team_id:, app_id:, authorization_details: nil) ⇒ AppInstallation
Install an app on a team.
-
#create_membership(team_id:, roles:, email: nil, user_id: nil, phone: nil, url: nil, name: nil) ⇒ Membership
Invite a new member to join your team.
-
#delete(team_id:) ⇒ Object
Delete a team using its ID.
-
#delete_installation(team_id:, installation_id:) ⇒ Object
Uninstall an app from a team by its installation ID.
-
#delete_membership(team_id:, membership_id:) ⇒ Object
This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member.
-
#get(team_id:) ⇒ Team
Get a team by its ID.
-
#get_installation(team_id:, installation_id:) ⇒ AppInstallation
Get an app installation on a team by its unique ID.
-
#get_membership(team_id:, membership_id:) ⇒ Membership
Get a team member by the membership unique id.
-
#get_prefs(team_id:) ⇒ Preferences
Get the team's shared preferences by its unique ID.
-
#initialize(client) ⇒ Teams
constructor
A new instance of Teams.
-
#list(queries: nil, search: nil, total: nil) ⇒ TeamList
Get a list of all the teams in which the current user is a member.
-
#list_installations(team_id:, queries: nil, total: nil) ⇒ AppInstallationList
List app installations on a team.
-
#list_memberships(team_id:, queries: nil, search: nil, total: nil) ⇒ MembershipList
Use this endpoint to list a team's members using the team's ID.
-
#update_installation(team_id:, installation_id:, authorization_details: nil) ⇒ AppInstallation
Update an app installation on a team.
-
#update_membership(team_id:, membership_id:, roles:) ⇒ Membership
Modify the roles of a team member.
-
#update_membership_status(team_id:, membership_id:, user_id:, secret:) ⇒ Membership
Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.
-
#update_name(team_id:, name:) ⇒ Team
Update the team's name by its unique ID.
-
#update_prefs(team_id:, prefs:) ⇒ Preferences
Update the team's preferences by its unique ID.
Constructor Details
#initialize(client) ⇒ Teams
Returns a new instance of Teams.
6 7 8 |
# File 'lib/appwrite/services/teams.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#create(team_id:, name:, roles: nil) ⇒ Team
Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/appwrite/services/teams.rb', line 51 def create(team_id:, name:, roles: nil) api_path = '/teams' if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end api_params = { teamId: team_id, name: name, roles: roles, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::Team ) end |
#create_installation(team_id:, app_id:, authorization_details: nil) ⇒ AppInstallation
Install an app on a team. When authenticated as a user, only team members with the owner role can install apps. Requests using an API key or in admin mode can install apps on any team. The installation is granted the scopes the app currently requests.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/appwrite/services/teams.rb', line 229 def create_installation(team_id:, app_id:, authorization_details: nil) api_path = '/teams/{teamId}/installations' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if app_id.nil? raise Appwrite::Exception.new('Missing required parameter: "appId"') end api_params = { appId: app_id, authorizationDetails: , } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::AppInstallation ) end |
#create_membership(team_id:, roles:, email: nil, user_id: nil, phone: nil, url: nil, name: nil) ⇒ Membership
Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.
You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.
Use the url parameter to redirect the user from the invitation email to
your app. After the user is redirected, use the Update Team Membership
Status
endpoint to allow the user to accept the invitation to the team.
Please note that to avoid a Redirect Attack Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console.
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/appwrite/services/teams.rb', line 452 def create_membership(team_id:, roles:, email: nil, user_id: nil, phone: nil, url: nil, name: nil) api_path = '/teams/{teamId}/memberships' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if roles.nil? raise Appwrite::Exception.new('Missing required parameter: "roles"') end api_params = { email: email, userId: user_id, phone: phone, roles: roles, url: url, name: name, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::Membership ) end |
#delete(team_id:) ⇒ Object
Delete a team using its ID. Only team members with the owner role can delete the team.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/appwrite/services/teams.rb', line 159 def delete(team_id:) api_path = '/teams/{teamId}' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#delete_installation(team_id:, installation_id:) ⇒ Object
Uninstall an app from a team by its installation ID. Only team members with the owner role can remove installations. Previously issued installation access tokens are revoked.
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/appwrite/services/teams.rb', line 351 def delete_installation(team_id:, installation_id:) api_path = '/teams/{teamId}/installations/{installationId}' .gsub('{teamId}', team_id) .gsub('{installationId}', installation_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if installation_id.nil? raise Appwrite::Exception.new('Missing required parameter: "installationId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#delete_membership(team_id:, membership_id:) ⇒ Object
This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted.
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/appwrite/services/teams.rb', line 583 def delete_membership(team_id:, membership_id:) api_path = '/teams/{teamId}/memberships/{membershipId}' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if membership_id.nil? raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#get(team_id:) ⇒ Team
Get a team by its ID. All team members have read access for this resource.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/appwrite/services/teams.rb', line 89 def get(team_id:) api_path = '/teams/{teamId}' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::Team ) end |
#get_installation(team_id:, installation_id:) ⇒ AppInstallation
Get an app installation on a team by its unique ID. Any team member can read installations.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/appwrite/services/teams.rb', line 269 def get_installation(team_id:, installation_id:) api_path = '/teams/{teamId}/installations/{installationId}' .gsub('{teamId}', team_id) .gsub('{installationId}', installation_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if installation_id.nil? raise Appwrite::Exception.new('Missing required parameter: "installationId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AppInstallation ) end |
#get_membership(team_id:, membership_id:) ⇒ Membership
Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console.
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/appwrite/services/teams.rb', line 497 def get_membership(team_id:, membership_id:) api_path = '/teams/{teamId}/memberships/{membershipId}' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if membership_id.nil? raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::Membership ) end |
#get_prefs(team_id:) ⇒ Preferences
Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in user preferences.
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
# File 'lib/appwrite/services/teams.rb', line 676 def get_prefs(team_id:) api_path = '/teams/{teamId}/prefs' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::Preferences ) end |
#list(queries: nil, search: nil, total: nil) ⇒ TeamList
Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/appwrite/services/teams.rb', line 18 def list(queries: nil, search: nil, total: nil) api_path = '/teams' api_params = { queries: queries, search: search, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::TeamList ) end |
#list_installations(team_id:, queries: nil, total: nil) ⇒ AppInstallationList
List app installations on a team. Any team member can read installations.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/appwrite/services/teams.rb', line 191 def list_installations(team_id:, queries: nil, total: nil) api_path = '/teams/{teamId}/installations' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end api_params = { queries: queries, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AppInstallationList ) end |
#list_memberships(team_id:, queries: nil, search: nil, total: nil) ⇒ MembershipList
Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console.
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/appwrite/services/teams.rb', line 392 def list_memberships(team_id:, queries: nil, search: nil, total: nil) api_path = '/teams/{teamId}/memberships' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end api_params = { queries: queries, search: search, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::MembershipList ) end |
#update_installation(team_id:, installation_id:, authorization_details: nil) ⇒ AppInstallation
Update an app installation on a team. Only team members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/appwrite/services/teams.rb', line 310 def update_installation(team_id:, installation_id:, authorization_details: nil) api_path = '/teams/{teamId}/installations/{installationId}' .gsub('{teamId}', team_id) .gsub('{installationId}', installation_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if installation_id.nil? raise Appwrite::Exception.new('Missing required parameter: "installationId"') end api_params = { authorizationDetails: , } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PUT', path: api_path, headers: api_headers, params: api_params, response_type: Models::AppInstallation ) end |
#update_membership(team_id:, membership_id:, roles:) ⇒ Membership
Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about roles and permissions.
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/appwrite/services/teams.rb', line 538 def update_membership(team_id:, membership_id:, roles:) api_path = '/teams/{teamId}/memberships/{membershipId}' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if membership_id.nil? raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end if roles.nil? raise Appwrite::Exception.new('Missing required parameter: "roles"') end api_params = { roles: roles, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::Membership ) end |
#update_membership_status(team_id:, membership_id:, user_id:, secret:) ⇒ Membership
Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.
If the request is successful, a session for the user is automatically created.
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/appwrite/services/teams.rb', line 627 def update_membership_status(team_id:, membership_id:, user_id:, secret:) api_path = '/teams/{teamId}/memberships/{membershipId}/status' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if membership_id.nil? raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if secret.nil? raise Appwrite::Exception.new('Missing required parameter: "secret"') end api_params = { userId: user_id, secret: secret, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::Membership ) end |
#update_name(team_id:, name:) ⇒ Team
Update the team's name by its unique ID.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/appwrite/services/teams.rb', line 121 def update_name(team_id:, name:) api_path = '/teams/{teamId}' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end api_params = { name: name, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PUT', path: api_path, headers: api_headers, params: api_params, response_type: Models::Team ) end |
#update_prefs(team_id:, prefs:) ⇒ Preferences
Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded.
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
# File 'lib/appwrite/services/teams.rb', line 710 def update_prefs(team_id:, prefs:) api_path = '/teams/{teamId}/prefs' .gsub('{teamId}', team_id) if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end if prefs.nil? raise Appwrite::Exception.new('Missing required parameter: "prefs"') end api_params = { prefs: prefs, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PUT', path: api_path, headers: api_headers, params: api_params, response_type: Models::Preferences ) end |