Class: Sentry::Client
- Inherits:
-
Object
- Object
- Sentry::Client
- Defined in:
- lib/sentry/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #create_release(version) ⇒ Object
-
#initialize(token, slug) ⇒ Client
constructor
A new instance of Client.
- #upload_release_artifact(version, artifact_path, filename_prefix = "") ⇒ Object
Constructor Details
#initialize(token, slug) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/sentry/client.rb', line 7 def initialize(token, slug) self.token = token self.slug = slug self.base_url = "https://sentry.io/api/0/projects/" end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/sentry/client.rb', line 5 def base_url @base_url end |
#prefix ⇒ Object
Returns the value of attribute prefix.
5 6 7 |
# File 'lib/sentry/client.rb', line 5 def prefix @prefix end |
#slug ⇒ Object
Returns the value of attribute slug.
5 6 7 |
# File 'lib/sentry/client.rb', line 5 def slug @slug end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/sentry/client.rb', line 5 def token @token end |
Instance Method Details
#create_release(version) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sentry/client.rb', line 13 def create_release(version) response = Typhoeus.get( "#{base_url}/#{slug}/releases/#{version}/", headers: { "Authorization" => "Bearer #{token}", "Content-Type" => "application/json" } ) if response.response_code == 200 # Release already present, skipping... return response end Typhoeus.post( "#{base_url}/#{slug}/releases/", headers: { "Authorization" => "Bearer #{token}", "Content-Type" => "application/json" }, body: JSON.dump({ version: version }) ) end |
#upload_release_artifact(version, artifact_path, filename_prefix = "") ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sentry/client.rb', line 36 def upload_release_artifact(version, artifact_path, filename_prefix = "") Typhoeus.post( "#{base_url}/#{slug}/releases/#{version}/files/", headers: { "Authorization" => "Bearer #{token}" }, body: { file: File.open(artifact_path, "r"), name: "#{filename_prefix}#{File.basename(artifact_path)}" } ) end |