Class: Twi::Lio

Inherits:
Object
  • Object
show all
Defined in:
lib/twi/lio.rb

Overview

Provides an object to store global configuration settings.

This class is not used directly, but by calling Twi.configure, which creates and updates a single instance of Lio.

An alternative way to set global configuration settings is by storing them in the following environment variables:

  • TWILIO_SID to store the Twilio SID

  • TWILIO_SECRET to store the Twilio secret

  • TWILIO_CONVERSATION_SERVICE_SID to store the Twilio Conversation service ID

In case both methods are used together, Twi.configure takes precedence.

Examples:

Set the sid and secret to interact with Twilio API:

Twi.configure do |config|
  twilio.sid = 'AC8776d'
  twilio.secret = '588213'
end

Set the sid and secret to interact with Twilio API:

ENV['TWILIO_SID'] = 'AC8776d'
ENV['TWILIO_SECRET'] = '588213'

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLio

Initialize the global configuration settings defaulting to matching environment variables.



32
33
34
35
36
37
38
39
40
# File 'lib/twi/lio.rb', line 32

def initialize
  @api_key = ENV['TWILIO_SID']
  @secret = ENV['TWILIO_SECRET']
  @account_sid = ENV['TWILIO_ACCOUNT_SID']
  @auth_token = ENV['TWILIO_AUTH_TOKEN']
  @conversation_sid = ENV['TWILIO_CONVERSATION_SERVICE_SID']
  @messaging_sid = ENV['TWILIO_MESSAGING_SID']
  @emergency_address_sid = ENV['TWILIO_EMERGENCY_SID']
end

Instance Attribute Details

#account_sidString (readonly)

Returns Account SID - used for advanced operations like creating numbers.

Returns:

  • (String)

    Account SID - used for advanced operations like creating numbers.



49
50
51
# File 'lib/twi/lio.rb', line 49

def 
  @account_sid
end

#api_keyString (readonly)

Returns API key - used for basic operations like sending messages.

Returns:

  • (String)

    API key - used for basic operations like sending messages.



43
44
45
# File 'lib/twi/lio.rb', line 43

def api_key
  @api_key
end

#auth_tokenString (readonly)

Returns OAuth token - to authenticate API requests made with account_sid.

Returns:

  • (String)

    OAuth token - to authenticate API requests made with account_sid.



52
53
54
# File 'lib/twi/lio.rb', line 52

def auth_token
  @auth_token
end

#conversation_sidString (readonly)

Returns the SID of the default Conversation service.

Returns:

  • (String)

    the SID of the default Conversation service.



55
56
57
# File 'lib/twi/lio.rb', line 55

def conversation_sid
  @conversation_sid
end

#emergency_address_sidString (readonly)

Returns the SID of the emergency address.

Returns:

  • (String)

    the SID of the emergency address.



61
62
63
# File 'lib/twi/lio.rb', line 61

def emergency_address_sid
  @emergency_address_sid
end

#messaging_sidString (readonly)

Returns the SID of the default Messaging service.

Returns:

  • (String)

    the SID of the default Messaging service.



58
59
60
# File 'lib/twi/lio.rb', line 58

def messaging_sid
  @messaging_sid
end

#secretString (readonly)

Returns secret - to authenticate API requests made with api_key.

Returns:

  • (String)

    secret - to authenticate API requests made with api_key.



46
47
48
# File 'lib/twi/lio.rb', line 46

def secret
  @secret
end