Class: Hoptoad::Notice

Inherits:
Base
  • Object
show all
Defined in:
lib/hoptoad-api/notice.rb

Class Method Summary collapse

Class Method Details

.find(id, error_id, options = {}) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/hoptoad-api/notice.rb', line 4

def self.find(id, error_id, options={})
  setup

  hash = fetch(find_path(id, error_id), options)

  if hash.errors
    raise HoptoadError.new(results.errors.error)
  end

  hash.notice
end

.find_all_by_error_id(error_id, notice_options = {}) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hoptoad-api/notice.rb', line 16

def self.find_all_by_error_id(error_id, notice_options = {})
  setup

  options = {}
  notices = []
  page = 1
  while !notice_options[:pages] || page <= notice_options[:pages]
    options[:page] = page
    hash = fetch(all_path(error_id), options)
    if hash.errors
      raise HoptoadError.new(results.errors.error)
    end
    notice_stubs = hash.notices

    notice_stubs.map do |notice|
      notices << find(notice.id, error_id)
    end
    break if notice_stubs.size < 30
    page += 1
  end
  notices
end

.find_by_error_id(error_id, options = { 'page' => 1}) ⇒ Object


39
40
41
42
43
44
45
46
47
48
# File 'lib/hoptoad-api/notice.rb', line 39

def self.find_by_error_id(error_id, options={ 'page' => 1})
  setup

  hash = fetch(all_path(error_id), options)
  if hash.errors
    raise HoptoadError.new(results.errors.error)
  end

  hash.notices
end