Class: RakutenApi::ItemSearch::Response
- Inherits:
-
Base::Response
- Object
- Base::Response
- RakutenApi::ItemSearch::Response
- Defined in:
- lib/rakuten_api/item_search/response.rb
Instance Attribute Summary collapse
-
#carrier ⇒ Object
readonly
Returns the value of attribute carrier.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
Attributes inherited from Base::Response
Instance Method Summary collapse
- #get_next_page ⇒ Object
- #get_prev_page ⇒ Object
-
#initialize(faraday_response = nil, params = nil) ⇒ Response
constructor
A new instance of Response.
- #new_request ⇒ Object
- #next? ⇒ Boolean
- #parse_body(data) ⇒ Object
- #prev? ⇒ Boolean
- #simple_mapping ⇒ Object
Methods inherited from Base::Response
#error?, #error_message, #success?
Constructor Details
#initialize(faraday_response = nil, params = nil) ⇒ Response
Returns a new instance of Response.
16 17 18 19 20 |
# File 'lib/rakuten_api/item_search/response.rb', line 16 def initialize(faraday_response = nil, params = nil) super(faraday_response) parse_body(@body) @request_params = params end |
Instance Attribute Details
#carrier ⇒ Object (readonly)
Returns the value of attribute carrier.
12 13 14 |
# File 'lib/rakuten_api/item_search/response.rb', line 12 def carrier @carrier end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
9 10 11 |
# File 'lib/rakuten_api/item_search/response.rb', line 9 def count @count end |
#first ⇒ Object (readonly)
Returns the value of attribute first.
10 11 12 |
# File 'lib/rakuten_api/item_search/response.rb', line 10 def first @first end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
8 9 10 |
# File 'lib/rakuten_api/item_search/response.rb', line 8 def hits @hits end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
11 12 13 |
# File 'lib/rakuten_api/item_search/response.rb', line 11 def last @last end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
14 15 16 |
# File 'lib/rakuten_api/item_search/response.rb', line 14 def page @page end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
13 14 15 |
# File 'lib/rakuten_api/item_search/response.rb', line 13 def page_count @page_count end |
Instance Method Details
#get_next_page ⇒ Object
30 31 32 33 34 |
# File 'lib/rakuten_api/item_search/response.rb', line 30 def get_next_page nil unless next? @request_params[:page] = @page + 1 new_request end |
#get_prev_page ⇒ Object
36 37 38 39 40 |
# File 'lib/rakuten_api/item_search/response.rb', line 36 def get_prev_page nil unless prev? @request_params[:page] = @page - 1 new_request end |
#new_request ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/rakuten_api/item_search/response.rb', line 42 def new_request Client.new do |params| @request_params.each_pair do |k, v| params.add_param k, v end end.request end |
#next? ⇒ Boolean
22 23 24 |
# File 'lib/rakuten_api/item_search/response.rb', line 22 def next? @page < @page_count end |
#parse_body(data) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/rakuten_api/item_search/response.rb', line 50 def parse_body(data) @count = data['count'] @page = data['page'] @first = data['first'] @last = data['last'] @hits = data['hits'] @carrier = data['carrier'] @page_count = data['pageCount'] end |
#prev? ⇒ Boolean
26 27 28 |
# File 'lib/rakuten_api/item_search/response.rb', line 26 def prev? @page > 1 end |