diff --git a/README.md b/README.md index dd28ff29..987dbc4d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ accurate and fully typed. - [Resume pagination](#resume-pagination) - [Iterate over all resources](#iterate-over-all-resources) - [Return all resources across all pages as a list](#return-all-resources-across-all-pages-as-a-list) - - [Interacting with Multiple Workspaces](#interacting-with-multiple-workspaces) + - [Requests without a Workspace in scope](#requests-without-a-workspace-in-scope) + - [Personal Access Token](#personal-access-token-1) - [Webhooks](#webhooks) - [Advanced Usage](#advanced-usage) - [Additional Options](#additional-options) @@ -314,18 +315,27 @@ paginator = seam.create_paginator(seam.devices.method(:list), {limit: 20}) all_devices = paginator.flatten_to_list ``` -### Interacting with Multiple Workspaces +### Requests without a Workspace in scope -Some Seam API endpoints interact with multiple workspaces. The `Seam::Http::SeamMultiWorkspace` client is not bound to a specific workspace and may use those endpoints with a personal access token authentication method. +Some Seam API endpoints do not require a workspace in scope. +The `Seam::Http::WithoutWorkspace` client is not bound to a specific workspace +and may use those endpoints with a personal access token authentication method. -A Personal Access Token is scoped to a Seam Console user. Obtain one from the Seam Console. +#### Personal Access Token + +A Personal Access Token is scoped to a Seam Console user. +Obtain one from the Seam Console. ```ruby -# Pass as an option to the constructor -seam = Seam::Http::SeamMultiWorkspace.new(personal_access_token: "your-personal-access-token") +# Pass as a keyword argument to the constructor +seam = Seam::Http::WithoutWorkspace.new( + personal_access_token: "your-personal-access-token" +) # Use the factory method -seam = Seam::Http::SeamMultiWorkspace.from_personal_access_token("your-personal-access-token") +seam = Seam::Http::WithoutWorkspace.from_personal_access_token( + "your-personal-access-token" +) # List workspaces authorized for this Personal Access Token workspaces = seam.workspaces.list diff --git a/lib/seam.rb b/lib/seam.rb index 796386c4..fce8429c 100644 --- a/lib/seam.rb +++ b/lib/seam.rb @@ -2,7 +2,7 @@ require_relative "seam/lts_version" require_relative "seam/http" -require_relative "seam/http_multi_workspace" +require_relative "seam/http_without_workspace" require_relative "seam/webhook" require_relative "seam/wait_for_action_attempt" diff --git a/lib/seam/auth.rb b/lib/seam/auth.rb index e4c256ac..e6232ef6 100644 --- a/lib/seam/auth.rb +++ b/lib/seam/auth.rb @@ -86,7 +86,7 @@ def self.get_auth_headers_for_personal_access_token(personal_access_token, works } end - def self.get_auth_headers_for_multi_workspace_personal_access_token(personal_access_token) + def self.get_auth_headers_for_without_workspace_personal_access_token(personal_access_token) if Auth.jwt?(personal_access_token) raise SeamInvalidTokenError.new( "A JWT cannot be used as a personal_access_token" diff --git a/lib/seam/http_multi_workspace.rb b/lib/seam/http_without_workspace.rb similarity index 87% rename from lib/seam/http_multi_workspace.rb rename to lib/seam/http_without_workspace.rb index df2c2ca0..9195ad3d 100644 --- a/lib/seam/http_multi_workspace.rb +++ b/lib/seam/http_without_workspace.rb @@ -11,7 +11,7 @@ module Seam module Http - class MultiWorkspace + class WithoutWorkspace attr_reader :client, :defaults def initialize(personal_access_token:, endpoint: nil, wait_for_action_attempt: true, timeout: nil, @@ -19,7 +19,7 @@ def initialize(personal_access_token:, endpoint: nil, wait_for_action_attempt: t @wait_for_action_attempt = wait_for_action_attempt @defaults = {"wait_for_action_attempt" => wait_for_action_attempt} @endpoint = Http::Options.get_endpoint(endpoint) - @auth_headers = Http::Auth.get_auth_headers_for_multi_workspace_personal_access_token(personal_access_token) + @auth_headers = Http::Auth.get_auth_headers_for_without_workspace_personal_access_token(personal_access_token) @client = Http::Request.create_faraday_client(@endpoint, @auth_headers, faraday_options, faraday_retry_options, timeout: timeout) end @@ -36,7 +36,8 @@ def workspaces @workspaces ||= WorkspacesProxy.new(Seam::Clients::Workspaces.new(client: @client, defaults: @defaults)) end - def self.from_personal_access_token(personal_access_token, endpoint: nil, wait_for_action_attempt: true, timeout: nil, faraday_options: {}, faraday_retry_options: {}) + def self.from_personal_access_token(personal_access_token, endpoint: nil, wait_for_action_attempt: true, + timeout: nil, faraday_options: {}, faraday_retry_options: {}) new( personal_access_token: personal_access_token, endpoint: endpoint, diff --git a/spec/seam_client/client_multi_workspace_spec.rb b/spec/seam_client/client_without_workspace_spec.rb similarity index 97% rename from spec/seam_client/client_multi_workspace_spec.rb rename to spec/seam_client/client_without_workspace_spec.rb index 8b6c389c..051f7fb3 100644 --- a/spec/seam_client/client_multi_workspace_spec.rb +++ b/spec/seam_client/client_without_workspace_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Seam::Http::MultiWorkspace, :fake do +RSpec.describe Seam::Http::WithoutWorkspace, :fake do describe ".from_personal_access_token" do it "returns an instance authorized with the personal access token" do seam = described_class.from_personal_access_token(