Class: Typeform::Client

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

Overview

Common functionality across Typeform API objects.

Direct Known Subclasses

Api::Form, Api::Response, Api::Workspace

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.connectionTypeform::Connection

The connection object being used to communicate with Typeform.

Returns:



34
35
36
# File 'lib/typeform/client.rb', line 34

def connection
  @@connection ||= Connection.new
end

.connection=(conn) ⇒ Typeform::Connection

Assign a default connection object.

Parameters:

Returns:



41
42
43
# File 'lib/typeform/client.rb', line 41

def connection=(conn)
  @@connection = conn
end

.parse(body) ⇒ Object

Converts the response body to an ObjectifiedHash.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/typeform/client.rb', line 13

def self.parse(body)
  if body.is_a?(Hash)
    body = body.deep_underscore_keys
    ObjectifiedHash.new(body)
  elsif body.is_a?(Array)
    body = body.deep_underscore_keys
    body.collect! { |e| ObjectifiedHash.new(e) }
  elsif body
    true
  elsif !body
    false
  elsif body.nil?
    false
  else
    raise Typeform::Error.new("Couldn't parse a response body")
  end
end

Instance Method Details

#connectionTypeform::Connection

The connection object being used to communicate with Typeform.

Returns:



8
9
10
# File 'lib/typeform/client.rb', line 8

def connection
  self.class.connection
end