Class: SmsBroker::Service
- Inherits:
-
Object
- Object
- SmsBroker::Service
- Defined in:
- lib/sms_broker/service.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client) ⇒ Service
constructor
A new instance of Service.
- #message(message) ⇒ Object
- #status(message_id) ⇒ Object
-
#voice_message(message) ⇒ Object
could have another params like lang.
Constructor Details
#initialize(client) ⇒ Service
Returns a new instance of Service.
41 42 43 |
# File 'lib/sms_broker/service.rb', line 41 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
39 40 41 |
# File 'lib/sms_broker/service.rb', line 39 def client @client end |
Class Method Details
.get(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sms_broker/service.rb', line 19 def self.get(name) = service_configuration(name) result = Service.validate(name, ) unless result.valid? raise Exceptions::InvalidService, name.to_sym => result.errors end new CLIENTS[name.to_sym].new() end |
.service_configuration(name) ⇒ Object
31 32 33 |
# File 'lib/sms_broker/service.rb', line 31 def self.service_configuration(name) SmsBroker.configuration[:services_setups][name.to_sym] end |
.validate(name, options) ⇒ Object
35 36 37 |
# File 'lib/sms_broker/service.rb', line 35 def self.validate(name, ) Setup.service_validation_schemas[name.to_sym].validate() end |
Instance Method Details
#message(message) ⇒ Object
45 46 47 |
# File 'lib/sms_broker/service.rb', line 45 def () MessageSender.new(client).() end |
#status(message_id) ⇒ Object
53 54 55 |
# File 'lib/sms_broker/service.rb', line 53 def status() StatusRequester.new(client).status() end |
#voice_message(message) ⇒ Object
could have another params like lang
49 50 51 |
# File 'lib/sms_broker/service.rb', line 49 def () #could have another params like lang VoiceMessageSender.new(client).() end |