| @@ 77-101 (lines=25) @@ | ||
| 74 | * |
|
| 75 | * @return array|mixed |
|
| 76 | */ |
|
| 77 | protected function assignGroupsToAssignment() |
|
| 78 | { |
|
| 79 | $assignment = fp_env('ACACHA_FORGE_ASSIGNMENT'); |
|
| 80 | foreach ( $this->groups as $group) { |
|
| 81 | $uri = str_replace('{assignment}', $assignment, config('forge-publish.assign_group_to_assignment_uri')); |
|
| 82 | $uri = str_replace('{group}', $group, $uri); |
|
| 83 | $url = config('forge-publish.url') . $uri; |
|
| 84 | try { |
|
| 85 | $response = $this->http->post($url, [ |
|
| 86 | 'headers' => [ |
|
| 87 | 'X-Requested-With' => 'XMLHttpRequest', |
|
| 88 | 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') |
|
| 89 | ] |
|
| 90 | ]); |
|
| 91 | } catch (\Exception $e) { |
|
| 92 | if ($e->getResponse()->getStatusCode() == 422) { |
|
| 93 | $this->error('The group is already assigned'); |
|
| 94 | return; |
|
| 95 | } |
|
| 96 | $this->error('And error occurs connecting to the api url: ' . $url); |
|
| 97 | $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase()); |
|
| 98 | return []; |
|
| 99 | } |
|
| 100 | } |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Ask for groups. |
|
| @@ 83-107 (lines=25) @@ | ||
| 80 | * |
|
| 81 | * @return array|mixed |
|
| 82 | */ |
|
| 83 | protected function assignUsersToAssignment() |
|
| 84 | { |
|
| 85 | $assignment = fp_env('ACACHA_FORGE_ASSIGNMENT'); |
|
| 86 | foreach ( $this->users as $user) { |
|
| 87 | $uri = str_replace('{assignment}', $assignment, config('forge-publish.assign_user_to_assignment_uri')); |
|
| 88 | $uri = str_replace('{user}', $user, $uri); |
|
| 89 | $url = config('forge-publish.url') . $uri; |
|
| 90 | try { |
|
| 91 | $response = $this->http->post($url, [ |
|
| 92 | 'headers' => [ |
|
| 93 | 'X-Requested-With' => 'XMLHttpRequest', |
|
| 94 | 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') |
|
| 95 | ] |
|
| 96 | ]); |
|
| 97 | } catch (\Exception $e) { |
|
| 98 | if ($e->getResponse()->getStatusCode() == 422) { |
|
| 99 | $this->error('The user is already assigned'); |
|
| 100 | return; |
|
| 101 | } |
|
| 102 | $this->error('And error occurs connecting to the api url: ' . $url); |
|
| 103 | $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase()); |
|
| 104 | return; |
|
| 105 | } |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Get users |
|