Class: WhatsappSdk::Configuration

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

Overview

This module allows client instantiating the client as a singleton like the following example: WhatsappSdk.configure do |config|

config.access_token = ACCESS_TOKEN
config.api_version = API_VERSION

end

The gem have access to the client through WhatsappSdk.configuration.client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token = "", api_version = Api::ApiConfiguration::DEFAULT_API_VERSION, logger = nil, logger_options = {}) ⇒ Configuration

Returns a new instance of Configuration.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/whatsapp_sdk/configuration.rb', line 17

def initialize(
  access_token = "",
  api_version = Api::ApiConfiguration::DEFAULT_API_VERSION,
  logger = nil,
  logger_options = {}
)
  @access_token = access_token
  @api_version = api_version
  @logger = logger
  @logger_options = logger_options
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



12
13
14
# File 'lib/whatsapp_sdk/configuration.rb', line 12

def access_token
  @access_token
end

#api_versionObject

Returns the value of attribute api_version.



12
13
14
# File 'lib/whatsapp_sdk/configuration.rb', line 12

def api_version
  @api_version
end

#loggerObject

loggers like ActiveSupport::Logger (Rails.logger) is a subclass of Logger



15
16
17
# File 'lib/whatsapp_sdk/configuration.rb', line 15

def logger
  @logger
end

#logger_optionsObject

loggers like ActiveSupport::Logger (Rails.logger) is a subclass of Logger



15
16
17
# File 'lib/whatsapp_sdk/configuration.rb', line 15

def logger_options
  @logger_options
end

Instance Method Details

#clientObject



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

def client
  Api::Client.new(access_token, api_version, logger, logger_options)
end