Class: Splat::Base
- Inherits:
-
Object
- Object
- Splat::Base
- Defined in:
- lib/splat.rb
Constant Summary collapse
- @@gateways =
{}
Instance Attribute Summary collapse
-
#number_format_regx ⇒ Object
readonly
Returns the value of attribute number_format_regx.
Instance Method Summary collapse
-
#initialize(vendor_name) ⇒ Base
constructor
A new instance of Base.
- #send_bulk_sms(message, numbers = [], options = {}) ⇒ Object
- #send_bulk_sms_with_insertion(message, insertions = {}, options = {}) ⇒ Object
- #send_sms(message, number, options = {}) ⇒ Object
- #vendor ⇒ Object
Constructor Details
#initialize(vendor_name) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/splat.rb', line 18 def initialize(vendor_name) self.vendor = vendor_name if number_format = Gateway.default_configuration['number_format'] @number_format_regx = Regexp.new(number_format) else raise SplatError.new("default: number_format not define in splat.yml") unless number_format end end |
Instance Attribute Details
#number_format_regx ⇒ Object (readonly)
Returns the value of attribute number_format_regx.
16 17 18 |
# File 'lib/splat.rb', line 16 def number_format_regx @number_format_regx end |
Instance Method Details
#send_bulk_sms(message, numbers = [], options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/splat.rb', line 37 def send_bulk_sms(, numbers = [], = {}) [:response] = validate_phones(numbers) get_vender_object(vendor).send_bulk_sms(, numbers - [:response].invalid_phone_numbers, ) end |
#send_bulk_sms_with_insertion(message, insertions = {}, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/splat.rb', line 42 def send_bulk_sms_with_insertion(, insertions ={}, = {}) [:response] = validate_phones(insertions.keys) insertions.delete_if do |key, value| ![:response].phone_numbers[key].nil? end get_vender_object(vendor).send_bulk_sms_with_insertion(, insertions, ) end |
#send_sms(message, number, options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/splat.rb', line 29 def send_sms(, number, = {}) [:response] = Response.new unless validate_phone?(number) return [:response].invalid_phone_format(number) end get_vender_object(vendor).send_sms(, number, ) end |
#vendor ⇒ Object
52 53 54 55 |
# File 'lib/splat.rb', line 52 def vendor raise SplatError.new('Vendor is nil.Set vendor name.') unless @vendor @vendor end |