Class: Octogate::Client
- Inherits:
-
Object
- Object
- Octogate::Client
- Defined in:
- lib/octogate/client.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
-
#initialize(event) ⇒ Client
constructor
A new instance of Client.
- #request(target) ⇒ Object
- #request_to_targets ⇒ Object
Constructor Details
#initialize(event) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/octogate/client.rb', line 9 def initialize(event) @event = event end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
7 8 9 |
# File 'lib/octogate/client.rb', line 7 def event @event end |
Instance Method Details
#request(target) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/octogate/client.rb', line 21 def request(target) uri = URI(target.url) = {url: target.url} .merge!() if uri.scheme == "https" conn = build_connection(, target.username, target.password) params = target.params.is_a?(Proc) ? target.instance_exec(event, &target.params) : target.params case target.http_method when :get Octogate::TransferRequest::GET.new(conn) .do_request(url: uri.path, params: params) when :post Octogate::TransferRequest::POST.new(conn) .do_request(url: uri.path, params: params, parameter_type: target.parameter_type) end sent_event = Octogate::SentEvent.build(event, target, params) Octogate.add_sent(sent_event) end |