Class: Crowdskout::Services::FieldService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/crowdskout/services/field_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#access_token, #api_key

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Crowdskout::Services::BaseService

Instance Method Details

#get_options_for_a_field(field_name, params = {}) ⇒ FieldOptions

more info - docs.crowdskout.com/api/#get-the-options-for-a-field Get the options for a field

Parameters:

  • field_name (String)
    • the name of the field

  • params (Hash) (defaults to: {})
    • A hash with query parameters

Returns:

  • (FieldOptions)
    • the field options

Raises:



15
16
17
18
19
20
21
22
# File 'lib/crowdskout/services/field_service.rb', line 15

def get_options_for_a_field(field_name, params = {})
  raise Exceptions::ServiceException, "Field name is required." if field_name.nil?
  url = Util::Config.get('endpoints.base_url') +
        sprintf(Util::Config.get('endpoints.fields_options'), field_name)
  url = build_url(url, params)
  response = RestClient.get(url, get_headers())
  Components::FieldOptions.create(JSON.parse(response.body)["data"])
end