apple_warranty_check 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apple_warranty_check/process.rb +20 -9
- data/lib/apple_warranty_check/version.rb +1 -1
- data/spec/apple_warranty_check_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28cf9938788f73aecbcd2157555a7b233068e150
|
4
|
+
data.tar.gz: 21886b40f483d2966c2c14a224db1734a0368eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628e17aea374f37e996fcee3568ac240d8af740e28de703cbb7018a8b0a6e79224fc1bdee02e7ee5fd42c36ccdd2942e06a6bb83b21aa69245cc896fa6afc4b0
|
7
|
+
data.tar.gz: c912ec837824e5ce3828b8dfbafe25dc97dae411275f7de62f98c1876dea9c4d2bea36a9f645eca0ca10044297c686f028c151267ca6dda6e00b17d9308fb38c
|
@@ -17,6 +17,8 @@ module AppleWarrantyCheck
|
|
17
17
|
|
18
18
|
ERR_RESP_REGEXP = /var errorMsg = '(.*)';/
|
19
19
|
|
20
|
+
NOT_REGISTERED_REGEXP = /window.location.href =(.*);/.freeze
|
21
|
+
|
20
22
|
PRODUCT_INFO_KEYS = %i(prodImgUrl prodDesc isIMEINum APIMEINum isProdId prodId sn).freeze
|
21
23
|
PH_SUPPORT_INFO_KEYS = %i(hasPhoneSuppCov phoneSuppSubHeader phoneSuppCovTxt phoneSuppLink).freeze
|
22
24
|
HW_SUPPORT_INFO_KEYS = %i(hasHWSuppCov HWRepairSubHead HWSuppCovTxt HWSuppLnk hasCLMessageCode).freeze
|
@@ -32,15 +34,15 @@ module AppleWarrantyCheck
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def parse_body(html)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
return error_response(html) unless ERR_RESP_REGEXP.match(html).nil?
|
38
|
+
|
39
|
+
return not_registered unless NOT_REGISTERED_REGEXP.match(html).nil?
|
40
|
+
|
41
|
+
{
|
42
|
+
product_info: get_product_info(html),
|
43
|
+
phone_support: get_phone_support_info(html),
|
44
|
+
hw_support: get_hw_support_info(html)
|
45
|
+
}
|
44
46
|
end
|
45
47
|
|
46
48
|
def get_phone_support_info(html)
|
@@ -78,5 +80,14 @@ module AppleWarrantyCheck
|
|
78
80
|
expiration_date: (EXP_DATE.match(match_data[3])[1] rescue nil)
|
79
81
|
)
|
80
82
|
end
|
83
|
+
|
84
|
+
def error_response(html)
|
85
|
+
{ error: ERR_RESP_REGEXP.match(html)[1] }
|
86
|
+
end
|
87
|
+
|
88
|
+
# TODO follow redirect to get live apple message
|
89
|
+
def not_registered
|
90
|
+
{ error: "Please validate your product's purchase date. Apple is unable to provide information about your service coverage." }
|
91
|
+
end
|
81
92
|
end
|
82
93
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe AppleWarrantyCheck do
|
4
4
|
it 'has a version number' do
|
5
|
-
expect(AppleWarrantyCheck::VERSION).to eq '0.0.
|
5
|
+
expect(AppleWarrantyCheck::VERSION).to eq '0.0.2'
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:valid_warranty_html) { File.open('spec/files/valid_warranty_resp.html').read }
|