Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 47 additions & 51 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,123 +2,119 @@ PATH
remote: .
specs:
seam (2.0.0a2)
http (~> 5.2)
faraday (~> 2.7)
faraday-retry (~> 2.2)
svix (~> 1.30)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ansi (1.5.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.7)
bigdecimal (3.1.8)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.0)
domain_name (0.6.20240107)
docile (1.4.1)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.16.3)
ffi-compiler (1.3.2)
ffi (>= 1.15.5)
rake
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-net_http (3.3.0)
net-http
faraday-retry (2.2.1)
faraday (~> 2.0)
ffi (1.17.0)
ffi (1.17.0-x86_64-linux-gnu)
gem-release (2.2.2)
hashdiff (1.1.0)
http (5.2.0)
addressable (~> 2.8)
base64 (~> 0.1)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
llhttp-ffi (~> 0.5.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
hashdiff (1.1.1)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
logger (1.6.1)
multi_json (1.15.0)
parallel (1.24.0)
net-http (0.4.1)
uri
parallel (1.26.3)
parse_gemspec (1.0.0)
parse_gemspec-cli (1.0.0)
multi_json
parse_gemspec
thor
parser (3.3.0.5)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
public_suffix (5.0.5)
racc (1.7.3)
public_suffix (6.0.1)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.0)
rexml (3.2.6)
regexp_parser (2.9.2)
rexml (3.3.8)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.62.1)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-performance (1.20.2)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-console (0.9.1)
simplecov-console (0.9.2)
ansi
simplecov
terminal-table
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
standard (1.35.1)
standard (1.41.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.62.0)
rubocop (~> 1.66.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.3)
standard-performance (~> 1.5)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.3.1)
standard-performance (1.5.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.20.2)
svix (1.30.0)
rubocop-performance (~> 1.22.0)
svix (1.38.0)
typhoeus (~> 1.0, >= 1.0.1)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.3.1)
thor (1.3.2)
typhoeus (1.4.1)
ethon (>= 0.9.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
uri (0.13.1)
webmock (3.0.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand Down
8 changes: 4 additions & 4 deletions lib/seam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def self.new(**args)
Http.new(**args)
end

def self.from_api_key(api_key, endpoint: nil, wait_for_action_attempt: false, debug: false)
Http.from_api_key(api_key, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt, debug: debug)
def self.from_api_key(api_key, endpoint: nil, wait_for_action_attempt: false)
Http.from_api_key(api_key, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt)
end

def self.from_personal_access_token(personal_access_token, workspace_id, endpoint: nil, wait_for_action_attempt: false, debug: false)
Http.from_personal_access_token(personal_access_token, workspace_id, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt, debug: debug)
def self.from_personal_access_token(personal_access_token, workspace_id, endpoint: nil, wait_for_action_attempt: false)
Http.from_personal_access_token(personal_access_token, workspace_id, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt)
end

def self.lts_version
Expand Down
2 changes: 1 addition & 1 deletion lib/seam/helpers/action_attempt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def self.update_action_attempt(action_attempt, client)
}
)

action_attempt.update_from_response(response["action_attempt"])
action_attempt.update_from_response(response.body["action_attempt"])
action_attempt
end
end
Expand Down
11 changes: 5 additions & 6 deletions lib/seam/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ def self.new(**args)
Http::SingleWorkspace.new(**args)
end

def self.from_api_key(api_key, endpoint: nil, wait_for_action_attempt: false, debug: false)
Http::SingleWorkspace.from_api_key(api_key, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt,
debug: debug)
def self.from_api_key(api_key, endpoint: nil, wait_for_action_attempt: false)
Http::SingleWorkspace.from_api_key(api_key, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt)
end

def self.from_personal_access_token(personal_access_token, workspace_id, endpoint: nil, wait_for_action_attempt: false, debug: false)
def self.from_personal_access_token(personal_access_token, workspace_id, endpoint: nil, wait_for_action_attempt: false)
Http::SingleWorkspace.from_personal_access_token(personal_access_token, workspace_id, endpoint: endpoint,
wait_for_action_attempt: wait_for_action_attempt, debug: debug)
wait_for_action_attempt: wait_for_action_attempt)
end

class ApiError < StandardError
Expand All @@ -40,7 +39,7 @@ class InvalidInputError < ApiError
attr_reader :validation_errors

def initialize(error, status_code, request_id)
super(error, status_code, request_id)
super
@code = "invalid_input"
@validation_errors = error["validation_errors"] || {}
end
Expand Down
28 changes: 13 additions & 15 deletions lib/seam/http_multi_workspace.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# frozen_string_literal: true

require_relative "request"
require_relative "parse_options"
require_relative "lts_version"
require_relative "auth"
require_relative "request"

module Seam
module Http
class MultiWorkspace
attr_reader :wait_for_action_attempt, :defaults
attr_reader :client, :defaults

def initialize(personal_access_token:, endpoint: nil, wait_for_action_attempt: true)
def initialize(personal_access_token:, endpoint: nil, wait_for_action_attempt: true, faraday_options: {},
faraday_retry_options: {})
@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)
@client = Seam::Http::Request.create_faraday_client(@endpoint, @auth_headers, faraday_options,
faraday_retry_options)
end

def self.lts_version
Expand All @@ -29,29 +32,24 @@ def workspaces
@workspaces ||= WorkspacesProxy.new(Seam::Clients::Workspaces.new(self))
end

def self.from_personal_access_token(personal_access_token, endpoint: nil, wait_for_action_attempt: true)
def self.from_personal_access_token(personal_access_token, endpoint: nil, wait_for_action_attempt: true, faraday_options: {}, faraday_retry_options: {})
new(
personal_access_token: personal_access_token,
endpoint: endpoint,
wait_for_action_attempt: wait_for_action_attempt
wait_for_action_attempt: wait_for_action_attempt,
faraday_options: faraday_options,
faraday_retry_options: faraday_retry_options
)
end

def request_seam_object(method, path, klass, inner_object, config = {})
response = request_seam(method, path, config)

data = response[inner_object]

response = Seam::Http::Request.request_seam(@client, @endpoint, method, path, config)
data = response.body[inner_object]
klass.load_from_response(data, self)
end

def request_seam(method, path, config = {})
Seam::Request.new(
auth_headers: @auth_headers,
endpoint: @endpoint
).perform(
method, path, config
)
Seam::Http::Request.request_seam(@client, @endpoint, method, path, config)
end
end

Expand Down
40 changes: 18 additions & 22 deletions lib/seam/http_single_workspace.rb
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
# frozen_string_literal: true

require_relative "request"
require_relative "parse_options"
require_relative "routes/routes"
require_relative "request"

module Seam
module Http
class SingleWorkspace
include Seam::Routes

attr_accessor :defaults
attr_reader :client, :defaults

def initialize(api_key: nil, personal_access_token: nil, workspace_id: nil, endpoint: nil,
wait_for_action_attempt: true, debug: false)
options = Http::Options.parse_options(api_key: api_key, personal_access_token: personal_access_token, workspace_id: workspace_id, endpoint: endpoint)
def initialize(client: nil, api_key: nil, personal_access_token: nil, workspace_id: nil, endpoint: nil,
wait_for_action_attempt: true, faraday_options: {}, faraday_retry_options: {})
options = Http::Options.parse_options(api_key: api_key, personal_access_token: personal_access_token,
workspace_id: workspace_id, endpoint: endpoint)
@endpoint = options[:endpoint]
@auth_headers = options[:auth_headers]
@debug = debug
@wait_for_action_attempt = wait_for_action_attempt
@defaults = Seam::DeepHashAccessor.new({"wait_for_action_attempt" => wait_for_action_attempt})

@client = client || Seam::Http::Request.create_faraday_client(@endpoint, @auth_headers, faraday_options,
faraday_retry_options)
end

def lts_version
Seam::LTS_VERSION
end

def self.from_api_key(api_key, endpoint: nil, wait_for_action_attempt: false, debug: false)
new(api_key: api_key, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt, debug: debug)
def self.from_api_key(api_key, endpoint: nil, wait_for_action_attempt: false, faraday_options: {}, faraday_retry_options: {})
new(api_key: api_key, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt,
faraday_options: faraday_options, faraday_retry_options: faraday_retry_options)
end

def self.from_personal_access_token(personal_access_token, workspace_id, endpoint: nil, wait_for_action_attempt: false, debug: false)
new(personal_access_token: personal_access_token, workspace_id: workspace_id, endpoint: endpoint, wait_for_action_attempt: wait_for_action_attempt, debug: debug)
def self.from_personal_access_token(personal_access_token, workspace_id, endpoint: nil, wait_for_action_attempt: false, faraday_options: {}, faraday_retry_options: {})
new(personal_access_token: personal_access_token, workspace_id: workspace_id, endpoint: endpoint,
wait_for_action_attempt: wait_for_action_attempt, faraday_options: faraday_options, faraday_retry_options: faraday_retry_options)
end

def request_seam_object(method, path, klass, inner_object, config = {})
response = request_seam(method, path, config)

data = response[inner_object]

response = Seam::Http::Request.request_seam(@client, @endpoint, method, path, config)
data = response.body[inner_object]
klass.load_from_response(data, self)
end

def request_seam(method, path, config = {})
Seam::Request.new(
auth_headers: @auth_headers,
endpoint: @endpoint,
debug: @debug
).perform(
method, path, config
)
Seam::Http::Request.request_seam(@client, @endpoint, method, path, config)
end
end
end
Expand Down
Loading