Skip to content

Commit 9a1797a

Browse files
committed
add teams project support and fix bug
1 parent a925973 commit 9a1797a

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

lib/sentry-api/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ class Client < API
66
include Organizations
77
include Projects
88
include Events
9+
include Teams
910
end
1011
end

lib/sentry-api/client/projects.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ def project_stats(project_slug, options={}, organization_slug="")
7272
get("/projects/#{organization_slug}/#{project_slug}/stats/", query: options)
7373
end
7474

75+
# Upload a new dsym file for the given release
76+
#
77+
# @example
78+
# SentryApi.upload_dsym_files('project-slug','/path/to/file')
79+
#
80+
# @param project_slug [String] the slug of the project to list the dsym files of.
81+
# @param file_path [String] the absolute file path of the dsym file.
82+
# @param organization_slug [String] the slug of the organization.
83+
# @return [Array<SentryApi::ObjectifiedHash>]
84+
def upload_dsym_files(project_slug, file_path, organization_slug="")
85+
organization_slug = @default_org_slug if organization_slug == ""
86+
post("/projects/#{organization_slug}/#{project_slug}/files/dsyms/", body: {file: File.new(file_path)})
87+
end
88+
7589
# List a Project’s DSym Files.
7690
#
7791
# @example

lib/sentry-api/request.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
require 'httparty'
1+
require 'httmultiparty'
22
require 'json'
33

44
module SentryApi
55
# @private
66
class Request
7-
include HTTParty
7+
include HTTMultiParty
8+
89
format :json
9-
headers 'Content-Type' => 'application/json'
10+
headers "Content-Type" => "application/json"
1011
parser proc { |body, _| parse(body) }
11-
1212
attr_accessor :auth_token, :endpoint, :default_org_slug
1313

1414
# Converts the response body to an ObjectifiedHash.
@@ -67,6 +67,12 @@ def delete(path, options={})
6767
validate self.class.delete(@endpoint + path, options)
6868
end
6969

70+
def upload(path, options={})
71+
set_httparty_config(options)
72+
set_authorization_header(options)
73+
validate self.class.post(@endpoint + path, options)
74+
end
75+
7076
# Checks the response code for common errors.
7177
# Returns parsed response for successful requests.
7278
def validate(response)
@@ -119,9 +125,12 @@ def set_authorization_header(options, path=nil)
119125
end
120126
end
121127

122-
# Set http post or put body as json string
128+
# Set http post or put body as json string if content type is application/json
123129
def set_json_body(options)
124-
options[:body] = options[:body].to_json
130+
headers = self.class.headers
131+
if headers and headers["Content-Type"] == "application/json"
132+
options[:body] = options[:body].to_json
133+
end
125134
end
126135

127136
# Set HTTParty configuration

lib/sentry-api/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SentryApi
2-
VERSION = "0.1.0"
2+
VERSION = "0.1.1"
33
end

sentry-api.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
2626
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2727
spec.require_paths = ["lib"]
2828

29-
spec.add_runtime_dependency 'httparty', "~> 0.14.0"
29+
spec.add_runtime_dependency 'httmultiparty', "~> 0.3.16"
3030
spec.add_development_dependency "bundler", "~> 1.12"
3131
spec.add_development_dependency "rake", "~> 10.0"
3232
spec.add_development_dependency 'rspec', "~> 3.5.0", '>= 3.5.0'

0 commit comments

Comments
 (0)