Class: SimpleApiAuth::Request

Inherits:
Object
  • Object
show all
Includes:
Helpers::Request
Defined in:
lib/simple-api-auth/request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Request

#normalize, #normalize_headers

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



7
8
9
10
11
12
13
# File 'lib/simple-api-auth/request.rb', line 7

def initialize(options = {})
  options.each do |k, v|
    send("#{k}=", v)
  end
  self.headers = normalize_headers(headers)
  self.http_verb = normalize(http_verb)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/simple-api-auth/request.rb', line 5

def body
  @body
end

#headersObject

Returns the value of attribute headers.



5
6
7
# File 'lib/simple-api-auth/request.rb', line 5

def headers
  @headers
end

#http_verbObject

Returns the value of attribute http_verb.



5
6
7
# File 'lib/simple-api-auth/request.rb', line 5

def http_verb
  @http_verb
end

#query_stringObject

Returns the value of attribute query_string.



5
6
7
# File 'lib/simple-api-auth/request.rb', line 5

def query_string
  @query_string
end

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/simple-api-auth/request.rb', line 5

def uri
  @uri
end

Class Method Details

.create(request) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/simple-api-auth/request.rb', line 22

def self.create(request)
  if request.is_a?(Request)
    request
  else
    options = {}
    SimpleApiAuth.config.request_fields.each do |k, v|
      options[k] = request.send(v)
    end
    Request.new(options)
  end
end

Instance Method Details

#timeObject



15
16
17
18
19
20
# File 'lib/simple-api-auth/request.rb', line 15

def time
  header_key = SimpleApiAuth.config.header_keys[:time]
  Time.parse(headers[header_key])
rescue ArgumentError
  nil
end