Class: CivicSIPSdk::AppConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/civic_sip_sdk/app_config.rb

Constant Summary collapse

VALID_ENVS =
%i[dev prod].freeze
REQUIRED_KEYS =
[
  { name: :id, error: 'Civic application id is missing!' },
  { name: :private_key, error: 'Civic application private signing key is missing!' },
  { name: :secret, error: 'Civic application secret is missing!' }
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, env:, private_key:, secret:) ⇒ AppConfig

Creates a new instance of CivicSIPSdk::AppConfig. This is used to configure the SDK connection parameters to the Civic SIP service.

It raises an ArgumentError if any argument is nil.

Parameters:

  • id (String)

    The application id.

  • env (Symbol)

    The application environment. Defaults to :prod if the value is incorrect.

  • private_key (String)

    The application’s private signing key.

  • secret (String)

    The application secret



23
24
25
26
27
28
29
30
# File 'lib/civic_sip_sdk/app_config.rb', line 23

def initialize(id:, env:, private_key:, secret:)
  @id = id
  @env = VALID_ENVS.include?(env.to_sym) ? env.to_sym : VALID_ENVS.last
  @private_key = private_key
  @secret = secret

  validate
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/civic_sip_sdk/app_config.rb', line 5

def env
  @env
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/civic_sip_sdk/app_config.rb', line 5

def id
  @id
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



5
6
7
# File 'lib/civic_sip_sdk/app_config.rb', line 5

def private_key
  @private_key
end

#secretObject (readonly)

Returns the value of attribute secret.



5
6
7
# File 'lib/civic_sip_sdk/app_config.rb', line 5

def secret
  @secret
end