Class: DelivereeSms

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

Defined Under Namespace

Classes: Infobip, Nexmo, Telerivet, Twilio

Constant Summary collapse

@@platforms =
nil
@@platform_by_country =
nil
@@keys =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, to_number, country) ⇒ DelivereeSms

Returns a new instance of DelivereeSms.



39
40
41
42
43
44
# File 'lib/deliveree_sms.rb', line 39

def initialize(content, to_number, country)
  platform_by_country = DelivereeSms.platform_by_country
  platform = platform_by_country[country.downcase.to_sym] || platform_by_country[:default]
  from_number = DelivereeSms.root_number_by_platform[platform.to_sym]
  @adapter = DelivereeSms.const_get(platform, false).new(content, to_number, from_number, @@keys)
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (DelivereeSms)

    the object that the method was called on



11
12
13
# File 'lib/deliveree_sms.rb', line 11

def self.configure
  yield self
end

.keysObject



31
32
33
# File 'lib/deliveree_sms.rb', line 31

def self.keys
  @@keys
end

.keys=(keys) ⇒ Object



23
24
25
# File 'lib/deliveree_sms.rb', line 23

def self.keys=(keys)
  @@keys = keys
end

.platform_by_countryObject



27
28
29
# File 'lib/deliveree_sms.rb', line 27

def self.platform_by_country
  @@platform_by_country
end

.platform_by_country=(platform_by_country) ⇒ Object



15
16
17
# File 'lib/deliveree_sms.rb', line 15

def self.platform_by_country=(platform_by_country)
  @@platform_by_country = platform_by_country
end

.root_number_by_platformObject



35
36
37
# File 'lib/deliveree_sms.rb', line 35

def self.root_number_by_platform
  @@root_number_by_platform
end

.root_number_by_platform=(root_number_by_platform) ⇒ Object



19
20
21
# File 'lib/deliveree_sms.rb', line 19

def self.root_number_by_platform=(root_number_by_platform)
  @@root_number_by_platform = root_number_by_platform
end

Instance Method Details

#sendObject



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

def send
  RestClient.post(@adapter.api_url, @adapter.body, @adapter.headers)
end