Class: Pike13::HTTPClientV3

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/pike13/http_client_v3.rb

Overview

HTTParty-based HTTP client for Pike13 v3 Reporting API V3 API uses JSON API 1.0 (application/vnd.api+json) and a different URL structure than v2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, access_token:) ⇒ HTTPClientV3

Returns a new instance of HTTPClientV3.



14
15
16
17
# File 'lib/pike13/http_client_v3.rb', line 14

def initialize(base_url:, access_token:)
  @base_url = base_url
  @access_token = access_token
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



12
13
14
# File 'lib/pike13/http_client_v3.rb', line 12

def access_token
  @access_token
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



12
13
14
# File 'lib/pike13/http_client_v3.rb', line 12

def base_url
  @base_url
end

Instance Method Details

#post(path, body = {}, params = {}) ⇒ Hash

POST request for v3 reporting queries

Parameters:

  • path (String)

    The API endpoint path

  • body (Hash) (defaults to: {})

    Request body

  • params (Hash) (defaults to: {})

    Query parameters

Returns:

  • (Hash)

    Parsed response body



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pike13/http_client_v3.rb', line 25

def post(path, body = {}, params = {})
  handle_response do
    self.class.post(
      full_path(path),
      body: body.to_json,
      query: params,
      headers: headers,
      timeout: 30
    )
  end
end