class TranscripticKit::Client

Attributes

email[R]
key[R]
org_name[R]
org_url[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/transcriptic_kit/client.rb, line 11
def initialize(options = {})
  @email = options.with_indifferent_access[:email]
  @key = options.with_indifferent_access[:key]
  @org_name = options.with_indifferent_access[:org_name]
end
resources() click to toggle source
# File lib/transcriptic_kit/client.rb, line 23
def self.resources
  {
    projects: ProjectResource,
    organization: OrganizationResource,
    runs: RunResource
  }
end

Public Instance Methods

connection() click to toggle source
# File lib/transcriptic_kit/client.rb, line 17
def connection
  Faraday.new(connection_options) do |req|
    req.adapter :net_http
  end
end
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/transcriptic_kit/client.rb, line 31
def method_missing(name, *args, &block)
  if self.class.resources.keys.include?(name)
    resources[name] ||= self.class.resources[name].new(connection: connection, org_name: @org_name)
    resources[name]
  else
    super
  end
end
resources() click to toggle source
# File lib/transcriptic_kit/client.rb, line 40
def resources
  @resources ||= {}
end

Private Instance Methods

connection_options() click to toggle source
# File lib/transcriptic_kit/client.rb, line 46
def connection_options
  {
    url: TRANSCRIPTIC_URL + "/#{@org_name}",
    headers: {
      content_type: 'application/json',
      accept: 'application/json',
      "X-User-Email": email,
      "X-User-Token": key
    }
  }
end