Sha256: b1514119f726517b162099d7eb9b949acd2f2365e059b9644fc1e3b2738ff6cd
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module PachubeStream class Request attr_accessor :on_complete_block, :on_datastream_block, :request, :token, :method, :on_error_block, :on_get_block # @param[String] method # @param[String] html this means headers and body and resource and params # @param[String] token if you wanted to send a specific token def initialize(api_key, method, resource, html_request, token = nil) @api_key = api_key @method = method @resource = resource @html_request = html_request @token = token || generate_token(method) generate_html_request(api_key, method, resource, html_request, @token) end def on_complete(&block) @on_complete_block = block end def on_datastream(&block) @on_datastream_block = block end def on_error(&block) @on_error_block = block end def on_get(&block) @on_get_block = block end def to_json @request.to_json end protected def generate_token(method) "#{method}:#{UUID.generate}" end def generate_html_request(api_key, method, resource, html_request, token) @request = HtmlRequest.new(html_request) @request.api_key = api_key @request[:method] = method @request[:resource] = resource @request[:token] = token end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pachube-stream-0.0.4 | lib/pachube-stream/request.rb |
pachube-stream-0.0.3 | lib/pachube-stream/request.rb |