Class: ScreenshotFreeAPI::Resources::Workspaces
- Inherits:
-
Object
- Object
- ScreenshotFreeAPI::Resources::Workspaces
- Defined in:
- lib/screenshotfreeapi/resources/workspaces.rb
Overview
Team workspace management.
Workspaces allow multiple users to share API keys and collaborate. All methods require a management JWT (from Auth#token) passed as ‘jwt:`.
Member roles: “owner” | “admin” | “member” | “viewer”
Instance Method Summary collapse
-
#create(jwt:, name:, **options) ⇒ Hash
Create a new workspace.
-
#get(jwt:, workspace_id:) ⇒ Hash
Get a single workspace with its members list.
-
#initialize(http) ⇒ Workspaces
constructor
A new instance of Workspaces.
-
#invite(jwt:, workspace_id:, email:, role: "member") ⇒ Hash
Invite a user to the workspace by email address.
-
#list(jwt:) ⇒ Array<Hash>
List workspaces the authenticated user belongs to.
-
#remove_member(jwt:, workspace_id:, user_id:) ⇒ Hash
Remove a member from the workspace.
-
#update_member(jwt:, workspace_id:, user_id:, role:) ⇒ Hash
Change a member’s role within the workspace.
Constructor Details
#initialize(http) ⇒ Workspaces
Returns a new instance of Workspaces.
12 13 14 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 12 def initialize(http) @http = http end |
Instance Method Details
#create(jwt:, name:, **options) ⇒ Hash
Create a new workspace.
22 23 24 25 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 22 def create(jwt:, name:, **) body = { name: name }.merge() @http.request(:post, "/workspaces", body: body, auth_header: "Bearer #{jwt}") end |
#get(jwt:, workspace_id:) ⇒ Hash
Get a single workspace with its members list.
42 43 44 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 42 def get(jwt:, workspace_id:) @http.request(:get, "/workspaces/#{workspace_id}", auth_header: "Bearer #{jwt}") end |
#invite(jwt:, workspace_id:, email:, role: "member") ⇒ Hash
Invite a user to the workspace by email address.
54 55 56 57 58 59 60 61 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 54 def invite(jwt:, workspace_id:, email:, role: "member") @http.request( :post, "/workspaces/#{workspace_id}/invite", body: { email: email, role: role }, auth_header: "Bearer #{jwt}" ) end |
#list(jwt:) ⇒ Array<Hash>
List workspaces the authenticated user belongs to.
32 33 34 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 32 def list(jwt:) @http.request(:get, "/workspaces", auth_header: "Bearer #{jwt}") end |
#remove_member(jwt:, workspace_id:, user_id:) ⇒ Hash
Remove a member from the workspace.
70 71 72 73 74 75 76 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 70 def remove_member(jwt:, workspace_id:, user_id:) @http.request( :delete, "/workspaces/#{workspace_id}/members/#{user_id}", auth_header: "Bearer #{jwt}" ) end |
#update_member(jwt:, workspace_id:, user_id:, role:) ⇒ Hash
Change a member’s role within the workspace.
86 87 88 89 90 91 92 93 |
# File 'lib/screenshotfreeapi/resources/workspaces.rb', line 86 def update_member(jwt:, workspace_id:, user_id:, role:) @http.request( :patch, "/workspaces/#{workspace_id}/members/#{user_id}", body: { role: role }, auth_header: "Bearer #{jwt}" ) end |