Class: Mushikago::Http::Client
- Inherits:
-
Object
- Object
- Mushikago::Http::Client
- Defined in:
- lib/mushikago/http/client.rb
Overview
Mushikagoサービスに接続するクライアント
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (String) api_key
readonly
Api_key.
-
- (Signer) signer
readonly
Signer.
Instance Method Summary (collapse)
-
- (Client) initialize(options = {})
constructor
A new instance of Client.
-
- (Mushikago::Http::Response) send_request(request)
Response.
Constructor Details
- (Client) initialize(options = {})
A new instance of Client
16 |
# File 'lib/mushikago/http/client.rb', line 16 def initialize ={} |
Instance Attribute Details
- (String) api_key (readonly)
Api_key
8 9 10 |
# File 'lib/mushikago/http/client.rb', line 8 def api_key @api_key end |
- (Signer) signer (readonly)
Signer
11 12 13 |
# File 'lib/mushikago/http/client.rb', line 11 def signer @signer end |
Instance Method Details
- (Mushikago::Http::Response) send_request(request)
Response
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mushikago/http/client.rb', line 23 def send_request request # add authorization request.set_param('api_key', api_key) request.set_param('timestamp', Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')) request.add_signature!(signer) # send request Net::HTTP.start(request.host, request.port) do |http| http_request = request.to_http_request http_response = http.request(http_request) return Mushikago::Http::Response.new(JSON.parse(http_response.body)) end end |