Class: SmsBroker::StatusRequester
- Inherits:
-
Object
- Object
- SmsBroker::StatusRequester
- Defined in:
- lib/sms_broker/status_requester.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(client) ⇒ StatusRequester
constructor
A new instance of StatusRequester.
- #request ⇒ Object
- #status(message_id) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(client) ⇒ StatusRequester
Returns a new instance of StatusRequester.
6 7 8 |
# File 'lib/sms_broker/status_requester.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/sms_broker/status_requester.rb', line 3 def client @client end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/sms_broker/status_requester.rb', line 3 def errors @errors end |
Instance Method Details
#request ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/sms_broker/status_requester.rb', line 16 def request unless valid? return Client::Response::Error.new(client.name, errors, errors) end client.(build_request) end |
#status(message_id) ⇒ Object
10 11 12 13 14 |
# File 'lib/sms_broker/status_requester.rb', line 10 def status() @message_id = self end |
#valid? ⇒ Boolean
24 25 26 27 28 29 30 31 32 |
# File 'lib/sms_broker/status_requester.rb', line 24 def valid? schema = { message_id: Compel.string.required } result = Compel.hash.keys(schema).validate(build_request) @errors = result.errors result.valid? end |