Module: WaitlistEndpoints

Includes:
Constants, FormData, ResponseFormatter
Included in:
Auciel
Defined in:
lib/endpoints/waitlist.rb

Overview

get a list of items in the registration queue

Constant Summary collapse

GET_WAITLIST_ITEMS =
{
  method: 'get',
  path: '/waitlist',
  responder: waitlist_items,
  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

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

.respond_if_available(res) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/endpoints/waitlist.rb', line 20

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) ⇒ Object



13
14
15
16
17
18
# File 'lib/endpoints/waitlist.rb', line 13

def self.send_post_request(uri)
  HTTParty.post(
    uri,
    headers: Constants::REQUEST_OPTS[:headers]
  )
end

.waitlist_itemsObject



29
30
31
32
33
34
35
36
# File 'lib/endpoints/waitlist.rb', line 29

def self.waitlist_items
  lambda do |_req|
    uri = URI "#{Constants::ROOT_URL}#{Constants::MARKET_WAIT_LIST}"
    res = send_post_request uri

    ResponseFormatter.format_waitlist_response(respond_if_available(res))
  end
end