Skip to content

Commit ccebc72

Browse files
committed
params default organization
1 parent ffee02e commit ccebc72

File tree

5 files changed

+28
-48
lines changed

5 files changed

+28
-48
lines changed

lib/sentry-api/client/organizations.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def organizations(member=false)
2020
#
2121
# @param organization_slug [String] the slug of the organization for which the projects should be listed.
2222
# @return [Array<SentryApi::ObjectifiedHash>]
23-
def organization_projects(organization_slug="")
24-
organization_slug = @default_org_slug if organization_slug == ""
23+
def organization_projects(organization_slug=@default_org_slug)
2524
get("/organizations/#{organization_slug}/projects/")
2625
end
2726

@@ -33,8 +32,7 @@ def organization_projects(organization_slug="")
3332
#
3433
# @param organization_slug [String] the slug of the organization the team should be created for.
3534
# @return [SentryApi::ObjectifiedHash]
36-
def organization(organization_slug="")
37-
organization_slug = @default_org_slug if organization_slug == ""
35+
def organization(organization_slug=@default_org_slug)
3836
get("/organizations/#{organization_slug}/")
3937
end
4038

@@ -50,7 +48,7 @@ def organization(organization_slug="")
5048
# @option options [String] :name an optional new name for the organization.
5149
# @option options [String] :slug an optional new slug for the organization. Needs to be available and unique.
5250
# @return [SentryApi::ObjectifiedHash]
53-
def update_organization(organization_slug, options={})
51+
def update_organization(options={}, organization_slug=@default_org_slug)
5452
put("/organizations/#{organization_slug}/", body: options)
5553
end
5654

@@ -67,7 +65,7 @@ def update_organization(organization_slug, options={})
6765
# @option options [Timestamp] :until a timestamp to set the end of the query in seconds since UNIX epoch.
6866
# @option options [String] :resolution an explicit resolution to search for (eg: 10s). This should not be used unless you are familiar with Sentry’s internals as it’s restricted to pre-defined values.
6967
# @return [Array<Array>]
70-
def organization_stats(organization_slug, options={})
68+
def organization_stats(options={}, organization_slug=@default_org_slug)
7169
get("/organizations/#{organization_slug}/stats/", query: options)
7270
end
7371

@@ -81,8 +79,7 @@ def organization_stats(organization_slug, options={})
8179
# @option options [String] :name the name for the new team.
8280
# @option options [String] :slug optionally a slug for the new team. If it’s not provided a slug is generated from the name.
8381
# @return [SentryApi::ObjectifiedHash]
84-
def create_team(options={}, organization_slug="")
85-
organization_slug = @default_org_slug if organization_slug == ""
82+
def create_team(options={}, organization_slug=@default_org_slug)
8683
post("/organizations/#{organization_slug}/teams/", body: options)
8784
end
8885

@@ -93,8 +90,7 @@ def create_team(options={}, organization_slug="")
9390
#
9491
# @param organization_slug [String] the slug of the organization
9592
# @return [Array<SentryApi::ObjectifiedHash>]
96-
def organization_teams(organization_slug="")
97-
organization_slug = @default_org_slug if organization_slug == ""
93+
def organization_teams(organization_slug=@default_org_slug)
9894
get("/organizations/#{organization_slug}/teams/")
9995
end
10096

lib/sentry-api/client/projects.rb

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def projects
1919
# @param project_slug [String] the slug of the project to retrieve.
2020
# @param organization_slug [String] the slug of the organization the project belong to.
2121
# @return [SentryApi::ObjectifiedHash]
22-
def project(project_slug, organization_slug="")
23-
organization_slug = @default_org_slug if organization_slug == ""
22+
def project(project_slug, organization_slug=@default_org_slug)
2423
get("/projects/#{organization_slug}/#{project_slug}/")
2524
end
2625

@@ -37,8 +36,7 @@ def project(project_slug, organization_slug="")
3736
# @option options [Hash] optional options to override in the project settings.
3837
# @param organization_slug [String] the slug of the organization the project belong to.
3938
# @return [SentryApi::ObjectifiedHash]
40-
def update_project(project_slug, options={}, organization_slug="")
41-
organization_slug = @default_org_slug if organization_slug == ""
39+
def update_project(project_slug, options={}, organization_slug=@default_org_slug)
4240
put("/projects/#{organization_slug}/#{project_slug}/", body: options)
4341
end
4442

@@ -49,8 +47,7 @@ def update_project(project_slug, options={}, organization_slug="")
4947
#
5048
# @param project_slug [String] the slug of the project to delete.
5149
# @param organization_slug [String] the slug of the organization the project belong to.
52-
def delete_project(project_slug, organization_slug="")
53-
organization_slug = @default_org_slug if organization_slug == ""
50+
def delete_project(project_slug, organization_slug=@default_org_slug)
5451
delete("/projects/#{organization_slug}/#{project_slug}/")
5552
end
5653

@@ -68,7 +65,7 @@ def delete_project(project_slug, organization_slug="")
6865
# @option options [String] :resolution an explicit resolution to search for (eg: 10s). This should not be used unless you are familiar with Sentry’s internals as it’s restricted to pre-defined values.
6966
# @param organization_slug [String] the slug of the organization the project belong to.
7067
# @return [Array<Array>]
71-
def project_stats(project_slug, options={}, organization_slug="")
68+
def project_stats(project_slug, options={}, organization_slug=@default_org_slug)
7269
get("/projects/#{organization_slug}/#{project_slug}/stats/", query: options)
7370
end
7471

@@ -81,8 +78,7 @@ def project_stats(project_slug, options={}, organization_slug="")
8178
# @param file_path [String] the absolute file path of the dsym file.
8279
# @param organization_slug [String] the slug of the organization.
8380
# @return [Array<SentryApi::ObjectifiedHash>]
84-
def upload_dsym_files(project_slug, file_path, organization_slug="")
85-
organization_slug = @default_org_slug if organization_slug == ""
81+
def upload_dsym_files(project_slug, file_path, organization_slug=@default_org_slug)
8682
post("/projects/#{organization_slug}/#{project_slug}/files/dsyms/", body: {file: File.new(file_path)})
8783
end
8884

@@ -94,8 +90,7 @@ def upload_dsym_files(project_slug, file_path, organization_slug="")
9490
# @param organization_slug [String] the slug of the organization.
9591
# @param project_slug [String] the slug of the project to list the dsym files of.
9692
# @return [Array<SentryApi::ObjectifiedHash>]
97-
def project_dsym_files(project_slug, organization_slug="")
98-
organization_slug = @default_org_slug if organization_slug == ""
93+
def project_dsym_files(project_slug, organization_slug=@default_org_slug)
9994
get("/projects/#{organization_slug}/#{project_slug}/files/dsyms/")
10095
end
10196

@@ -122,8 +117,7 @@ def client_keys(project_slug, organization_slug="")
122117
# @option options [String] :name the name for the new key.
123118
# @param organization_slug [String] the slug of the organization the client keys belong to.
124119
# @return [SentryApi::ObjectifiedHash]
125-
def create_client_key(project_slug, options={}, organization_slug="")
126-
organization_slug = @default_org_slug if organization_slug == ""
120+
def create_client_key(project_slug, options={}, organization_slug=@default_org_slug)
127121
post("/projects/#{organization_slug}/#{project_slug}/keys/", body: options)
128122
end
129123

@@ -135,8 +129,7 @@ def create_client_key(project_slug, options={}, organization_slug="")
135129
# @param project_slug [String] the slug of the project the client keys belong to.
136130
# @param key_id [String] the ID of the key to delete.
137131
# @param organization_slug [String] the slug of the organization the client keys belong to.
138-
def delete_client_key(project_slug, key_id, organization_slug="")
139-
organization_slug = @default_org_slug if organization_slug == ""
132+
def delete_client_key(project_slug, key_id, organization_slug=@default_org_slug)
140133
delete("/projects/#{organization_slug}/#{project_slug}/keys/#{key_id}/")
141134
end
142135

@@ -151,8 +144,7 @@ def delete_client_key(project_slug, key_id, organization_slug="")
151144
# @option options [String] :name the new name for the client key.
152145
# @param organization_slug [String] the slug of the organization the client keys belong to.
153146
# @return [Array<SentryApi::ObjectifiedHash>]
154-
def update_client_key(project_slug, key_id, options={}, organization_slug="")
155-
organization_slug = @default_org_slug if organization_slug == ""
147+
def update_client_key(project_slug, key_id, options={}, organization_slug=@default_org_slug)
156148
put("/projects/#{organization_slug}/#{project_slug}/keys/#{key_id}/", body: options)
157149
end
158150

@@ -164,8 +156,7 @@ def update_client_key(project_slug, key_id, options={}, organization_slug="")
164156
# @param project_slug [String] the slug of the project the client keys belong to.
165157
# @param organization_slug [String] the slug of the organization the client keys belong to.
166158
# @return [Array<SentryApi::ObjectifiedHash>]
167-
def project_events(project_slug, organization_slug="")
168-
organization_slug = @default_org_slug if organization_slug == ""
159+
def project_events(project_slug, organization_slug=@default_org_slug)
169160
get("/projects/#{organization_slug}/#{project_slug}/events/")
170161
end
171162

@@ -178,8 +169,7 @@ def project_events(project_slug, organization_slug="")
178169
# @param event_id [String] the slug of the project the event belongs to.
179170
# @param organization_slug [String] the slug of the organization the client keys belong to.
180171
# @return [SentryApi::ObjectifiedHash]
181-
def project_event(project_slug, event_id, organization_slug="")
182-
organization_slug = @default_org_slug if organization_slug == ""
172+
def project_event(project_slug, event_id, organization_slug=@default_org_slug)
183173
get("/projects/#{organization_slug}/#{project_slug}/events/#{event_id}/")
184174
end
185175

@@ -189,8 +179,7 @@ def project_event(project_slug, event_id, organization_slug="")
189179
# SentryApi.project_issues('project-slug')
190180
#
191181
# @return [Array<SentryApi::ObjectifiedHash>]
192-
def project_issues(project_slug, organization_slug="")
193-
organization_slug = @default_org_slug if organization_slug == ""
182+
def project_issues(project_slug, organization_slug=@default_org_slug)
194183
get("/projects/#{organization_slug}/#{project_slug}/issues/")
195184
end
196185

lib/sentry-api/client/teams.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ module Teams
1313
# @option options [String] :name the name for the new project.
1414
# @option options [String] :slug optionally a slug for the new project. If it’s not provided a slug is generated from the name.
1515
# @return [SentryApi::ObjectifiedHash]
16-
def create_project(team_slug, options={}, organization_slug="")
17-
organization_slug = @default_org_slug if organization_slug == ""
16+
def create_project(team_slug, options={}, organization_slug=@default_org_slug)
1817
post("/teams/#{organization_slug}/#{team_slug}/projects/", body: options)
1918
end
2019

@@ -25,8 +24,7 @@ def create_project(team_slug, options={}, organization_slug="")
2524
#
2625
# @param team_slug [String] the slug of the team
2726
# @param organization_slug [String] the slug of the organization
28-
def delete_team(team_slug, organization_slug="")
29-
organization_slug = @default_org_slug if organization_slug == ""
27+
def delete_team(team_slug, organization_slug=@default_org_slug)
3028
delete("/teams/#{organization_slug}/#{team_slug}/")
3129
end
3230

@@ -38,8 +36,7 @@ def delete_team(team_slug, organization_slug="")
3836
# @param team_slug [String] the slug of the team
3937
# @param organization_slug [String] the slug of the organization
4038
# @return [Array<SentryApi::ObjectifiedHash>]
41-
def team_projects(team_slug, organization_slug="")
42-
organization_slug = @default_org_slug if organization_slug == ""
39+
def team_projects(team_slug, organization_slug=@default_org_slug)
4340
get("/teams/#{organization_slug}/#{team_slug}/projects/")
4441
end
4542

@@ -51,8 +48,7 @@ def team_projects(team_slug, organization_slug="")
5148
# @param team_slug [String] the slug of the team
5249
# @param organization_slug [String] the slug of the organization
5350
# @return [SentryApi::ObjectifiedHash]
54-
def team(team_slug, organization_slug="")
55-
organization_slug = @default_org_slug if organization_slug == ""
51+
def team(team_slug, organization_slug=@default_org_slug)
5652
get("/teams/#{organization_slug}/#{team_slug}/")
5753
end
5854

@@ -67,8 +63,7 @@ def team(team_slug, organization_slug="")
6763
# @option options [String] :name the name for the new project.
6864
# @option options [String] :slug optionally a slug for the new project. If it’s not provided a slug is generated from the name.
6965
# @return [SentryApi::ObjectifiedHash]
70-
def update_team(team_slug, options={}, organization_slug="")
71-
organization_slug = @default_org_slug if organization_slug == ""
66+
def update_team(team_slug, options={}, organization_slug=@default_org_slug)
7267
get("/teams/#{organization_slug}/#{team_slug}/", body: options)
7368
end
7469

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.1"
2+
VERSION = "0.2.1"
33
end

spec/sentry-api/client/organizations_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
describe ".update_organization" do
5757
before do
5858
stub_put("/organizations/org-slug/", "update_organization")
59-
@edited_organization = SentryApi.update_organization("org-slug", name: "Impeccably Designated")
59+
@edited_organization = SentryApi.update_organization({name: "Impeccably Designated"}, "org-slug")
6060
end
6161

6262
it "should get the correct resource" do
@@ -70,12 +70,12 @@
7070

7171
describe ".organization_stats" do
7272
before do
73-
stub_get("/organizations/org-slug/stats/", "organization_stats").with(query: {stat: "received"})
74-
@stats = SentryApi.organization_stats("org-slug", stat: "received")
73+
stub_get("/organizations/sentry-sc/stats/", "organization_stats").with(query: {stat: "received"})
74+
@stats = SentryApi.organization_stats({stat: "received"})
7575
end
7676

7777
it "should get the correct resource" do
78-
expect(a_get("/organizations/org-slug/stats/").with(query: {stat: "received"})).to have_been_made
78+
expect(a_get("/organizations/sentry-sc/stats/").with(query: {stat: "received"})).to have_been_made
7979
end
8080

8181
it "should return array about an organization's event counts" do

0 commit comments

Comments
 (0)