Class: RakutenApi::ItemRanking::Response
- Inherits:
-
Base::Response
- Object
- Base::Response
- RakutenApi::ItemRanking::Response
- Defined in:
- lib/rakuten_api/item_ranking/response.rb
Instance Attribute Summary collapse
-
#last_build_date ⇒ Object
readonly
Returns the value of attribute last_build_date.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Attributes inherited from Base::Response
Instance Method Summary collapse
-
#initialize(faraday_response = nil, params = {}) ⇒ Response
constructor
A new instance of Response.
- #new_request ⇒ Object
- #next_ranking ⇒ Object
- #parse_body ⇒ Object
- #prev? ⇒ Boolean
- #prev_ranking ⇒ Object
- #simple_mapping ⇒ Object
Methods inherited from Base::Response
#error?, #error_message, #success?
Constructor Details
#initialize(faraday_response = nil, params = {}) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 10 def initialize(faraday_response = nil, params = {}) super(faraday_response) @request_params = params parse_body end |
Instance Attribute Details
#last_build_date ⇒ Object (readonly)
Returns the value of attribute last_build_date.
7 8 9 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 7 def last_build_date @last_build_date end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
8 9 10 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 8 def page @page end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 6 def title @title end |
Instance Method Details
#new_request ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 31 def new_request Client.new do |params| @request_params.each_pair do |k, v| params.add_param k, v end end.request end |
#next_ranking ⇒ Object
16 17 18 19 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 16 def next_ranking @request_params['page'] = @page + 1 new_request end |
#parse_body ⇒ Object
39 40 41 42 43 44 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 39 def parse_body @title = @body['title'] @last_build_date = DateTime.rfc2822(@body['lastBuildDate']) rescue nil @page = @request_params['page'] if @request_params.is_a? Hash @page ||= 1 end |
#prev? ⇒ Boolean
21 22 23 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 21 def prev? @page > 1 end |
#prev_ranking ⇒ Object
25 26 27 28 29 |
# File 'lib/rakuten_api/item_ranking/response.rb', line 25 def prev_ranking return nil unless prev? @request_params['page'] = @page - 1 new_request end |