Class: Hivehook::Resources::UserService

Inherits:
BaseService show all
Defined in:
lib/hivehook/resources/user_service.rb

Constant Summary collapse

FRAGMENT =
"id organizationId email name role lastLoginAt createdAt updatedAt"

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Hivehook::Resources::BaseService

Instance Method Details

#invite(organization_id, input) ⇒ Object



23
24
25
26
# File 'lib/hivehook/resources/user_service.rb', line 23

def invite(organization_id, input)
  query = "mutation($organizationId: UUID!, $input: InviteUserInput!) { inviteUser(organizationId: $organizationId, input: $input) { #{FRAGMENT} } }"
  @transport.execute(query, { "organizationId" => organization_id, "input" => input })["inviteUser"]
end

#list(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/hivehook/resources/user_service.rb', line 8

def list(options = {})
  query = "query($organizationId: UUID, $search: String, $limit: Int, $offset: Int) {
    users(organizationId: $organizationId, search: $search, limit: $limit, offset: $offset) {
      nodes { #{FRAGMENT} }
      pageInfo { total limit offset endCursor hasNextPage }
    }
  }"
  @transport.execute(query, build_variables(options, %w[organizationId search limit offset]))["users"]
end

#meObject



18
19
20
21
# File 'lib/hivehook/resources/user_service.rb', line 18

def me
  query = "query { me { #{FRAGMENT} } }"
  @transport.execute(query, {})["me"]
end

#remove(id) ⇒ Object



28
29
30
31
# File 'lib/hivehook/resources/user_service.rb', line 28

def remove(id)
  query = "mutation($id: UUID!) { removeUser(id: $id) }"
  @transport.execute(query, { "id" => id })["removeUser"]
end

#update_role(id, input) ⇒ Object



33
34
35
36
# File 'lib/hivehook/resources/user_service.rb', line 33

def update_role(id, input)
  query = "mutation($id: UUID!, $input: UpdateUserRoleInput!) { updateUserRole(id: $id, input: $input) { #{FRAGMENT} } }"
  @transport.execute(query, { "id" => id, "input" => input })["updateUserRole"]
end