Class: Stew::XmlClient

Inherits:
Object
  • Object
show all
Defined in:
lib/stew/xml_client.rb

Overview

Client for accessing the steam community XML api

Defined Under Namespace

Classes: ObjectNotFoundError, ServiceUnavailableError

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ XmlClient

Returns a new instance of XmlClient.



5
6
7
# File 'lib/stew/xml_client.rb', line 5

def initialize(uri)
  @connection = XmlClient.connection(uri)
end

Instance Method Details

#get(path) ⇒ Object

The Steam community is notorious for responding with error 503 Retries up to 10 times for the same request to compensate for this



11
12
13
14
15
16
17
18
# File 'lib/stew/xml_client.rb', line 11

def get(path)
  10.times do
    response = request(path)
    return XmlClient.parse_response(response.body) unless response.status == 503
    sleep 0.5
  end
  raise ServiceUnavailableError
end