Class: KpApi::Category

Inherits:
Agent
  • Object
show all
Defined in:
lib/kp_api/category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Agent

#arr_data, #bool_data, #current_page, #data, #data2, #dn, #film_hash, #int_data, #json, #json2, #min_data, #next_page, #page_count, #people_hash, #s2a, #status, #status2, #str_data, #time_data, #url_data, #year_data

Constructor Details

#initialize(country_id = 1) ⇒ Category

Returns a new instance of Category.



5
6
7
8
9
10
11
12
13
14
# File 'lib/kp_api/category.rb', line 5

def initialize(country_id=1)
  @country_id = country_id
  @url  = "#{DOMAINS[:api]}#{METHODS[:navigator_filters  ][:method]}?countryID=#{country_id}"
  @url2 = "#{DOMAINS[:api]}#{METHODS[:get_all_cities_view][:method]}?countryID=#{country_id}"
  @json = json

  unless status
    raise ApiError.new(@json[:message], @json[:data])
  end
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/kp_api/category.rb', line 3

def url
  @url
end

Instance Method Details

#citiesObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kp_api/category.rb', line 24

def cities
  json2

  if @json2['countryName'].nil?
    raise ApiError.new(@json2[:message], @json2[:data])
  else
    @json2['cityData'].map{|city|
      {
        id:   int_data(String, city["cityID"   ]),
        name: str_data(String, city["cityName" ])
      }
    }
  end
end

#countriesObject



20
21
22
# File 'lib/kp_api/category.rb', line 20

def countries
  h(@json['country'])
end

#genresObject



16
17
18
# File 'lib/kp_api/category.rb', line 16

def genres
  h(@json['genre'])
end