Sha256: 7b374ac8c71e13f2d227b152984d4141b2ce8160caf12b4ad3ab524641b48f45

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

module TwilioBase
  module Clients
    ACCOUNT_SID = ENV.fetch('TWILIO_ACCOUNT_SID')
    AUTH_TOKEN = ENV.fetch('TWILIO_AUTH_TOKEN')

    delegate :api_key_sid, to: :config
    delegate :api_key_secret, to: :config
    delegate :application_sid, to: :config
    delegate :chat_service_sid, to: :config
    delegate :phone_number, to: :config
    delegate :sync_service_sid, to: :config
    delegate :workflow_sid, to: :config
    delegate :workspace_sid, to: :config

    def config
      @config ||= TwilioBase::GlobalConfig.first
    end

    def chat_client
      @chat_client ||= Twilio::ChatClient.new(
        account_sid: ACCOUNT_SID, auth_token: AUTH_TOKEN
      )
    end

    def sms_client
      @sms_client ||= TwilioBase::Clients::Sms.new(
        account_sid: ACCOUNT_SID, auth_token: AUTH_TOKEN
      )
    end

    def rest_client
      @rest_client ||= Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twilio_base-1.11.1101 app/services/twilio_base/clients.rb
twilio_base-1.11.11 app/services/twilio_base/clients.rb
twilio_base-1.9.0 app/services/twilio_base/clients.rb
twilio_base-1.8.0 app/services/twilio_base/clients.rb