Class: Mirror::Api::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/mirror-api/request.rb

Constant Summary collapse

TIMELINE =
"timeline"
SUBSCRIPTIONS =
"subscriptions"
LOCATIONS =
"locations"
CONTACTS =
"contacts"
VALID_RESOURCES =
[TIMELINE, SUBSCRIPTIONS, LOCATIONS, CONTACTS]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(creds, options = {}) ⇒ Request

Returns a new instance of Request.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mirror-api/request.rb', line 23

def initialize(creds, options={})
  self.resource = options[:resource]
  self.params = options[:params]
  self.logger = options[:logger]
  @id = options[:id]

  @expected_response = options[:expected_response]
  @creds = creds
  @last_exception = nil
  @throw_on_fail = options[:raise_errors] || false
  @host = options[:host] || HOST

  @last_error = nil
end

Instance Attribute Details

#credsObject

Returns the value of attribute creds.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def creds
  @creds
end

#dataObject

Returns the value of attribute data.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def data
  @data
end

#hostObject

Returns the value of attribute host.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def host
  @host
end

#last_errorObject

Returns the value of attribute last_error.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def last_error
  @last_error
end

#last_exceptionObject

Returns the value of attribute last_exception.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def last_exception
  @last_exception
end

#loggerObject

Returns the value of attribute logger.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def logger
  @logger
end

#paramsObject

Returns the value of attribute params.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def params
  @params
end

#resourceObject

Returns the value of attribute resource.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def resource
  @resource
end

#responseObject

Returns the value of attribute response.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def response
  @response
end

#throw_on_failObject

Returns the value of attribute throw_on_fail.



20
21
22
# File 'lib/mirror-api/request.rb', line 20

def throw_on_fail
  @throw_on_fail
end

Instance Method Details

#deleteObject



86
87
88
# File 'lib/mirror-api/request.rb', line 86

def delete
  get_verb(:delete)
end

#getObject



90
91
92
# File 'lib/mirror-api/request.rb', line 90

def get
  get_verb
end

#patchObject



82
83
84
# File 'lib/mirror-api/request.rb', line 82

def patch
  do_verb(:patch)
end

#postObject



74
75
76
# File 'lib/mirror-api/request.rb', line 74

def post
  do_verb(:post)
end

#putObject



78
79
80
# File 'lib/mirror-api/request.rb', line 78

def put
  do_verb(:put)
end