Class: ConditionFetch

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

Class Method Summary collapse

Class Method Details

.fetch_ios_apple(json_body, type_value) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ConditionFetch.rb', line 3

def self.fetch_ios_apple(json_body,type_value)

    #fetch content key
    @@track_name_key="trackName"
    @@track_id_key="trackId"
    @@niminum_os_version_key="minimumOsVersion"
    @@track_url_key="trackViewUrl"
    @@bundle_id_key="bundleId"
    @@version_key="version"
    @@price_key="price"
    @@kind_key="kind"
    isCondition=false
    
    final_apps=Array.new
    results_array=json_body["results"]
    results_array.each do |result|
        if result[@@kind_key]
          if type_value != nil
          if result[kind_key] == "software"
            support_array=result["supportedDevices"]
            if  support_array
                support_content= support_array.join
                puts support_content.upcase
                if support_content.upcase.include? type_value.upcase
                  app = self.parse_result(result)
                  
                  final_apps << app
                  
                end
            end
            elsif result[kind_key].upcase.include? type_value.upcase
                app = self.parse_result(result)

                final_apps << app
          end
           else
          app = self.parse_result(result)
                  
           final_apps << app
        end
        end
    end
    return final_apps
end

.parse_result(result) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ConditionFetch.rb', line 48

def  self.parse_result(result)

  track_name=result[@@track_name_key]
  track_id =result[@@track_id_key]
  track_nimi_os=result[@@niminum_os_version_key]
  track_url=result[@@track_url_key]
  track_bundle_id=result[@@bundle_id_key]
  track_version=result[@@version_key]
  track_price=result[@@price_key]

  app=Hash.new
  app[@@track_name_key]=track_name
  app[@@track_id_key]=track_id
  app[@@niminum_os_version_key]=track_nimi_os
  app[@@track_url_key]=track_url
  app[@@bundle_id_key]=track_bundle_id
  app[@@version_key]=track_version
  app[@@price_key]=track_price.to_s

  return app
  
end