Module: TradeAPI
- Included in:
- Handler
- Defined in:
- lib/IEconService.rb
Instance Method Summary collapse
- #accept_trade_offer(trade_offer_id) ⇒ Object
- #cancel_trade_offer(trade_offer_id) ⇒ Object
- #decline_trade_offer(trade_offer_id) ⇒ Object
- #get_trade_offer(trade_offer_id) ⇒ Object
- #get_trade_offers(time = "") ⇒ Object
Instance Method Details
#accept_trade_offer(trade_offer_id) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/IEconService.rb', line 36 def accept_trade_offer(trade_offer_id) raise "You are not logged in " if @loggedin == false trade = get_trade_offer(trade_offer_id) trade_offer_state = trade["offer"]['trade_offer_state'] raise "Cannot accept trade #{trade_offer_id}" if trade_offer_state != OfferState::Active partner = trade["offer"]['accountid_other'] session_id = () accept_url = "https://steamcommunity.com" + '/tradeoffer/' + trade_offer_id + '/accept' params = {'sessionid'=> session_id, 'tradeofferid'=> trade_offer_id, 'serverid'=> '1', 'partner'=> partner, 'captcha'=> ''} headers = {'Referer'=> "https://steamcommunity.com/tradeoffer/#{trade_offer_id}"} response = JSON.parse(@session.post(accept_url, params, headers).content) output "trade offer confirmed" if response.key?('needs_mobile_confirmation') == true re = send_trade_allow_request(trade_offer_id) output "trade offer confirmed" return re end return response end |
#cancel_trade_offer(trade_offer_id) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/IEconService.rb', line 78 def cancel_trade_offer(trade_offer_id) raise "have no API_key, cannot cancel the trade offer" if @api_key == nil params = {'key'=> @api_key, 'tradeofferid'=> trade_offer_id} return JSON.parse(api_call('POST', 'IEconService', 'CancelTradeOffer', 'v1', params)) end |
#decline_trade_offer(trade_offer_id) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/IEconService.rb', line 71 def decline_trade_offer(trade_offer_id) raise "have no API_key, cannot decline the trade offer" if @api_key == nil params = {'key'=> @api_key, 'tradeofferid'=> trade_offer_id} return JSON.parse(api_call('POST', 'IEconService', 'DeclineTradeOffer', 'v1', params)) end |
#get_trade_offer(trade_offer_id) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/IEconService.rb', line 62 def get_trade_offer(trade_offer_id) raise "have no API_key, cannot get the trade offer" if @api_key == nil params = {'key' => @api_key, 'tradeofferid'=>trade_offer_id, 'language'=> 'english'} response = JSON.parse(api_call('GET', 'IEconService', 'GetTradeOffer', 'v1', params)) return response["response"] end |
#get_trade_offers(time = "") ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/IEconService.rb', line 22 def get_trade_offers(time = "") raise "have no API_key, cannot get trade offers" if @api_key == nil params = {'key'=> @api_key, 'get_sent_offers'=> 1, 'get_received_offers'=> 1, 'get_descriptions'=> 1, 'language'=> 'english', 'active_only'=> 1, 'historical_only'=> 0, 'time_historical_cutoff'=> time.to_i} data = JSON.parse(api_call('GET', 'IEconService', 'GetTradeOffers', 'v1', params))["response"] return data end |