Skip to content

Commit 5cd8a5e

Browse files
Endpoint: Check status code of HTTP delete requests (#529)
Reworks endpoint class delete methods to check HTTP status code instead of response body.
1 parent a708150 commit 5cd8a5e

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/Endpoint/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function delete(int $id): bool
9393
$response = $this->guzzle->delete($this->endpoint . '/' . $id);
9494
$body = $response->getBody()->getContents();
9595

96-
return $body === '' ? true : false;
96+
return $response->getStatusCode() === 200 ? true : false;
9797
}
9898

9999
/**

src/Endpoint/ApplicationMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public function deleteAll(int $id): bool
5555
$response = $this->guzzle->delete($this->endpoint . '/' . $id . '/message');
5656
$body = $response->getBody()->getContents();
5757

58-
return $body === '' ? true : false;
58+
return $response->getStatusCode() === 200 ? true : false;
5959
}
6060
}

src/Endpoint/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ public function delete(int $id): bool
8989
$response = $this->guzzle->delete($this->endpoint . '/' . $id);
9090
$body = $response->getBody()->getContents();
9191

92-
return $body === '' ? true : false;
92+
return $response->getStatusCode() === 200 ? true : false;
9393
}
9494
}

src/Endpoint/Message.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function delete(int $id): bool
113113
$response = $this->guzzle->delete($this->endpoint . '/' . $id);
114114
$body = $response->getBody()->getContents();
115115

116-
return $body === '' ? true : false;
116+
return $response->getStatusCode() === 200 ? true : false;
117117
}
118118

119119
/**
@@ -128,6 +128,6 @@ public function deleteAll(): bool
128128
$response = $this->guzzle->delete($this->endpoint);
129129
$body = $response->getBody()->getContents();
130130

131-
return $body === '' ? true : false;
131+
return $response->getStatusCode() === 200 ? true : false;
132132
}
133133
}

src/Endpoint/Plugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function updateConfig(int $id, string $config): bool
6262
$response = $this->guzzle->postYaml($this->endpoint . '/' . $id . '/config', $config);
6363
$body = $response->getBody()->getContents();
6464

65-
return $body === '' ? true : false;
65+
return $response->getStatusCode() === 200 ? true : false;
6666
}
6767

6868
/**
@@ -96,7 +96,7 @@ public function enable(int $id): bool
9696
$response = $this->guzzle->post($this->endpoint . '/' . $id . '/enable');
9797
$body = $response->getBody()->getContents();
9898

99-
return $body === '' ? true : false;
99+
return $response->getStatusCode() === 200 ? true : false;
100100
}
101101

102102
/**
@@ -113,6 +113,6 @@ public function disable(int $id): bool
113113
$response = $this->guzzle->post($this->endpoint . '/' . $id . '/disable');
114114
$body = $response->getBody()->getContents();
115115

116-
return $body === '' ? true : false;
116+
return $response->getStatusCode() === 200 ? true : false;
117117
}
118118
}

src/Endpoint/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function updatePassword(string $password): bool
5050
$response = $this->guzzle->post('current/user/password', $data);
5151
$body = $response->getBody()->getContents();
5252

53-
return $body === '' ? true : false;
53+
return $response->getStatusCode() === 200 ? true : false;
5454
}
5555

5656
/**
@@ -150,6 +150,6 @@ public function delete(int $id): bool
150150
$response = $this->guzzle->delete($this->endpoint . '/' . $id);
151151
$body = $response->getBody()->getContents();
152152

153-
return $body === '' ? true : false;
153+
return $response->getStatusCode() === 200 ? true : false;
154154
}
155155
}

0 commit comments

Comments
 (0)