Sha256: 0a18d1ecfc0253e1b692dee8340e1bbe11b900f2c7a0c3a59fce124bd69075d1

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require "active_support/core_ext/module/delegation"
require "faraday"
require "ostruct"
require "singleton"
require "zeitwerk"

# Load the gem's internal dependencies
loader = Zeitwerk::Loader.new
loader.inflector = Zeitwerk::GemInflector.new(__FILE__)
loader.push_dir(File.absolute_path("#{__FILE__}/../.."))
loader.setup

module Globus
  # Client for interacting with the Globus API
  class Client
    include Singleton

    class << self
      # @param client_id [String] the client identifier registered with Globus
      # @param client_secret [String] the client secret to authenticate with Globus
      # @param uploads_directory [String] where to upload files
      # @param transfer_endpoint_id [String] the transfer API endpoint ID supplied by Globus
      # @param transfer_url [String] the transfer API URL
      # @param auth_url [String] the authentication API URL
      def configure(client_id:, client_secret:, uploads_directory:, transfer_endpoint_id:, transfer_url: default_transfer_url, auth_url: default_auth_url)
        instance.config = OpenStruct.new(
          token: Globus::Client::Authenticator.token(client_id, client_secret, auth_url),
          uploads_directory:,
          transfer_endpoint_id:,
          transfer_url:,
          auth_url:
        )

        self
      end

      delegate :mkdir, :config, to: :instance

      def default_transfer_url
        "https://transfer.api.globusonline.org"
      end

      def default_auth_url
        "https://auth.globus.org"
      end
    end

    attr_accessor :config

    def mkdir(...)
      endpoint = Globus::Client::Endpoint.new(config, ...)
      endpoint.mkdir
      endpoint.set_permissions
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
globus_client-0.2.1 lib/globus/client.rb
globus_client-0.2.0 lib/globus/client.rb