pub struct OrganizationApi<'a, A> { /* private fields */ }Expand description
Calls the organization endpoints without HTTP.
create, add_member,
has_permission and
invitations_for_email act for the server and need no
session. Every other method calls the route of the same name as the session in
headers (their cookies, or whatever a session resolver reads), and answers what the
route would, plus the cookies it sets.
Implementations§
Source§impl<A: AuthInstance> OrganizationApi<'_, A>
impl<A: AuthInstance> OrganizationApi<'_, A>
Sourcepub async fn create(
&self,
user_id: &Id,
input: CreateOrganizationInput,
) -> Result<OrganizationWithMembers, AuthError>
pub async fn create( &self, user_id: &Id, input: CreateOrganizationInput, ) -> Result<OrganizationWithMembers, AuthError>
Creates an organization owned by user_id (which replaces input.user_id). Ignores
allow_user_to_create_organization, but not organization_limit. Runs hooks on
CreateOrganization and emits OrganizationCreated and MemberAdded.
Sourcepub async fn add_member(
&self,
organization_id: &Id,
user_id: &Id,
role: &str,
) -> Result<Member, AuthError>
pub async fn add_member( &self, organization_id: &Id, user_id: &Id, role: &str, ) -> Result<Member, AuthError>
Adds a user to an organization without an invitation. role is one role or a
comma-separated list; each must exist. Runs hooks on AddMember and emits
MemberAdded.
Sourcepub async fn has_permission(
&self,
organization_id: &Id,
user_id: &Id,
permissions: &[(&str, &[&str])],
) -> Result<bool, AuthError>
pub async fn has_permission( &self, organization_id: &Id, user_id: &Id, permissions: &[(&str, &[&str])], ) -> Result<bool, AuthError>
Whether the user’s role in the organization grants permissions; false when they
aren’t a member.
Sourcepub async fn invitations_for_email(
&self,
email: &str,
) -> Result<Vec<InvitationWithOrganization>, AuthError>
pub async fn invitations_for_email( &self, email: &str, ) -> Result<Vec<InvitationWithOrganization>, AuthError>
Pending invitations addressed to email, with their organizations’ names.
Source§impl<A: AuthInstance> OrganizationApi<'_, A>
impl<A: AuthInstance> OrganizationApi<'_, A>
Sourcepub async fn create_as(
&self,
headers: &HeaderMap,
input: CreateOrganizationInput,
) -> Result<ApiResponse<OrganizationWithMembers>, AuthError>
pub async fn create_as( &self, headers: &HeaderMap, input: CreateOrganizationInput, ) -> Result<ApiResponse<OrganizationWithMembers>, AuthError>
POST /organization/create as the session in headers.
Sourcepub async fn update(
&self,
headers: &HeaderMap,
input: UpdateOrganizationInput,
) -> Result<ApiResponse<OrganizationRow>, AuthError>
pub async fn update( &self, headers: &HeaderMap, input: UpdateOrganizationInput, ) -> Result<ApiResponse<OrganizationRow>, AuthError>
POST /organization/update as the session in headers.
Sourcepub async fn delete(
&self,
headers: &HeaderMap,
input: DeleteOrganizationInput,
) -> Result<ApiResponse<OrganizationRow>, AuthError>
pub async fn delete( &self, headers: &HeaderMap, input: DeleteOrganizationInput, ) -> Result<ApiResponse<OrganizationRow>, AuthError>
POST /organization/delete as the session in headers.
Sourcepub async fn list(
&self,
headers: &HeaderMap,
input: Empty,
) -> Result<ApiResponse<Vec<OrganizationRow>>, AuthError>
pub async fn list( &self, headers: &HeaderMap, input: Empty, ) -> Result<ApiResponse<Vec<OrganizationRow>>, AuthError>
GET /organization/list as the session in headers.
Sourcepub async fn get_full(
&self,
headers: &HeaderMap,
input: GetFullOrganizationQuery,
) -> Result<ApiResponse<Option<FullOrganization>>, AuthError>
pub async fn get_full( &self, headers: &HeaderMap, input: GetFullOrganizationQuery, ) -> Result<ApiResponse<Option<FullOrganization>>, AuthError>
GET /organization/get-full-organization as the session in headers.
Sourcepub async fn set_active(
&self,
headers: &HeaderMap,
input: SetActiveOrganizationInput,
) -> Result<ApiResponse<Option<OrganizationRow>>, AuthError>
pub async fn set_active( &self, headers: &HeaderMap, input: SetActiveOrganizationInput, ) -> Result<ApiResponse<Option<OrganizationRow>>, AuthError>
POST /organization/set-active as the session in headers.
Sourcepub async fn check_slug(
&self,
headers: &HeaderMap,
input: CheckSlugInput,
) -> Result<ApiResponse<Status>, AuthError>
pub async fn check_slug( &self, headers: &HeaderMap, input: CheckSlugInput, ) -> Result<ApiResponse<Status>, AuthError>
POST /organization/check-slug as the session in headers.
Sourcepub async fn invite_member(
&self,
headers: &HeaderMap,
input: InviteMemberInput,
) -> Result<ApiResponse<Invitation>, AuthError>
pub async fn invite_member( &self, headers: &HeaderMap, input: InviteMemberInput, ) -> Result<ApiResponse<Invitation>, AuthError>
POST /organization/invite-member as the session in headers.
Sourcepub async fn accept_invitation(
&self,
headers: &HeaderMap,
input: InvitationIdInput,
) -> Result<ApiResponse<InvitationResponse>, AuthError>
pub async fn accept_invitation( &self, headers: &HeaderMap, input: InvitationIdInput, ) -> Result<ApiResponse<InvitationResponse>, AuthError>
POST /organization/accept-invitation as the session in headers.
Sourcepub async fn reject_invitation(
&self,
headers: &HeaderMap,
input: InvitationIdInput,
) -> Result<ApiResponse<InvitationResponse>, AuthError>
pub async fn reject_invitation( &self, headers: &HeaderMap, input: InvitationIdInput, ) -> Result<ApiResponse<InvitationResponse>, AuthError>
POST /organization/reject-invitation as the session in headers.
Sourcepub async fn cancel_invitation(
&self,
headers: &HeaderMap,
input: InvitationIdInput,
) -> Result<ApiResponse<Invitation>, AuthError>
pub async fn cancel_invitation( &self, headers: &HeaderMap, input: InvitationIdInput, ) -> Result<ApiResponse<Invitation>, AuthError>
POST /organization/cancel-invitation as the session in headers.
Sourcepub async fn get_invitation(
&self,
headers: &HeaderMap,
input: InvitationIdQuery,
) -> Result<ApiResponse<InvitationDetails>, AuthError>
pub async fn get_invitation( &self, headers: &HeaderMap, input: InvitationIdQuery, ) -> Result<ApiResponse<InvitationDetails>, AuthError>
GET /organization/get-invitation as the session in headers.
Sourcepub async fn list_invitations(
&self,
headers: &HeaderMap,
input: OrganizationIdQuery,
) -> Result<ApiResponse<Vec<Invitation>>, AuthError>
pub async fn list_invitations( &self, headers: &HeaderMap, input: OrganizationIdQuery, ) -> Result<ApiResponse<Vec<Invitation>>, AuthError>
GET /organization/list-invitations as the session in headers.
Sourcepub async fn list_user_invitations(
&self,
headers: &HeaderMap,
input: Empty,
) -> Result<ApiResponse<Vec<InvitationWithOrganization>>, AuthError>
pub async fn list_user_invitations( &self, headers: &HeaderMap, input: Empty, ) -> Result<ApiResponse<Vec<InvitationWithOrganization>>, AuthError>
GET /organization/list-user-invitations as the session in headers.
Sourcepub async fn remove_member(
&self,
headers: &HeaderMap,
input: RemoveMemberInput,
) -> Result<ApiResponse<RemoveMemberOutput>, AuthError>
pub async fn remove_member( &self, headers: &HeaderMap, input: RemoveMemberInput, ) -> Result<ApiResponse<RemoveMemberOutput>, AuthError>
POST /organization/remove-member as the session in headers.
Sourcepub async fn update_member_role(
&self,
headers: &HeaderMap,
input: UpdateMemberRoleInput,
) -> Result<ApiResponse<Member>, AuthError>
pub async fn update_member_role( &self, headers: &HeaderMap, input: UpdateMemberRoleInput, ) -> Result<ApiResponse<Member>, AuthError>
POST /organization/update-member-role as the session in headers.
Sourcepub async fn leave(
&self,
headers: &HeaderMap,
input: LeaveOrganizationInput,
) -> Result<ApiResponse<Member>, AuthError>
pub async fn leave( &self, headers: &HeaderMap, input: LeaveOrganizationInput, ) -> Result<ApiResponse<Member>, AuthError>
POST /organization/leave as the session in headers.
Sourcepub async fn get_active_member(
&self,
headers: &HeaderMap,
input: Empty,
) -> Result<ApiResponse<MemberWithUser>, AuthError>
pub async fn get_active_member( &self, headers: &HeaderMap, input: Empty, ) -> Result<ApiResponse<MemberWithUser>, AuthError>
GET /organization/get-active-member as the session in headers.
Sourcepub async fn list_members(
&self,
headers: &HeaderMap,
input: ListMembersQuery,
) -> Result<ApiResponse<ListMembersOutput>, AuthError>
pub async fn list_members( &self, headers: &HeaderMap, input: ListMembersQuery, ) -> Result<ApiResponse<ListMembersOutput>, AuthError>
GET /organization/list-members as the session in headers.
Sourcepub async fn check_permission(
&self,
headers: &HeaderMap,
input: HasPermissionInput,
) -> Result<ApiResponse<HasPermissionOutput>, AuthError>
pub async fn check_permission( &self, headers: &HeaderMap, input: HasPermissionInput, ) -> Result<ApiResponse<HasPermissionOutput>, AuthError>
POST /organization/has-permission as the session in headers.