Class: WarrantyCheck::APPLE

Inherits:
BaseVendor show all
Defined in:
lib/vendors/apple_vendor.rb

Instance Attribute Summary

Attributes inherited from BaseVendor

#dom, #html, #warranties

Instance Method Summary collapse

Methods inherited from BaseVendor

#http_method, #initialize, #uri, #url

Constructor Details

This class inherits a constructor from WarrantyCheck::BaseVendor

Instance Method Details

#checkObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vendors/apple_vendor.rb', line 17

def check
  @warranties = []
  
  if json["ERROR_CODE"].nil?

    @warranties << {
      :description => sprintf("%s - %s", json["PROD_DESCR"].strip, json["PH_SUPPORT_COVERAGE_SUBHEADER"].split(':').first.strip),
      :expired => json["PH_SUPPORT_COVERAGE_SUBHEADER"].split(':').last.strip == "Expired",
      :expire_date => (" " * 10),
      :details => json
    }
  
    @warranties << {
      :description => sprintf("%s - %s", json["PROD_DESCR"].strip, json["HW_REPAIR_COVERAGE_SUBHEADER"].split(':').first.strip),
      :expired => json["HW_REPAIR_COVERAGE_SUBHEADER"].split(':').last.strip == "Expired",
      :expire_date => (" " * 10),
      :details => json
    }
    
  end
end

#jsonObject



13
14
15
# File 'lib/vendors/apple_vendor.rb', line 13

def json
  @json ||= JSON.parse(html.slice(5, html.length - 6))
end

#service_base_urlObject



5
6
7
# File 'lib/vendors/apple_vendor.rb', line 5

def service_base_url
  "https://selfsolve.apple.com"
end

#service_uriObject



9
10
11
# File 'lib/vendors/apple_vendor.rb', line 9

def service_uri
  "/warrantyChecker.do?sn=%s"
end