Class: FreshdeskAPI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/freshdesk_api/configuration.rb

Overview

Holds the configuration options for the client and connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



32
33
34
# File 'lib/freshdesk_api/configuration.rb', line 32

def initialize
  @client_options = {}
end

Instance Attribute Details

#allow_httpBoolean

Returns Whether to allow non-HTTPS connections for development purposes.

Returns:

  • (Boolean)

    Whether to allow non-HTTPS connections for development purposes.



25
26
27
# File 'lib/freshdesk_api/configuration.rb', line 25

def allow_http
  @allow_http
end

#apitokenString

Returns The basic auth token.

Returns:

  • (String)

    The basic auth token.



13
14
15
# File 'lib/freshdesk_api/configuration.rb', line 13

def apitoken
  @apitoken
end

#base_urlString

Returns The API url. Must be https unless #allow_http is set.

Returns:

  • (String)

    The API url. Must be https unless #allow_http is set.



16
17
18
# File 'lib/freshdesk_api/configuration.rb', line 16

def base_url
  @base_url
end

#client_optionsHash

Returns Client configurations.

Returns:

  • (Hash)

    Client configurations



22
23
24
# File 'lib/freshdesk_api/configuration.rb', line 22

def client_options
  @client_options
end

#loggerLogger

Returns Logger to use when logging requests.

Returns:

  • (Logger)

    Logger to use when logging requests.



19
20
21
# File 'lib/freshdesk_api/configuration.rb', line 19

def logger
  @logger
end

#open_timeoutObject

:read_timeout and :open_timeout are how long to wait for a response and to open a connection, in seconds. Pass nil to disable the timeout.



29
30
31
# File 'lib/freshdesk_api/configuration.rb', line 29

def open_timeout
  @open_timeout
end

#passwordString

Returns The basic auth password.

Returns:

  • (String)

    The basic auth password.



10
11
12
# File 'lib/freshdesk_api/configuration.rb', line 10

def password
  @password
end

#read_timeoutObject

Returns the value of attribute read_timeout.



30
31
32
# File 'lib/freshdesk_api/configuration.rb', line 30

def read_timeout
  @read_timeout
end

#usernameString

Returns The basic auth username.

Returns:

  • (String)

    The basic auth username



7
8
9
# File 'lib/freshdesk_api/configuration.rb', line 7

def username
  @username
end

Instance Method Details

#optionsHash

Sets accept and user_agent headers, and url

Returns:

  • (Hash)

    RestClient-formatted hash of options.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/freshdesk_api/configuration.rb', line 39

def options
  {
    headers: {
      accept: :json,
      content_type: :json,
      accept_encoding: 'gzip ,deflate',
      user_agent: "FreshdeskAPI API #{FreshdeskAPI::VERSION}"
    },
    read_timeout: nil,
    open_timeout: nil,
    base_url: @base_url
  }.merge(client_options)
end