Class: ResoWebApi::Client

Inherits:
BaseClient show all
Includes:
Resources
Defined in:
lib/reso_web_api/client.rb

Overview

Main class to run requests against a RESO Web API server.

Constant Summary

Constants included from Resources

Resources::STANDARD_RESOURCES

Constants inherited from BaseClient

BaseClient::USER_AGENT

Instance Method Summary collapse

Methods included from Resources

#resources

Constructor Details

#initialize(options = {}) ⇒ Client


12
13
14
15
# File 'lib/reso_web_api/client.rb', line 12

def initialize(options = {})
  super(options)
  ensure_valid_auth_strategy!
end

Instance Method Details

#connection(&block) ⇒ Faraday::Connection

Return the Faraday::Connection object for this client. Yields the connection object being constructed (for customzing middleware).


26
27
28
29
30
31
# File 'lib/reso_web_api/client.rb', line 26

def connection(&block)
  super do |conn|
    conn.use Authentication::Middleware, @auth
    yield conn if block_given?
  end
end

#headersHash

Headers to be send along with requests


19
20
21
# File 'lib/reso_web_api/client.rb', line 19

def headers
  super.merge({ accept: 'application/json' })
end

#serviceOData4::Service

Returns a proxied OData4::Service that attempts to ensure a properly authenticated and authorized connection


36
37
38
# File 'lib/reso_web_api/client.rb', line 36

def service
  @service ||= OData4::Service.new(connection)
end