module Mixpanel::Client::Utils
Mixpanel
API Ruby Client
Library
Utility helpers
Copyright © 2009+ Keolo Keagy See LICENSE for details
Public Class Methods
generate_signature(args, api_secret)
click to toggle source
Return a string composed of hashed values specified by the mixpanel data API
@return [String] md5 hash signature required by mixpanel data API
# File lib/mixpanel/utils.rb, line 23 def self.generate_signature(args, api_secret) Digest::MD5.hexdigest( args.map { |key, val| "#{key}=#{val}" } .sort .join + api_secret ) end
to_hash(data, format)
click to toggle source
Return a JSON object or a string depending on a given format
@param [String] data either CSV or JSON formatted @return [JSON, String] data
# File lib/mixpanel/utils.rb, line 36 def self.to_hash(data, format) if format == 'csv' || format == 'raw' data else begin JSON.parse(data) rescue JSON::ParserError => error raise ParseError, error end end end