lib/sailthru.rb in sailthru-client-1.12 vs lib/sailthru.rb in sailthru-client-1.13

- old
+ new

@@ -7,11 +7,11 @@ require 'digest/md5' require 'net/http/post/multipart' module Sailthru - Version = VERSION = '1.12' + Version = VERSION = '1.13' class SailthruClientException < Exception end module Helpers @@ -85,22 +85,11 @@ f[_key] = value end end return f end - - def verify_purchase_items (items) - if items.class == Array and !items.empty? - required_item_fields = ['qty', 'title', 'price', 'id', 'url'].sort - items.each do |v| - keys = v.keys.sort - return false if keys != required_item_fields - end - return true - end - return false - end + end class SailthruClient include Helpers @@ -389,16 +378,17 @@ # params: # email, String # items, String # incomplete, Integer # message_id, String + # options, Hash # returns: # hash, response from server # # Record that a user has made a purchase, or has added items to their purchase total. - def purchase(email, items, incomplete = nil, message_id = nil) - data = {} + def purchase(email, items, incomplete = nil, message_id = nil, options = {}) + data = options data[:email] = email data[:items] = items if incomplete != nil data[:incomplete] = incomplete.to_i @@ -764,16 +754,16 @@ response = http.start { http.request(req) } rescue Exception => e - raise SailthruClientException.new("Unable to open stream: #{_uri.to_s}\n" + e); + raise SailthruClientException.new("Unable to open stream: #{_uri}\n#{e}"); end if response.body return response.body else - raise SailthruClientException.new("No response received from stream: #{_uri.to_s}") + raise SailthruClientException.new("No response received from stream: #{_uri}") end end def http_multipart_request(uri, data) req = Net::HTTP::Post::Multipart.new url.path,