Class: Auciel

Inherits:
Object
  • Object
show all
Includes:
HotEndpoints, ItemEndpoints, PriceEndpoints, SearchEndpoints, WaitlistEndpoints
Defined in:
lib/auciel.rb

Overview

main class for auciel

Constant Summary

Constants included from WaitlistEndpoints

WaitlistEndpoints::GET_WAITLIST_ITEMS

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

Constants included from HotEndpoints

HotEndpoints::GET_HOT_ITEMS_LIST

Constants included from PriceEndpoints

PriceEndpoints::GET_PRICE_LIST_BY_ID

Constants included from SearchEndpoints

SearchEndpoints::SEARCH_ITEM_BY_TEXT

Constants included from ItemEndpoints

ItemEndpoints::GET_ITEM_BY_CATEGORY, ItemEndpoints::GET_ITEM_BY_ID

Instance Method Summary collapse

Methods included from WaitlistEndpoints

respond_if_available, send_post_request, waitlist_items

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

Methods included from HotEndpoints

hot_items, respond_if_available, send_post_request

Methods included from PriceEndpoints

price_list_by_id, respond_if_available, send_post_request

Methods included from SearchEndpoints

respond_if_available, search_item_by_text, send_post_request

Methods included from ItemEndpoints

item_by_id, items_by_category, respond_if_available, send_post_request

Constructor Details

#initialize(port = 8888) ⇒ Auciel

Returns a new instance of Auciel.



18
19
20
21
# File 'lib/auciel.rb', line 18

def initialize(port = 8888)
  @server = Tsurezure.new port
  register_endpoints
end

Instance Method Details

#all_endpointsObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/auciel.rb', line 52

def all_endpoints
  {
    get_item_by_id: ItemEndpoints::GET_ITEM_BY_ID,
    get_item_by_category: ItemEndpoints::GET_ITEM_BY_CATEGORY,
    search_item_by_text: SearchEndpoints::SEARCH_ITEM_BY_TEXT,
    get_price_list_by_id: PriceEndpoints::GET_PRICE_LIST_BY_ID,
    get_hot_items_list: HotEndpoints::GET_HOT_ITEMS_LIST,
    get_waitlist_items: WaitlistEndpoints::GET_WAITLIST_ITEMS
  }
end

#listenObject



44
45
46
47
48
49
50
# File 'lib/auciel.rb', line 44

def listen
  @server.listen lambda { |opts|
    puts "listening on port #{opts[:port]}!"
  }
rescue Interrupt
  puts '[auciel] shutting down.'
end

#register_endpointsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/auciel.rb', line 23

def register_endpoints
  # /item/:id
  @server.register(*ItemEndpoints::GET_ITEM_BY_ID)

  # /item/:cat/:sub
  @server.register(*ItemEndpoints::GET_ITEM_BY_CATEGORY)

  # /search
  # requires a urlencoded string
  @server.register(*SearchEndpoints::SEARCH_ITEM_BY_TEXT)

  # /prices/:id
  @server.register(*PriceEndpoints::GET_PRICE_LIST_BY_ID)

  # /hot
  @server.register(*HotEndpoints::GET_HOT_ITEMS_LIST)

  # /waitlist
  @server.register(*WaitlistEndpoints::GET_WAITLIST_ITEMS)
end