Sha256: 3e8981af12920e156bcdb0efcacf34b0089815496126f574c8a5ff24d27c956a

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

require 'active_model'
module Qualtrics
  class Entity
    include ActiveModel::Model
    include ActiveModel::Validations

    def library_id=(lib_id)
      @library_id = lib_id
    end

    def library_id
      @library_id || configuration.default_library_id
    end

    def success?
      @last_response && @last_response.success?
    end

    def persisted?
      !id.nil?
    end

    def post(request, options = {}, body_override = nil)
      @last_response = self.class.post(request, options, body_override)
    end

    def get(request, options = {})
      @last_response = self.class.get(request, options)
    end

    def configuration
      self.class.configuration
    end

    def self.underscore_attributes(attributes)
      attribute_map.inject({}) do |map, keys|
        qualtrics_key, ruby_key = keys[0], keys[1]
        map[ruby_key] = attributes[qualtrics_key]
        map
      end
    end

    def self.post(request, options = {}, body_override = nil)
      Qualtrics::Operation.new(:post, request, options, body_override).issue_request
    end

    def self.get(request, options = {})
      Qualtrics::Operation.new(:get, request, options).issue_request
    end

    def self.configuration
      Qualtrics.configuration
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
qualtrics-0.6.0 lib/qualtrics/entity.rb
qualtrics-0.5.9b lib/qualtrics/entity.rb
qualtrics-0.5.9 lib/qualtrics/entity.rb
qualtrics-0.5.8 lib/qualtrics/entity.rb
qualtrics-0.5.7 lib/qualtrics/entity.rb
qualtrics-0.5.6 lib/qualtrics/entity.rb
qualtrics-0.5.5 lib/qualtrics/entity.rb
qualtrics-0.5.4 lib/qualtrics/entity.rb
qualtrics-0.5.3 lib/qualtrics/entity.rb
qualtrics-0.5.2 lib/qualtrics/entity.rb