class Kameleoon::CustomData
Attributes
id[RW]
value[RW]
Public Class Methods
new(*args)
click to toggle source
@param [Integer] id Id of the custom data @param [String] value Value of the custom data
@overload @param [Hash] hash Json value encoded in a hash.
# File lib/kameleoon/data.rb, line 42 def initialize(*args) @instance = DataType::CUSTOM @sent = false unless args.empty? if args.length == 1 hash = args.first if hash["id"].nil? raise NotFoundError.new("id") end @id = hash["id"].to_s if hash["value"].nil? raise NotFoundError.new(hash["value"]) end @value = hash["value"] elsif args.length == 2 @id = args[0].to_s @value = args[1] end end end
Public Instance Methods
obtain_full_post_text_line()
click to toggle source
# File lib/kameleoon/data.rb, line 63 def obtain_full_post_text_line to_encode = "[[\"" + @value.to_s.gsub("\"", "\\\"") + "\",1]]" nonce = Kameleoon::Utils.generate_random_string(NONCE_LENGTH) "eventType=customData&index=" + @id.to_s + "&valueToCount=" + URI.encode_www_form_component(to_encode) + "&overwrite=true&nonce=" + nonce end