Sha256: 55e0d389a7965d219c012cbf677ec2bdedc7229e3e524d0608d673e4bc4f3128
Contents?: true
Size: 1.39 KB
Versions: 11
Compression:
Stored size: 1.39 KB
Contents
require 'faraday' require 'faraday_middleware' require 'json' module Qualtrics class Panel < Entity attr_accessor :id, :name, :category def self.all(library_id = nil) lib_id = library_id || configuration.default_library_id response = get('getPanels', {'LibraryID' => lib_id}) if response.success? response.result['Panels'].map do |panel| new(underscore_attributes(panel)) end else [] end end def self.attribute_map { 'LibraryID' => :library_id, 'Category' => :category, 'Name' => :name, 'PanelID' => :id } end def initialize(options={}) @name = options[:name] @id = options[:id] @category = options[:category] @library_id = options[:library_id] end def save response = nil if persisted? raise Qualtrics::UpdateNotAllowed else response = post('createPanel', attributes) end if response.success? self.id = response.result['PanelID'] true else false end end def destroy response = post('deletePanel', { 'LibraryID' => library_id, 'PanelID' => self.id }) response.success? end def attributes { 'LibraryID' => library_id, 'Category' => category, 'Name' => name } end end end
Version data entries
11 entries across 11 versions & 1 rubygems