Class: Typeform::Client
- Inherits:
-
Object
- Object
- Typeform::Client
- Defined in:
- lib/typeform/client.rb
Overview
Common functionality across Typeform API objects.
Direct Known Subclasses
Class Method Summary collapse
-
.connection ⇒ Typeform::Connection
The connection object being used to communicate with Typeform.
-
.connection=(conn) ⇒ Typeform::Connection
Assign a default connection object.
-
.parse(body) ⇒ Object
Converts the response body to an ObjectifiedHash.
Instance Method Summary collapse
-
#connection ⇒ Typeform::Connection
The connection object being used to communicate with Typeform.
Class Method Details
.connection ⇒ Typeform::Connection
The connection object being used to communicate with Typeform.
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.
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
#connection ⇒ Typeform::Connection
The connection object being used to communicate with Typeform.
8 9 10 |
# File 'lib/typeform/client.rb', line 8 def connection self.class.connection end |