Skip to content

Commit c439948

Browse files
committed
Consistently return from ProfileApiClient methods
So that the last line of the method body is the value being returned. Note that in the case of `.create_safeguarding_flag` and `.delete_safeguarding_flag` we return nil to indicate a successful response so the conditional `raise` appears on the last line of the method body.
1 parent 29416f0 commit c439948

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/profile_api_client.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,13 @@ def create_safeguarding_flag(token:, flag:)
135135
request.body = { flag: }
136136
end
137137

138-
return if response.status == 201 || response.status == 303
139-
140-
raise UnexpectedResponse, response
138+
raise UnexpectedResponse, response unless [201, 303].include?(response.status)
141139
end
142140

143141
def delete_safeguarding_flag(token:, flag:)
144142
response = connection(token).delete("/api/v1/safeguarding-flags/#{flag}")
145143

146-
return if response.status == 204
147-
148-
raise UnexpectedResponse, response
144+
raise UnexpectedResponse, response unless response.status == 204
149145
end
150146

151147
private

0 commit comments

Comments
 (0)