itunes_validator 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/itunes_validator.rb +1 -1
- data/lib/itunes_validator/client.rb +14 -18
- data/test/test_itunes_validator.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a478903ae40c548da09c811f5ff575ee3d718357
|
4
|
+
data.tar.gz: b45ee4e98c5405679cbae5650cf05b5b405413aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce700a4fcb9283f6bcd128431513043019e66bebd2c9fc578a3849441219598f325f67e5e5a4cc5f6b757a02da3fac611f438ee7fa9970dac400332c3edd645f
|
7
|
+
data.tar.gz: e32aabe97755ae41ac6d8b3febc427c95c07d26eddf1e11cfd886a9174128a092cf3f6ab99706a3ce9aed23e8897c654c46a91f43fd2d89ebe3b19ea3c1e9473
|
data/lib/itunes_validator.rb
CHANGED
@@ -20,22 +20,18 @@ module ItunesValidator
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def validate(receipt_data)
|
23
|
-
raise ParameterError unless receipt_data
|
23
|
+
raise ParameterError unless (receipt_data && !receipt_data.strip.empty?)
|
24
24
|
|
25
|
-
post_body = {}
|
26
|
-
post_body['
|
27
|
-
post_body['password'] = @shared_secret if @shared_secret
|
25
|
+
post_body = { 'receipt-data' => receipt_data }
|
26
|
+
post_body['password'] = @shared_secret if @shared_secret && !@shared_secret.strip.empty?
|
28
27
|
|
29
28
|
receipt_info = latest_receipt_info = nil
|
30
29
|
|
31
30
|
uri = URI(APPSTORE_VERIFY_URL_PRODUCTION)
|
32
31
|
begin
|
33
|
-
h = Net::HTTP::Proxy(*@proxy)
|
34
|
-
h
|
35
|
-
|
36
|
-
req = Net::HTTP::Post.new(uri.request_uri)
|
37
|
-
req['Accept'] = 'application/json'
|
38
|
-
req['Content-Type'] = 'application/json'
|
32
|
+
h = @proxy ? Net::HTTP::Proxy(*@proxy) : Net::HTTP
|
33
|
+
h.start(uri.host, uri.port, use_ssl: true) do |http|
|
34
|
+
req = Net::HTTP::Post.new(uri.request_uri, {'Accept' => 'application/json', 'Content-Type'=>'applications/json'})
|
39
35
|
req.body = post_body.to_json
|
40
36
|
|
41
37
|
response = http.request(req)
|
@@ -43,19 +39,19 @@ module ItunesValidator
|
|
43
39
|
response_body = JSON.parse(response.body)
|
44
40
|
|
45
41
|
case itunes_status = response_body['status'].to_i
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
when 0
|
43
|
+
receipt_info = response_body['receipt']
|
44
|
+
latest_receipt_info = response_body['latest_receipt_info']
|
45
|
+
else
|
46
|
+
raise ItunesValidationError.new(itunes_status)
|
51
47
|
end
|
52
48
|
end
|
53
49
|
rescue ItunesCommunicationError
|
54
50
|
rescue ItunesValidationError => e
|
55
51
|
case e.code
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
when 21007
|
53
|
+
uri = URI(APPSTORE_VERIFY_URL_SANDBOX)
|
54
|
+
retry
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
@@ -81,6 +81,12 @@ class TestItunesValidator < Test::Unit::TestCase
|
|
81
81
|
assert_raises(ItunesValidator::ParameterError) do
|
82
82
|
ItunesValidator.validate(nil)
|
83
83
|
end
|
84
|
+
assert_raises(ItunesValidator::ParameterError) do
|
85
|
+
ItunesValidator.validate('')
|
86
|
+
end
|
87
|
+
assert_raises(ItunesValidator::ParameterError) do
|
88
|
+
ItunesValidator.validate(' ')
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
92
|
def test_invalid_parameters_no_receipt
|
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.4.
|
4
|
+
version: 0.4.5
|
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-10-
|
11
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|