Sha256: 46ab15abc96b97a6ae7fd0b64e178195ec1112a2e9a4842cc37175562eccd043
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
module Hubspot class Utils class << self # Parses the hubspot properties format into a key-value hash def properties_to_hash(props) newprops = {} props.each{ |k,v| newprops[k] = v["value"] } newprops end # Turns a hash into the hubspot properties format def hash_to_properties(hash) hash.map{ |k,v| {"property" => k.to_s, "value" => v}} end # Generate the API URL for the request # # @param path [String] The path of the request with leading "/". Parts starting with a ":" will be interpolated # @param params [Hash] params to be included in the query string or interpolated into the url. # # @return [String] # def generate_url(path, params={}) raise Hubspot::ConfigurationError.new("'hapikey' not configured") unless Hubspot::Config.hapikey path = path.clone params = params.clone params["hapikey"] = Hubspot::Config.hapikey params.each do |k,v| if path.match(":#{k}") path.gsub!(":#{k}",v.to_s) params.delete(k) end end raise(Hubspot::MissingInterpolation.new("Interpolation not resolved")) if path =~ /:/ query = params.map{ |k,v| "#{k}=#{v}" }.join("&") Hubspot::Config.base_url + path + "?" + query end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hubspot-ruby-0.1.1 | lib/hubspot/utils.rb |