Class: Openlive::Request

Inherits:
Base
  • Object
show all
Defined in:
lib/openlive/request.rb

Instance Attribute Summary

Attributes inherited from Base

#api_data, #response

Class Method Summary collapse

Methods inherited from Base

connection, #connection, handle_response, #initialize, #method_missing, #oauth, oauth, #refresh

Constructor Details

This class inherits a constructor from Openlive::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Openlive::Base

Class Method Details

.delete(path, params = {}, headers = {}) ⇒ Openlive::Response

Perform a delete request against the OpenLIVE API.

Parameters:

  • path (String)

    the URI path to perform the request against

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

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/openlive/request.rb', line 49

def delete(path, params = {}, headers = {})
  headers["Content-Type"] ||= "application/json"

  response = connection.send(
    :delete,
    path,
    params,
    default_headers.merge(headers)
  )

  Response.new(response)
end

.get(path, params = {}, headers = {}) ⇒ Openlive::Response

Perform a get request against the OpenLIVE API.

Parameters:

  • path (String)

    the URI path to perform the request against

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

Returns:



11
12
13
14
15
16
17
18
19
20
# File 'lib/openlive/request.rb', line 11

def get(path, params = {}, headers = {})
  response = connection.send(
    :get,
    path,
    default_params.merge(params),
    default_headers.merge(headers)
  )

  Response.new(response)
end

.post(path, params = {}, headers = {}) ⇒ Openlive::Response

Perform a post request against the OpenLIVE API.

Parameters:

  • path (String)

    the URI path to perform the request against

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

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/openlive/request.rb', line 29

def post(path, params = {}, headers = {})
  headers["Content-Type"] ||= "application/json"

  response = connection.send(
    :post,
    path,
    JSON.generate(default_params.merge(params)),
    default_headers.merge(headers)
  )

  Response.new(response)
end