blob: 388d0531da18f13ad979cf5b3c510676d33c028f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
module Sentry
class ApiUrls
def initialize(url_base)
@uri = URI(url_base).freeze
end
def issues_url
with_path(File.join(@uri.path, '/issues/'))
end
def issue_url(issue_id)
with_path("/api/0/issues/#{escape(issue_id)}/")
end
def projects_url
with_path('/api/0/projects/')
end
def issue_latest_event_url(issue_id)
with_path("/api/0/issues/#{escape(issue_id)}/events/latest/")
end
private
def with_path(new_path)
new_uri = @uri.dup
# Sentry API returns 404 if there are extra slashes in the URL
new_uri.path = new_path.squeeze('/')
new_uri
end
def escape(param)
CGI.escape(param.to_s)
end
end
end
|