Class: Shipeasy::Admin::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/shipeasy/admin.rb

Overview

Programmatic client for the Shipeasy Admin REST API. Each resource group is a lazily-constructed, memoized reader whose methods map 1:1 to the OpenAPI operations.

This is the LEAN admin surface: the vendored spec is the dedicated server-SDK contract (marketplace/openapi/spec/openapi-sdk.yaml in the monorepo), seven operations across three capabilities — file a public ticket (#ops), toggle a kill switch (#killswitch), manage a flag's whitelist (#flags). The rest of the admin API (experiments, metrics, events, configs, i18n, projects, …) is intentionally NOT here; reach it through the Shipeasy CLI or MCP, which consume the complete spec.

Constant Summary collapse

APIS =

Friendly reader name => generated Api class.

{
  flags: Generated::FlagsApi,
  killswitch: Generated::KillswitchApi,
  ops: Generated::OpsApi,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, project_id: nil, base_url: "https://shipeasy.ai", client_key: nil) ⇒ Client

Two of the seven operations — #ops.create_public_bug and #ops.create_public_feature_request — are the PUBLIC ticket intake. They live on the Shipeasy edge worker and authenticate with a CLIENT key (X-SDK-Key), not the admin key, so pass client_key: if you want to call them. The generated client routes them to the edge host itself.

Parameters:

  • api_key (String)

    admin SDK key, sent as Authorization: Bearer <api_key>.

  • project_id (String, nil) (defaults to: nil)

    optional project id sent as the X-Project-Id header on every request. Operations also accept an explicit x_project_id: argument to override per call.

  • base_url (String) (defaults to: "https://shipeasy.ai")

    admin API base URL. Defaults to https://shipeasy.ai (the spec's production server); use http://localhost:3000 for local dev. The public intake ignores it — it carries its own server list.

  • client_key (String, nil) (defaults to: nil)

    client SDK key (sdk_client_…) carrying the tickets:public_create scope, sent as X-SDK-Key on the two public ticket operations. Optional — omit it if you only use the admin ones.



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/shipeasy/admin.rb', line 73

def initialize(api_key:, project_id: nil, base_url: "https://shipeasy.ai", client_key: nil)
  config = Generated::Configuration.new
  config.access_token = api_key
  config.api_key["clientSdkKey"] = client_key if client_key
  scheme, _, host = base_url.rpartition("://")
  config.scheme = scheme unless scheme.empty?
  config.host = host.empty? ? base_url : host

  @api_client = Generated::ApiClient.new(config)
  @api_client.default_headers["X-Project-Id"] = project_id if project_id
  @apis = {}
end

Instance Attribute Details

#api_clientObject (readonly)

The underlying generated ApiClient (advanced/escape hatch).



87
88
89
# File 'lib/shipeasy/admin.rb', line 87

def api_client
  @api_client
end