Module: PriceEndpoints
- Includes:
- Constants, FormData, ResponseFormatter
- Included in:
- Auciel
- Defined in:
- lib/endpoints/prices.rb
Overview
get price list by id and name, and other price-related endpoints
Constant Summary collapse
- GET_PRICE_LIST_BY_ID =
{ method: 'get', path: '/prices/:id', responder: price_list_by_id, opts: { content_type: 'application/json' } }.values.freeze
Constants included from ApiErrors
ApiErrors::UNEXPECTED_BLACK_DESERT_RESPONSE
Constants included from Constants
Constants::COOKIE, Constants::MARKET_HOT_LIST, Constants::MARKET_SEARCH_LIST, Constants::MARKET_SELL_BUY_INFO, Constants::MARKET_SUB_LIST, Constants::MARKET_WAIT_LIST, Constants::REQUEST_OPTS, Constants::ROOT_URL, Constants::RVT, Constants::WORLD_MARKET_LIST
Class Method Summary collapse
- .price_list_by_id ⇒ Object
- .respond_if_available(res) ⇒ Object
- .send_post_request(uri, data) ⇒ Object
Methods included from ResponseFormatter
format_cat_response, format_hot_response, format_item_response, format_price_list_response, format_search_response, format_waitlist_response, try_error
Methods included from FormData
item_by_cat_data, item_by_id_data, price_list_data, search_item_by_text_data
Class Method Details
.price_list_by_id ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/endpoints/prices.rb', line 45 def self.price_list_by_id lambda do |req| item_id = req[:vars]['id'] uri = URI "#{Constants::ROOT_URL}#{Constants::MARKET_SELL_BUY_INFO}" form = FormData.price_list_data item_id res = send_post_request uri, form ResponseFormatter.format_price_list_response(respond_if_available(res)) end end |
.respond_if_available(res) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/endpoints/prices.rb', line 36 def self.respond_if_available(res) return res.body if res.body { error: 'invalid response from the black desert api.', response: res }.to_json end |
.send_post_request(uri, data) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/endpoints/prices.rb', line 26 def self.send_post_request(uri, data) uri_params = URI.encode_www_form data HTTParty.post( uri, body: uri_params, headers: Constants::REQUEST_OPTS[:headers] ) end |