Module: HelpScoutDocs::Default

Defined in:
lib/help_scout_docs/default.rb

Constant Summary collapse

ENDPOINT =

Faraday.default_adapter = :net_http_persistent

'https://docsapi.helpscout.net/v1/'
MIDDLEWARE =
Faraday::Builder.new do |builder|
  # Encode request params as "www-form-urlencoded"
  builder.use Faraday::Request::UrlEncoded
  # Parse JSON response bodies
  builder.use HelpScoutDocs::Response::ParseJson#, content_type: /\bjson$/
  # Use Faraday logger
  builder.use Faraday::Response::Logger if ENV['DEBUG']
  # Set Faraday's HTTP adapter
  builder.adapter Faraday.default_adapter
end

Class Method Summary collapse

Class Method Details

.api_keyString

Returns:

  • (String)


31
32
33
# File 'lib/help_scout_docs/default.rb', line 31

def api_key
  ENV['HELP_SCOUT_DOCS_API_KEY']
end

.api_passwordString

Returns:

  • (String)


36
37
38
# File 'lib/help_scout_docs/default.rb', line 36

def api_password
  ENV['HELP_SCOUT_DOCS_API_PASSWORD'] || "X"
end

.endpointString

Returns:

  • (String)


41
42
43
# File 'lib/help_scout_docs/default.rb', line 41

def endpoint
  ENDPOINT
end

.middlewareFaraday::Builder

Note:

Faraday’s middleware stack implementation is comparable to that of Rack middleware. The order of middleware is important: the first middleware on the list wraps all others, while the last middleware is the innermost one.



49
50
51
# File 'lib/help_scout_docs/default.rb', line 49

def middleware
  MIDDLEWARE
end

.optionsHash

Returns:

  • (Hash)


26
27
28
# File 'lib/help_scout_docs/default.rb', line 26

def options
  Hash[HelpScoutDocs::Configurable.keys.map{|key| [key, send(key)]}]
end