Module: Smplkit::Platform
- Defined in:
- lib/smplkit/platform/types.rb,
lib/smplkit/platform/client.rb,
lib/smplkit/platform/models.rb
Defined Under Namespace
Modules: EnvironmentClassification Classes: Color, ContextType, ContextTypesClient, ContextsClient, Environment, EnvironmentsClient, PlatformClient, Service, ServicesClient
Constant Summary collapse
- HEX_RE =
/\A#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\z/
Class Method Summary collapse
-
.app_transport(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object
private
Build a standalone app transport from resolved config.
-
.coerce_color(value) ⇒ Object
private
Accept Color, hex string, or nil; reject anything else.
-
.split_context_id(id_or_type, key) ⇒ Object
private
Resolve the two-arg or composite-id form to [type, key].
Class Method Details
.app_transport(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build a standalone app transport from resolved config.
base_url/api_key are used directly when supplied (the path the top-level client takes after it has already resolved them); otherwise the config resolver fills in whatever is missing (+~/.smplkit+ / env vars / defaults).
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/smplkit/platform/client.rb', line 51 def self.app_transport(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) cfg = ConfigResolution.resolve_client_config( profile: profile, api_key: api_key, base_domain: base_domain, scheme: scheme, debug: debug ) resolved_key = api_key.nil? ? cfg.api_key : api_key merged = {} merged.merge!(cfg.extra_headers || {}) merged.merge!(extra_headers || {}) tcfg = ConfigResolution::ResolvedClientConfig.new( api_key: resolved_key, base_domain: cfg.base_domain, scheme: cfg.scheme, debug: cfg.debug, extra_headers: merged ) Transport.build_api_client(SmplkitGeneratedClient::App, "app", tcfg, base_url: base_url) end |
.coerce_color(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Accept Color, hex string, or nil; reject anything else.
8 9 10 11 12 13 |
# File 'lib/smplkit/platform/models.rb', line 8 def self.coerce_color(value) return value if value.nil? || value.is_a?(Color) return Color.new(value) if value.is_a?(String) raise TypeError, "color must be a Color, hex string, or nil; got #{value.class}: #{value.inspect}" end |
.split_context_id(id_or_type, key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resolve the two-arg or composite-id form to [type, key].
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/smplkit/platform/client.rb', line 31 def self.split_context_id(id_or_type, key) return [id_or_type, key] unless key.nil? unless id_or_type.include?(":") raise ArgumentError, "context id must be 'type:key' (got #{id_or_type.inspect}); " \ "alternatively pass type and key as separate args" end id_or_type.split(":", 2) end |