Class: Steamworks::Connection
- Inherits:
-
Object
- Object
- Steamworks::Connection
- Defined in:
- lib/steamworks/connection.rb
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(gateway: :partner) ⇒ Connection
constructor
A new instance of Connection.
- #post(path) ⇒ Object
Constructor Details
#initialize(gateway: :partner) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 9 10 11 12 |
# File 'lib/steamworks/connection.rb', line 5 def initialize(gateway: :partner) raise ArgumentError, "Invalid gateway: #{gateway}" unless %i[partner public].include?(gateway) @connection = Faraday.new( url: gateway == :partner ? "https://partner.steam-api.com" : "https://api.steampowered.com", headers: { "Content-Type" => "application/x-www-form-urlencoded" } ) end |
Instance Method Details
#get(path) ⇒ Object
14 15 16 17 18 |
# File 'lib/steamworks/connection.rb', line 14 def get(path) @connection.get(path) do |req| yield(req) if block_given? end end |
#post(path) ⇒ Object
20 21 22 23 24 |
# File 'lib/steamworks/connection.rb', line 20 def post(path) @connection.post(path) do |req| yield(req) if block_given? end end |