Class: Loggie::Logentries::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/loggie/logentries/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/loggie/logentries/response.rb', line 6

def initialize(response)
  data = JSON.parse response.read_body

  @logs = data["logs"]
  @links = data["links"]
  @leql = data["leql"]

  if data.key?("events") # 200
    @events = data["events"]
  else # 202 for a query that successfully started but has not yet finished
    @progress = data["progress"]
    @id = data["id"]
  end
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



4
5
6
# File 'lib/loggie/logentries/response.rb', line 4

def events
  @events
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/loggie/logentries/response.rb', line 4

def id
  @id
end

#leqlObject (readonly)

Returns the value of attribute leql.



4
5
6
# File 'lib/loggie/logentries/response.rb', line 4

def leql
  @leql
end

Returns the value of attribute links.



4
5
6
# File 'lib/loggie/logentries/response.rb', line 4

def links
  @links
end

#logsObject (readonly)

Returns the value of attribute logs.



4
5
6
# File 'lib/loggie/logentries/response.rb', line 4

def logs
  @logs
end

#progressObject (readonly)

Returns the value of attribute progress.



4
5
6
# File 'lib/loggie/logentries/response.rb', line 4

def progress
  @progress
end

Instance Method Details

#events?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/loggie/logentries/response.rb', line 26

def events?
  !@events.nil?
end

#next_urlObject



21
22
23
24
# File 'lib/loggie/logentries/response.rb', line 21

def next_url
  # res.fetch("links", [{}]).first.dig("href").gsub(/\?$/, '')
  links.first["href"]
end