Class: Rapidomize::Client
- Inherits:
-
Object
- Object
- Rapidomize::Client
- Defined in:
- lib/rapidomize/client.rb
Overview
A client object is a simplification of the message sending process. It merely abstract the Message creation process by automatically creating messages and assign payloads and URIs to them. A transport method is still needed for the delivery process.
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#token ⇒ Object
Returns the value of attribute token.
-
#transport ⇒ Object
Returns the value of attribute transport.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, transport, app_id = nil, token = nil) ⇒ Client
constructor
Create a new client with a URI and a transport method.
-
#send(payload) ⇒ Net::HTTPResponse
Send the payload.
Constructor Details
#initialize(uri, transport, app_id = nil, token = nil) ⇒ Client
Create a new client with a URI and a transport method. These parameters will be used with every payload sent through this client.
20 21 22 23 24 25 |
# File 'lib/rapidomize/client.rb', line 20 def initialize(uri, transport, app_id = nil, token = nil) @uri = URI(uri) @transport = transport @app_id = app_id @token = token end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
10 11 12 |
# File 'lib/rapidomize/client.rb', line 10 def app_id @app_id end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/rapidomize/client.rb', line 10 def token @token end |
#transport ⇒ Object
Returns the value of attribute transport.
10 11 12 |
# File 'lib/rapidomize/client.rb', line 10 def transport @transport end |
#uri ⇒ Object
Returns the value of attribute uri.
10 11 12 |
# File 'lib/rapidomize/client.rb', line 10 def uri @uri end |
Instance Method Details
#send(payload) ⇒ Net::HTTPResponse
Send the payload
30 31 32 33 34 35 36 37 |
# File 'lib/rapidomize/client.rb', line 30 def send(payload) pl = Payload.create(payload) msg = Message.new(@uri, pl) msg.app_id = @app_id unless @app_id.nil? msg.token = @token unless @token.nil? @transport.deliver(msg) end |