Sha256: 9910d891e2fee7dac7afcd91155b4988b2d6fd7f091056cb2b9985e4ed04f65c

Contents?: true

Size: 984 Bytes

Versions: 12

Compression:

Stored size: 984 Bytes

Contents

#
# field_service.rb
# Crowdskout
#
# Copyright (c) 2016 Kyle Schutt. All rights reserved.

module Crowdskout
  module Services
    class FieldService < BaseService
      class << self

        # more info - http://docs.crowdskout.com/api/#get-the-options-for-a-field
        # Get the options for a field
        # @param [String] field_name - the name of the field
        # @param [Hash] params - A hash with query parameters
        # @return [FieldOptions] - the field options
        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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
crowdskout-0.1.2 lib/crowdskout/services/field_service.rb
crowdskout-0.1.1 lib/crowdskout/services/field_service.rb
crowdskout-0.1.0 lib/crowdskout/services/field_service.rb
crowdskout-0.0.20 lib/crowdskout/services/field_service.rb
crowdskout-0.0.19 lib/crowdskout/services/field_service.rb
crowdskout-0.0.13 lib/crowdskout/services/field_service.rb
crowdskout-0.0.10 lib/crowdskout/services/field_service.rb
crowdskout-0.0.9 lib/crowdskout/services/field_service.rb
crowdskout-0.0.8 lib/crowdskout/services/field_service.rb
crowdskout-0.0.7 lib/crowdskout/services/field_service.rb
crowdskout-0.0.6 lib/crowdskout/services/field_service.rb
crowdskout-0.0.5 lib/crowdskout/services/field_service.rb