Module: SparkApi::Request

Included in:
Client
Defined in:
lib/spark_api/request.rb

Overview

HTTP request wrapper. Performs all the api session mumbo jumbo so that the models don’t have to.

Instance Method Summary collapse

Instance Method Details

#delete(path, options = {}) ⇒ Object

Perform an HTTP DELETE request

  • path - Path of an api resource, excluding version and endpoint (domain) information

  • options - Resource request options as specified being supported via and api resource

:returns:

Hash of the json results as documented in the api.

:raises:

SparkApi::ClientError or subclass if the request failed.


53
54
55
# File 'lib/spark_api/request.rb', line 53

def delete(path, options={})
  request(:delete, path, nil, options)
end

#get(path, options = {}) ⇒ Object

Perform an HTTP GET request

  • path - Path of an api resource, excluding version and endpoint (domain) information

  • options - Resource request options as specified being supported via and api resource

:returns:

Hash of the json results as documented in the api.

:raises:

SparkApi::ClientError or subclass if the request failed.


15
16
17
# File 'lib/spark_api/request.rb', line 15

def get(path, options={})
  request(:get, path, nil, options)
end

#post(path, body = nil, options = {}) ⇒ Object

Perform an HTTP POST request

  • path - Path of an api resource, excluding version and endpoint (domain) information

  • body - Hash for post body data

  • options - Resource request options as specified being supported via and api resource

:returns:

Hash of the json results as documented in the api.

:raises:

SparkApi::ClientError or subclass if the request failed.


28
29
30
# File 'lib/spark_api/request.rb', line 28

def post(path, body = nil, options={})
  request(:post, path, body, options)
end

#put(path, body = nil, options = {}) ⇒ Object

Perform an HTTP PUT request

  • path - Path of an api resource, excluding version and endpoint (domain) information

  • body - Hash for post body data

  • options - Resource request options as specified being supported via and api resource

:returns:

Hash of the json results as documented in the api.

:raises:

SparkApi::ClientError or subclass if the request failed.


41
42
43
# File 'lib/spark_api/request.rb', line 41

def put(path, body = nil, options={})
  request(:put, path, body, options)
end