Class: TypeformData::Client
- Inherits:
-
Object
- Object
- TypeformData::Client
- Defined in:
- lib/typeform_data/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #all_typeforms ⇒ Object
-
#get(endpoint, params = {}) ⇒ Object
Your API key will automatically be added to the request URL as a query param, as required by the API.
-
#initialize(api_key:) ⇒ Client
constructor
For the sake of usability, we’re breaking convention here and accepting an API key as the first parameter instead of an instance of TypeformData::Config.
- #typeform(id) ⇒ Object
Constructor Details
#initialize(api_key:) ⇒ Client
For the sake of usability, we’re breaking convention here and accepting an API key as the first parameter instead of an instance of TypeformData::Config.
9 10 11 |
# File 'lib/typeform_data/client.rb', line 9 def initialize(api_key:) @config = TypeformData::Config.new(api_key: api_key) end |
Class Method Details
.new_from_config(config) ⇒ Object
13 14 15 16 |
# File 'lib/typeform_data/client.rb', line 13 def self.new_from_config(config) raise ArgumentError, 'Missing config' unless config new(api_key: config.api_key) end |
Instance Method Details
#all_typeforms ⇒ Object
28 29 30 31 32 |
# File 'lib/typeform_data/client.rb', line 28 def all_typeforms get('forms').parsed_json.map do |form_hash| ::TypeformData::Typeform.new(@config, form_hash) end end |
#get(endpoint, params = {}) ⇒ Object
Your API key will automatically be added to the request URL as a query param, as required by the API.
24 25 26 |
# File 'lib/typeform_data/client.rb', line 24 def get(endpoint, params = {}) TypeformData::Requestor.get(@config, endpoint, params) end |
#typeform(id) ⇒ Object
34 35 36 |
# File 'lib/typeform_data/client.rb', line 34 def typeform(id) ::TypeformData::Typeform.new(@config, id: id) end |