Module: Seam::Http::Options
- Defined in:
- lib/seam/options.rb,
lib/seam/parse_options.rb
Defined Under Namespace
Classes: SeamInvalidOptionsError
Class Method Summary
collapse
Class Method Details
.get_endpoint(endpoint = nil) ⇒ Object
8
9
10
|
# File 'lib/seam/options.rb', line 8
def self.get_endpoint(endpoint = nil)
endpoint || get_endpoint_from_env || Seam::DEFAULT_ENDPOINT
end
|
.get_endpoint_from_env ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/seam/options.rb', line 12
def self.get_endpoint_from_env
seam_api_url = ENV["SEAM_API_URL"]
seam_endpoint = ENV["SEAM_ENDPOINT"]
if seam_api_url
warn "\033[93mUsing the SEAM_API_URL environment variable is deprecated. Support will be removed in a later major version. Use SEAM_ENDPOINT instead.\033[0m"
end
if seam_api_url && seam_endpoint
warn "\033[93mDetected both the SEAM_API_URL and SEAM_ENDPOINT environment variables. Using SEAM_ENDPOINT.\033[0m"
end
seam_endpoint || seam_api_url
end
|
.parse_options(api_key: nil, personal_access_token: nil, workspace_id: nil, endpoint: nil) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/seam/parse_options.rb', line 9
def self.parse_options(api_key: nil, personal_access_token: nil, workspace_id: nil, endpoint: nil)
api_key ||= ENV["SEAM_API_KEY"] if personal_access_token.nil?
= Http::Auth.(
api_key: api_key,
personal_access_token: personal_access_token,
workspace_id: workspace_id
)
endpoint = Http::Options.get_endpoint(endpoint)
{auth_headers: , endpoint: endpoint}
end
|
.seam_http_options_with_api_key?(api_key: nil, personal_access_token: nil) ⇒ Boolean
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/seam/options.rb', line 33
def self.seam_http_options_with_api_key?(api_key: nil, personal_access_token: nil)
return false if api_key.nil?
if personal_access_token
raise SeamInvalidOptionsError.new(
"The personal_access_token option cannot be used with the api_key option"
)
end
true
end
|
.seam_http_options_with_personal_access_token?(personal_access_token: nil, api_key: nil, workspace_id: nil) ⇒ Boolean
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/seam/options.rb', line 45
def self.seam_http_options_with_personal_access_token?(personal_access_token: nil, api_key: nil, workspace_id: nil)
return false if personal_access_token.nil?
if api_key
raise SeamInvalidOptionsError.new(
"The api_key option cannot be used with the personal_access_token option"
)
end
if workspace_id.nil?
raise SeamInvalidOptionsError.new(
"Must pass a workspace_id when using a personal_access_token"
)
end
true
end
|