class ElectricProfile::Profiler
Attributes
archived[RW]
callbackType[RW]
customerId[RW]
error[RW]
exitMessage[RW]
hideAnsweredQuestions[RW]
id[RW]
introMessage[RW]
listQuestionsId[RW]
name[RW]
questionOrder[RW]
Public Class Methods
all()
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 81 def self.all client = Client.new if client.fetch_profilers client.data["Items"].map { |atts| new atts } else raise StandardError, client.error end end
find(id)
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 72 def self.find(id) client = Client.new if client.fetch_profiler(id) new client.data["data"] else raise StandardError, client.error end end
new(atts)
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 6 def initialize(atts) atts = atts.inject({}){ |memo, (k, v) | memo[k.to_sym] = v; memo } @id = atts[:id] @customerId = atts[:customerId] @name = atts[:name] @listQuestionsId = atts[:listQuestionsId] || [] @introMessage = atts[:introMessage] @exitMessage = atts[:exitMessage] @hideAnsweredQuestions = atts[:hideAnsweredQuestions] || false @questionOrder = atts[:questionOrder] @callbackType = atts[:callbackType] @archived = atts[:archived] || false end
Public Instance Methods
initialize_client()
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 90 def initialize_client @client ||= Client.new end
save()
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 20 def save if @id save_existing else save_new end end
save_existing()
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 50 def save_existing initialize_client attributes = { id: @id, customerId: @customerId, name: @name, listQuestionsId: @listQuestionsId, introMessage: @introMessage, exitMessage: @exitMessage, hideAnsweredQuestions: @hideAnsweredQuestions, questionOrder: @questionOrder, callbackType: @callbackType, archived: @archived } if @client.update_profiler(attributes) true else @error = @client.error false end end
save_new()
click to toggle source
# File lib/electric_profile_ruby/profiler.rb, line 28 def save_new initialize_client attributes = { name: @name, listQuestionsId: @listQuestionsId, introMessage: @introMessage, exitMessage: @exitMessage, hideAnsweredQuestions: @hideAnsweredQuestions, questionOrder: @questionOrder, callbackType: @callbackType, archived: @archived } if @client.create_profiler(attributes) @id = @client.data["data"]["id"] @customerId = @client.data["data"]["customerId"] true else @error = @client.error false end end