Class: LiveQA::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/liveqa/config.rb

Overview

LiveQA Config

Represent the LiveQA configuration for the API

Constant Summary collapse

DEFAULT_OBFUSCATED_FIELDS =
%w[
  password
  password_confirmation
  secret
  secret_token
  authenticity_token
  token
  api_key
  access_token
  credit_card_number
  cvv
  ccv
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Initialize and validate the configuration rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity

Parameters:

  • (Hash{Symbol=>Object})


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/liveqa/config.rb', line 83

def initialize(options = {})
  self. = options[:account_token]
  self.space_name = options[:space_name]
  self.environment_name = options[:environment_name]
  self.api_host = options[:api_host] || 'api.liveqa.io'
  self.api_version = options[:api_version] || 'v1'
  self.proxy_url = options[:proxy_url]
  self.http_secure = options[:http_secure] || true
  self.enabled = options[:enabled] || true
  self.obfuscated_fields = options[:obfuscated_fields] || []
  self.async = options[:async] || true
  self.custom_object_properties = options[:custom_object_properties] || {}
  self. = options[:metadata]
  self.log = options[:log] || true
  self.logger = FormatedLogger.build(options[:logger])
end

Instance Attribute Details

#account_tokenString

Returns API account token.

Returns:

  • (String)

    API account token



24
25
26
# File 'lib/liveqa/config.rb', line 24

def 
  @account_token
end

#api_hostString

Returns API host.

Returns:

  • (String)

    API host



36
37
38
# File 'lib/liveqa/config.rb', line 36

def api_host
  @api_host
end

#api_versionString

Returns API version.

Returns:

  • (String)

    API version



40
41
42
# File 'lib/liveqa/config.rb', line 40

def api_version
  @api_version
end

#asyncBoolean

Returns send.

Returns:

  • (Boolean)

    send



60
61
62
# File 'lib/liveqa/config.rb', line 60

def async
  @async
end

#custom_object_propertiesHash

Returns custom object properties.

Returns:

  • (Hash)

    custom object properties



64
65
66
# File 'lib/liveqa/config.rb', line 64

def custom_object_properties
  @custom_object_properties
end

#enabledBoolean

Returns service is enable.

Returns:

  • (Boolean)

    service is enable



52
53
54
# File 'lib/liveqa/config.rb', line 52

def enabled
  @enabled
end

#environment_nameString

Returns API environment name.

Returns:

  • (String)

    API environment name



32
33
34
# File 'lib/liveqa/config.rb', line 32

def environment_name
  @environment_name
end

#http_secureBoolean

Returns http secure.

Returns:

  • (Boolean)

    http secure



48
49
50
# File 'lib/liveqa/config.rb', line 48

def http_secure
  @http_secure
end

#logBoolean

Returns enable the logger.

Returns:

  • (Boolean)

    enable the logger



72
73
74
# File 'lib/liveqa/config.rb', line 72

def log
  @log
end

#loggerLogger

Returns logger.

Returns:

  • (Logger)

    logger



76
77
78
# File 'lib/liveqa/config.rb', line 76

def logger
  @logger
end

#metadataHash

Returns metadata to be attach to the payload.

Returns:

  • (Hash)

    metadata to be attach to the payload



68
69
70
# File 'lib/liveqa/config.rb', line 68

def 
  
end

#obfuscated_fieldsArray[String]

Returns fields to obfuscate.

Returns:

  • (Array[String])

    fields to obfuscate



56
57
58
# File 'lib/liveqa/config.rb', line 56

def obfuscated_fields
  @obfuscated_fields
end

#proxy_urlString

Returns proxy url.

Returns:

  • (String)

    proxy url



44
45
46
# File 'lib/liveqa/config.rb', line 44

def proxy_url
  @proxy_url
end

#space_nameString

Returns API space name.

Returns:

  • (String)

    API space name



28
29
30
# File 'lib/liveqa/config.rb', line 28

def space_name
  @space_name
end

Instance Method Details

#valid!Boolean

validate the configuration Raise when configuration are not valid

Returns:

  • (Boolean)

    true



106
107
108
109
110
111
112
113
114
# File 'lib/liveqa/config.rb', line 106

def valid!
  format!

  i[ space_name environment_name api_host api_version].each do |field|
    validate_presence(field)
  end

  true
end