Module: SignalApi

Defined in:
lib/signal_api.rb,
lib/signal_api/list.rb,
lib/signal_api/carrier.rb,
lib/signal_api/contact.rb,
lib/signal_api/segment.rb,
lib/signal_api/version.rb,
lib/signal_api/short_url.rb,
lib/signal_api/exceptions.rb,
lib/signal_api/mocks/list.rb,
lib/signal_api/util/phone.rb,
lib/signal_api/deliver_sms.rb,
lib/signal_api/coupon_group.rb,
lib/signal_api/mocks/contact.rb,
lib/signal_api/mocks/api_mock.rb,
lib/signal_api/mocks/short_url.rb,
lib/signal_api/signal_http_api.rb,
lib/signal_api/mocks/deliver_sms.rb,
lib/signal_api/util/email_address.rb

Defined Under Namespace

Modules: ApiMock Classes: ApiException, AuthFailedException, Carrier, CarrierOverrideMessage, Contact, CouponGroup, DeliverSms, EmailAddress, InvalidApiKeyException, InvalidMobilePhoneException, InvalidParameterException, List, NonRetryableException, Phone, Segment, SegmentType, SegmentUser, ShortUrl, SignalHttpApi, SubscriptionType

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.api_keyObject

Get your Signal API key.



21
22
23
24
25
26
27
# File 'lib/signal_api.rb', line 21

def api_key
  if @api_key.nil? || @api_key.strip == ""
    raise InvalidApiKeyException.new("The api_key is blank or nil.  Use SignalApi.api_key= to set it.")
  else
    @api_key
  end
end

.api_key=(api_key) ⇒ Object

Set your Signal API key.

Examples:

SignalApi.api_key = 'foobar123456abcxyz77'

Parameters:

  • api_key (String)

    Your Signal API key



16
17
18
# File 'lib/signal_api.rb', line 16

def api_key=(api_key)
  @api_key = api_key
end

.base_uriObject



83
84
85
# File 'lib/signal_api.rb', line 83

def base_uri
  @base_uri || "https://app.signalhq.com"
end

.base_uri=(base_uri) ⇒ Object



77
78
79
80
# File 'lib/signal_api.rb', line 77

def base_uri=(base_uri)
  @base_uri = base_uri
  api_classes.each { |clazz| clazz.base_uri @base_uri }
end

.loggerObject

Get the logger used by Signal.



41
42
43
# File 'lib/signal_api.rb', line 41

def logger
  @logger ||= Logger.new("/dev/null")
end

.logger=(logger) ⇒ Object

Set the logger to be used by Signal.

Examples:

SignalApi.logger = Rails.logger
SignalApi.logger = Logger.new(STDERR)

Parameters:

  • logger (Logger)

    The logger you would like Signal to use



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

def logger=(logger)
  @logger = logger
end

.retriesObject

Get the number of times failed API calls should be retried.



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

def retries
  @retries || 0
end

.retries=(retries) ⇒ Object

Set the number of times failed API calls should be retried. Defaults to 0.

Examples:

SignalApi.retries = 3

Parameters:

  • retries (Fixnum)

    The number of times API calls should be retried



51
52
53
# File 'lib/signal_api.rb', line 51

def retries=(retries)
  @retries = retries
end

.timeoutObject

Get the default timeout for API calls.



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

def timeout
  @timeout || 15
end

.timeout=(timeout) ⇒ Object

Set the default timeout for API calls. Defaults to 15 seconds.

Examples:

SignalApi.timeout = 5

Parameters:

  • timeout (Fixnum)

    The default timeout (in seconds) for API calls



66
67
68
69
# File 'lib/signal_api.rb', line 66

def timeout=(timeout)
  @timeout = timeout
  api_classes.each { |clazz| clazz.default_timeout @timeout }
end