Class: UTApi::Client
- Inherits:
-
Object
- Object
- UTApi::Client
- Defined in:
- lib/utapi/client.rb
Instance Attribute Summary collapse
-
#logged_in ⇒ Object
readonly
Returns the value of attribute logged_in.
Instance Method Summary collapse
- #auction_status(ids) ⇒ Object
- #bid(trade_id, value) ⇒ Object
- #delete_from_trade_pile(trade_id) ⇒ Object
- #delete_from_watch_list(*trade_ids) ⇒ Object
- #get_credits ⇒ Object
-
#initialize(email, password, hash, platform) ⇒ Client
constructor
A new instance of Client.
- #list_item(item_id, start_price, bin_price, duration) ⇒ Object
- #login ⇒ Object
- #move_card(item_id, pile) ⇒ Object
- #search(params) ⇒ Object
- #trade_pile ⇒ Object
- #unassigned_items ⇒ Object
- #watch_list ⇒ Object
Constructor Details
Instance Attribute Details
#logged_in ⇒ Object (readonly)
Returns the value of attribute logged_in.
12 13 14 |
# File 'lib/utapi/client.rb', line 12 def logged_in @logged_in end |
Instance Method Details
#auction_status(ids) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/utapi/client.rb', line 37 def auction_status(ids) action = 'trade/status?' + Util.encode_query_string(tradeIds: ids.join(',')) do_request(action).tap do |response| raise ApiCallFailed, "response has no auctionInfo: #{response}" unless response.is_a?(Hash) and response.has_key?('auctionInfo') end end |
#bid(trade_id, value) ⇒ Object
47 48 49 50 |
# File 'lib/utapi/client.rb', line 47 def bid(trade_id, value) response = do_request("trade/#{trade_id}/bid", :put, {bid: value}) response.is_a?(Hash) and response.has_key?('auctionInfo') end |
#delete_from_trade_pile(trade_id) ⇒ Object
90 91 92 |
# File 'lib/utapi/client.rb', line 90 def delete_from_trade_pile(trade_id) do_request("trade/#{trade_id}", :delete) end |
#delete_from_watch_list(*trade_ids) ⇒ Object
94 95 96 97 |
# File 'lib/utapi/client.rb', line 94 def delete_from_watch_list(*trade_ids) action = 'watchlist?' + Util.encode_query_string(tradeId: trade_ids.join(',')) do_request(action, :delete) end |
#get_credits ⇒ Object
99 100 101 |
# File 'lib/utapi/client.rb', line 99 def get_credits do_request('user/credits') end |
#list_item(item_id, start_price, bin_price, duration) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/utapi/client.rb', line 53 def list_item(item_id, start_price, bin_price, duration) response = do_request('auctionhouse', :post, { startingBid: start_price, duration: duration, itemData: { id: item_id }, buyNowPrice: bin_price }) response.is_a?(Hash) and response.has_key?('id') end |
#login ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/utapi/client.rb', line 19 def login @authorization = rescue LoginError false else true end |
#move_card(item_id, pile) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/utapi/client.rb', line 67 def move_card(item_id, pile) response = do_request('item', :put, { itemData: [{ id: item_id, pile: pile }] }) response.is_a?(Hash) and response.has_key?('itemData') and response['itemData'][0]['success'] end |
#search(params) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/utapi/client.rb', line 27 def search(params) action = 'transfermarket?' + Util.encode_query_string(params) do_request(action).tap do |response| raise ApiCallFailed, "response has no auctionInfo: #{response}" unless response.is_a?(Hash) and response.has_key?('auctionInfo') end end |
#trade_pile ⇒ Object
76 77 78 79 80 |
# File 'lib/utapi/client.rb', line 76 def trade_pile do_request('tradepile', :get).tap do |response| raise ApiCallFailed, "Cannot get trade pile, response: #{response}" unless response.is_a?(Hash) and response.has_key?('auctionInfo') end end |
#unassigned_items ⇒ Object
86 87 88 |
# File 'lib/utapi/client.rb', line 86 def unassigned_items do_request('purchased/items', :get) end |
#watch_list ⇒ Object
82 83 84 |
# File 'lib/utapi/client.rb', line 82 def watch_list do_request('watchlist', :get) end |