Class: ApiSim::RecordedRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/api_sim/recorded_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time: Time.now, body:, request_env:, request_path:, query_string:) ⇒ RecordedRequest

Returns a new instance of RecordedRequest.



5
6
7
8
9
10
11
# File 'lib/api_sim/recorded_request.rb', line 5

def initialize(time: Time.now, body:, request_env:, request_path:, query_string: )
  @time = time
  @body = body
  @headers = parse_headers_from(request_env)
  @path = request_path
  @query = query_string
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/api_sim/recorded_request.rb', line 3

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/api_sim/recorded_request.rb', line 3

def headers
  @headers
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/api_sim/recorded_request.rb', line 3

def path
  @path
end

#queryObject (readonly)

Returns the value of attribute query.



3
4
5
# File 'lib/api_sim/recorded_request.rb', line 3

def query
  @query
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/api_sim/recorded_request.rb', line 3

def time
  @time
end

Instance Method Details

#to_json(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/api_sim/recorded_request.rb', line 13

def to_json(options = {})
  {
    body: @body,
    headers: @headers,
    path: @path,
    time: @time,
    query: @query
  }.to_json
end