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.



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

def initialize(options = {})
  @email = options.with_indifferent_access[:email]
  @key = options.with_indifferent_access[:key]
  @org_name = options.with_indifferent_access[:org_name]
  @org_url = "https://secure.transcriptic.com/#{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



28
29
30
31
32
33
34
35
# File 'lib/transcriptic_kit/client.rb', line 28

def method_missing(name, *args, &block)
  if self.class.resources.keys.include?(name)
    resources[name] ||= self.class.resources[name].new(connection: connection)
    resources[name]
  else
    super
  end
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



6
7
8
# File 'lib/transcriptic_kit/client.rb', line 6

def email
  @email
end

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/transcriptic_kit/client.rb', line 6

def key
  @key
end

#org_nameObject (readonly)

Returns the value of attribute org_name.



6
7
8
# File 'lib/transcriptic_kit/client.rb', line 6

def org_name
  @org_name
end

#org_urlObject (readonly)

Returns the value of attribute org_url.



6
7
8
# File 'lib/transcriptic_kit/client.rb', line 6

def org_url
  @org_url
end

Class Method Details

.resourcesObject



21
22
23
24
25
26
# File 'lib/transcriptic_kit/client.rb', line 21

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

Instance Method Details

#connectionObject



15
16
17
18
19
# File 'lib/transcriptic_kit/client.rb', line 15

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

#resourcesObject



37
38
39
# File 'lib/transcriptic_kit/client.rb', line 37

def resources
  @resources ||= {}
end