Class: TranscripticKit::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/transcriptic_kit/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



31
32
33
34
35
36
37
38
# 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

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



9
10
11
# File 'lib/transcriptic_kit/client.rb', line 9

def email
  @email
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/transcriptic_kit/client.rb', line 9

def key
  @key
end

#org_nameObject (readonly)

Returns the value of attribute org_name.



9
10
11
# File 'lib/transcriptic_kit/client.rb', line 9

def org_name
  @org_name
end

#org_urlObject (readonly)

Returns the value of attribute org_url.



9
10
11
# File 'lib/transcriptic_kit/client.rb', line 9

def org_url
  @org_url
end

Class Method Details

.resourcesObject



23
24
25
26
27
28
29
# File 'lib/transcriptic_kit/client.rb', line 23

def self.resources
  {
    projects: ProjectResource,
    organization: OrganizationResource,
    runs: RunResource
  }
end

Instance Method Details

#connectionObject



17
18
19
20
21
# File 'lib/transcriptic_kit/client.rb', line 17

def connection
  Faraday.new(connection_options) do |req|
    req.adapter :net_http
  end
end

#resourcesObject



40
41
42
# File 'lib/transcriptic_kit/client.rb', line 40

def resources
  @resources ||= {}
end