Module: WrAPI

Extended by:
Configuration, RespondTo
Defined in:
lib/wrapi.rb,
lib/wrapi/api.rb,
lib/wrapi/entity.rb,
lib/wrapi/request.rb,
lib/wrapi/version.rb,
lib/wrapi/connection.rb,
lib/wrapi/pagination.rb,
lib/wrapi/respond_to.rb,
lib/wrapi/configuration.rb,
lib/wrapi/authentication.rb,
lib/wrapi/middleware/rate_throttle_middleware.rb

Overview

This module defines constants and methods related to the configuration of the WrAPI. It provides a set of default configuration options and allows these options to be overridden.

Constants:

  • VALID_OPTIONS_KEYS: An array of valid keys in the options hash when configuring a WrAPI::API.

  • DEFAULT_CONNECTION_OPTIONS: Default connection options (empty hash).

  • DEFAULT_FORMAT: Default response format (:json).

  • DEFAULT_PAGE_SIZE: Default page size for paged responses (500).

  • DEFAULT_USER_AGENT: Default user agent string.

  • DEFAULT_PAGINATION: Default pagination class.

Attributes:

  • access_token: Access token for authentication.

  • token_type: Type of the token.

  • refresh_token: Token used to refresh the access token.

  • token_expires: Expiration time of the token.

  • client_id: Client ID for authentication.

  • client_secret: Client secret for authentication.

  • connection_options: Options for the connection.

  • username: Username for authentication.

  • password: Password for authentication.

  • endpoint: API endpoint.

  • logger: Logger instance.

  • format: Response format.

  • page_size: Page size for paged responses.

  • user_agent: User agent string.

  • pagination_class: Pagination class.

Methods:

  • self.extended(base): Sets all configuration options to their default values when the module is extended.

  • configure: Allows configuration options to be set in a block.

  • options: Creates a hash of options and their values.

  • reset: Resets all configuration options to their default values.

Defined Under Namespace

Modules: Authentication, Configuration, Connection, Request, RequestPagination, RespondTo Classes: API, RateThrottleMiddleware

Constant Summary collapse

VERSION =
'0.5.1'

Constants included from Configuration

Configuration::DEFAULT_CONNECTION_OPTIONS, Configuration::DEFAULT_FORMAT, Configuration::DEFAULT_PAGE_SIZE, Configuration::DEFAULT_PAGINATION, Configuration::DEFAULT_TOKEN_TYPE, Configuration::DEFAULT_USER_AGENT, Configuration::VALID_OPTIONS_KEYS

Class Method Summary collapse

Methods included from RespondTo

method_missing, respond_to?

Methods included from Configuration

configure, extended, options, reset

Class Method Details

.client(_options = {}) ⇒ Object

Abstract method should be overridden

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/wrapi.rb', line 27

def self.client(_options = {})
  raise NotImplementedError, 'Abstract method self.client must implemented when including ResponTo'
end

.resetObject

set/override defaults



32
33
34
35
# File 'lib/wrapi.rb', line 32

def self.reset
  super
  self.user_agent = "Ruby API wrapper #{WrAPI::VERSION}"
end