./lib/venice/client.rb in venice-0.4.0 vs ./lib/venice/client.rb in venice-0.4.1

- old
+ new

@@ -1,26 +1,26 @@ require 'json' require 'net/https' require 'uri' module Venice - ITUNES_PRODUCTION_RECEIPT_VERIFICATION_ENDPOINT = "https://buy.itunes.apple.com/verifyReceipt" - ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT = "https://sandbox.itunes.apple.com/verifyReceipt" + ITUNES_PRODUCTION_RECEIPT_VERIFICATION_ENDPOINT = 'https://buy.itunes.apple.com/verifyReceipt' + ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT = 'https://sandbox.itunes.apple.com/verifyReceipt' class Client attr_accessor :verification_url attr_writer :shared_secret class << self def development - client = self.new + client = new client.verification_url = ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT client end def production - client = self.new + client = new client.verification_url = ITUNES_PRODUCTION_RECEIPT_VERIFICATION_ENDPOINT client end end @@ -31,11 +31,12 @@ def verify!(data, options = {}) @verification_url ||= ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT @shared_secret = options[:shared_secret] if options[:shared_secret] json = json_response_from_verifying_data(data) - status, receipt_attributes = json['status'].to_i, json['receipt'] + status = json['status'].to_i + receipt_attributes = json['receipt'].dup receipt_attributes['original_json_response'] = json if receipt_attributes case status when 0, 21006 receipt = Receipt.new(receipt_attributes) @@ -71,11 +72,11 @@ http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Post.new(uri.request_uri) - request['Accept'] = "application/json" - request['Content-Type'] = "application/json" + request['Accept'] = 'application/json' + request['Content-Type'] = 'application/json' request.body = parameters.to_json response = http.request(request) JSON.parse(response.body)