module Remind101::Client::Connection

Public Instance Methods

builder()
Alias for: middleware
middleware() click to toggle source

Public: The Faraday::Builder instance used for the middleware stack. This can be used to insert a custom middleware.

Examples

# Add the instrumentation middleware for Rails.
client.middleware.use FaradayMiddleware::Instrumentation

Returns the Faraday::Builder for the Faraday connection.

# File lib/remind101/client/connection.rb, line 22
def middleware
  connection.builder
end
Also aliased as: builder

Private Instance Methods

api_path(path) click to toggle source
# File lib/remind101/client/connection.rb, line 29
def api_path(path)
  "/#{configuration.version}#{path}"
end
configuration() click to toggle source
# File lib/remind101/client/connection.rb, line 55
def configuration
  Remind101.configuration
end
connection() click to toggle source

Internal: Internal faraday connection where all requests go through

# File lib/remind101/client/connection.rb, line 34
def connection
  @connection ||= Faraday.new(configuration.endpoint) do |builder|
    # Raise exceptions for HTTP error status's
    builder.use      Remind101::Middleware::RaiseError
    # Add auth_token to query string.
    builder.request  :oauth2, auth_token, param_name: 'auth_token'
    # Turn the response into a Hashie::Mash.
    builder.response :mashify
    # Parse ISO 8601 dates.
    builder.use      FaradayMiddleware::ParseDates
    # Converts the request into JSON.
    builder.request  :json
    # Parses returned JSON response into a hash.
    builder.response :json, content_type: /\bjson$/
    # Follows 30x redirects.
    builder.response :follow_redirects

    builder.adapter  configuration.adapter
  end
end