Class: Monza::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/monza/client.rb

Constant Summary collapse

PRODUCTION_URL =
"https://buy.itunes.apple.com/verifyReceipt"
DEVELOPMENT_URL =
"https://sandbox.itunes.apple.com/verifyReceipt"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



25
26
# File 'lib/monza/client.rb', line 25

def initialize
end

Instance Attribute Details

#shared_secret=(value) ⇒ Object (writeonly)

Sets the attribute shared_secret

Parameters:

  • value

    the value to set the attribute shared_secret to.



8
9
10
# File 'lib/monza/client.rb', line 8

def shared_secret=(value)
  @shared_secret = value
end

#verification_urlObject

Returns the value of attribute verification_url.



7
8
9
# File 'lib/monza/client.rb', line 7

def verification_url
  @verification_url
end

Class Method Details

.developmentObject



13
14
15
16
17
# File 'lib/monza/client.rb', line 13

def self.development
  client = self.new
  client.verification_url = DEVELOPMENT_URL
  client
end

.productionObject



19
20
21
22
23
# File 'lib/monza/client.rb', line 19

def self.production
  client = self.new
  client.verification_url = PRODUCTION_URL
  client
end

Instance Method Details

#verify(data, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/monza/client.rb', line 28

def verify(data, options = {})
  # Post to apple and receive json_response
  json_response = post_receipt_verification(data, options)
  # Get status code of response
  status = json_response['status'].to_i

  case status
  when 0
    begin
      return VerificationResponse.new(json_response)
    rescue
      nil
    end
  else
    raise VerificationResponse::VerificationError.new(status)
  end

end