Class: Talkgh::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/talkgh/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
# File 'lib/talkgh/client.rb', line 5

def initialize(options = {})
    @api_token = options[:api_token] || ENV['TALKGH_API_TOKEN']

    self.logger = options[:logger] || (defined?(Rails.logger) && Rails.logger)
end

Instance Attribute Details

#api_tokenObject



11
12
13
14
15
16
17
18
# File 'lib/talkgh/client.rb', line 11

def api_token
    unless @api_token
      raise AuthenticationError.new('No API token provided. ' \
        'See https://talkgh.com for details.')
    end
      
    @api_token
end

Instance Method Details

#loggerObject



24
25
26
# File 'lib/talkgh/client.rb', line 24

def logger
  @logger
end

#logger=(logger) ⇒ Object



28
29
30
# File 'lib/talkgh/client.rb', line 28

def logger=(logger)
  @logger = Logger.new(logger)
end

#smsObject



20
21
22
# File 'lib/talkgh/client.rb', line 20

def sms
    @sms ||= SMS.new(self)
end