itunes_validator 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1383cfb2c9e8a04f1ea0ea8af36e6ecbd0c5b865
4
- data.tar.gz: 421dce6d0ad73e6eea100b3d046ad0457d59547c
3
+ metadata.gz: eccf396503837b383c0c3f976596d998d4fa8f62
4
+ data.tar.gz: 9ee21081006cde3f5acfcb346ccf58454a6c1f09
5
5
  SHA512:
6
- metadata.gz: 8bbd3b01c5cf941b22f88eb75e5ea1f29e69c569e7050deb08812e0208f84000f5226c214def75ac6ae299a9db7d2b9e736a1b12e9c39e8b78bf994011f2d813
7
- data.tar.gz: 80e92c453c1476f15c4be05935d3f2131d8d986de38e250886cc4c417a1165b6816b0d5fc754d26263cfadcfc813d441fe1db75cc65a9d2a8f8e76c2c9c6aac3
6
+ metadata.gz: e64dff5caaf1fa0643f4acab76711fa2bca6472a9c2713759fc89daf83ffa562dc70beb591b3f772e7b3e51abfee13b91915e986929ddbee5fcae876374c6e46
7
+ data.tar.gz: a0a9d908b9ba5db9d1dc0e21c9592ae4454b8760b3e43c710bcfa30b049c2ac42e581d697d29a6a67143acc68b6c3afe26ff7ff6beba6d9b3544b362f76354b8
@@ -15,6 +15,7 @@ module ItunesValidator
15
15
  def initialize(options=nil)
16
16
  @shared_secret = options[:shared_secret] if options
17
17
  @use_latest = (options[:use_latest] if options) || true
18
+ @return_latest_too = (options[:return_latest_too] if options) || true
18
19
  end
19
20
 
20
21
  def validate(receipt_data)
@@ -24,7 +25,7 @@ module ItunesValidator
24
25
  post_body['receipt-data'] = receipt_data
25
26
  post_body['password'] = @shared_secret if @shared_secret
26
27
 
27
- receipt_info = nil
28
+ receipt_info = latest_receipt_info = nil
28
29
 
29
30
  uri = URI(APPSTORE_VERIFY_URL_PRODUCTION)
30
31
  begin
@@ -41,9 +42,7 @@ module ItunesValidator
41
42
  case itunes_status = response_body['status'].to_i
42
43
  when 0
43
44
  receipt_info = response_body['receipt']
44
- if @use_latest && response_body['latest_receipt_info']
45
- receipt_info = response_body['latest_receipt_info']
46
- end
45
+ latest_receipt_info = response_body['latest_receipt_info']
47
46
  else
48
47
  raise ItunesValidationError.new(itunes_status)
49
48
  end
@@ -57,7 +56,17 @@ module ItunesValidator
57
56
  end
58
57
  end
59
58
 
60
- Receipt.from_h(receipt_info) if receipt_info
59
+ receipts = [receipt_info, latest_receipt_info].map{ |ri| Receipt.from_h(ri) if ri }
60
+
61
+ if @use_latest
62
+ return receipts.compact.last
63
+ end
64
+
65
+ if @return_latest_too
66
+ return receipts
67
+ end
68
+
69
+ receipts[0]
61
70
  end
62
71
  end
63
72
 
@@ -1,6 +1,6 @@
1
1
  require_relative 'itunes_validator/client'
2
2
  require_relative 'itunes_validator/receipt'
3
- require_relative 'itunes_validator/version'
4
3
 
5
4
  module ItunesValidator
5
+ VERSION = '0.3.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Talbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -35,7 +35,6 @@ files:
35
35
  - lib/itunes_validator.rb
36
36
  - lib/itunes_validator/client.rb
37
37
  - lib/itunes_validator/receipt.rb
38
- - lib/itunes_validator/version.rb
39
38
  homepage: https://github.com/cysp/itunes_validator-ruby
40
39
  licenses:
41
40
  - MPL-2.0
@@ -1,3 +0,0 @@
1
- module ItunesValidator
2
- VERSION = '0.3.0'
3
- end