Sha256: a82d1ece729384c02e0ddaa5026942465be94a0ad3fd0917e3d94c6a521bd868

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

module Script
  module Layers
    module Infrastructure
      module ApiClients
        class ScriptServiceApiClient
          LOCAL_INSTANCE_URL = "https://script-service.myshopify.io"

          def initialize(ctx, api_key)
            instance_url = script_service_url
            @api = ShopifyCLI::API.new(
              ctx: ctx,
              url: "#{instance_url}/graphql",
              token: { "APP_KEY" => api_key }.compact.to_json,
              auth_header: "X-Shopify-Authenticated-Tokens"
            )
          end

          def query(query_name, variables: {})
            @api.query(query_name, variables: variables)
          end

          private

          def script_service_url
            if ::ShopifyCLI::Environment.use_spin_partners_instance?
              "https://script-service.#{::ShopifyCLI::Environment.spin_url}"
            else
              LOCAL_INSTANCE_URL
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-cli-2.5.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb