Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #30 from herpaderpaldent/develop
Browse files Browse the repository at this point in the history
This PR contains changes from @5pitf1re and @MichaelErmer from #28 and #27 making style.ci happy.
exclamation ATTENTION

This package is one of my first work and no testing setup, therefore manual testing is required which i can currently not execute by myself i am fully dependent on the contributors of the changes for the functionality.
Other then that, i can not guarantee functionality in seat 4.x if it is ever released.
  • Loading branch information
herpaderpaldent authored Apr 24, 2020
2 parents 0910264 + e50fd42 commit 0d41ae1
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
6 changes: 2 additions & 4 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ preset: laravel
risky: false

enabled:
- alpha_ordered_imports
- concat_with_spaces
- no_empty_comment

disabled:
- braces
- psr2_braces
- phpdoc_no_package
- concat_without_spaces
- length_ordered_imports
- no_blank_lines_after_class_opening
- no_blank_lines_after_throw

finder:
exclude:
- "tests"
name:
- "*.php"
- "*.php"
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"cviebrock/discourse-php": "^0.9.3",
"laravel/framework": "5.5.*",
"eveseat/web": "3.0.*",
"ext-json": "*"
"ext-json": "*",
"guzzlehttp/guzzle": "^6.5"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 5 additions & 3 deletions src/Action/Discourse/Groups/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ class Create
* @return string
* @throws \Herpaderpaldent\Seat\SeatDiscourse\Exceptions\DiscourseGuzzleException
*/
public function execute(String $groupname) : string
public function execute(string $groupname): string
{
$client = new Client();
try {
$response = $client->request('POST', getenv('DISCOURSE_URL') . '/admin/groups', [
'form_params' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
'group[name]' => $groupname,
],
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

if (200 === $response->getStatusCode()) {
Expand Down
6 changes: 3 additions & 3 deletions src/Action/Discourse/Groups/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public function execute(int $group_id)
$client = new Client();
try {
$response = $client->request('DELETE', getenv('DISCOURSE_URL') . '/admin/groups/' . $group_id . '.json', [
'form_params' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

Expand Down
14 changes: 7 additions & 7 deletions src/Action/Discourse/Groups/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ class Get
* @return \Illuminate\Support\Collection
* @throws \Herpaderpaldent\Seat\SeatDiscourse\Exceptions\DiscourseGuzzleException
*/
public function execute() : Collection
public function execute(): Collection
{
$client = new Client();
try {
$response = $client->request('GET', getenv('DISCOURSE_URL') . '/groups/search.json', [
'query' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
],
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

if(! $response->getCode() === 200)
throw new Exception($response->getMessage(), $response->getCode());
if(! $response->getStatusCode() === 200)
throw new Exception($response->getMessage(), $response->getStatusCode());

$body = collect(json_decode($response->getBody()))->reject(function ($item) {
return $item->automatic;
Expand Down
6 changes: 3 additions & 3 deletions src/Action/Discourse/Users/GetUserByCharacterId.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function execute(int $id)
$client = new Client();
try {
$response = $client->request('GET', getenv('DISCOURSE_URL') . '/users/by-external/' . $id . '.json', [
'query' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

Expand Down
6 changes: 4 additions & 2 deletions src/Action/Discourse/Users/ListUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public function execute()
try {
$response = $client->request('GET', getenv('DISCOURSE_URL') . '/admin/users/list/active.json', [
'query' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
'order' => 'topics_entered',
'show_emails' => 'true',
],
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

return collect(json_decode($response->getBody()));
Expand Down
12 changes: 6 additions & 6 deletions src/Jobs/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public function handle()

try {
$response = $this->client->request('POST', getenv('DISCOURSE_URL') . '/admin/users/' . $this->discourse_user_id . '/log_out', [
'form_params' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

Expand All @@ -108,9 +108,9 @@ public function beforeStart()
$uri = sprintf('%s/users/by-external/%d.json', getenv('DISCOURSE_URL'), $this->main_character->character_id);

$response = $this->client->request('GET', $uri, [
'query' => [
'api_key' => getenv('DISCOURSE_API_KEY'),
'api_username' => getenv('DISCOURSE_API_USERNAME'),
'headers' => [
'api-key' => getenv('DISCOURSE_API_KEY'),
'api-username' => getenv('DISCOURSE_API_USERNAME'),
],
]);

Expand Down

0 comments on commit 0d41ae1

Please sign in to comment.