Add region Api

This commit is contained in:
philipp lang 2021-04-10 00:48:04 +02:00
parent c8537d0037
commit 1825950eb1
2 changed files with 26 additions and 8 deletions

View File

@ -171,6 +171,13 @@ class Api {
});
}
public function regions() {
return collect($this->http()->get(self::$url."/ica/rest/baseadmin/region")['data'])->map(function($region) {
return Region::fromNami($region);
});
}
public function feesOf($groupid) {
return collect($this->http()->get(self::$url."/ica/rest/namiBeitrag/beitragsartmgl/gruppierung/{$groupid}")['data'])->map(function($fee) {
return Fee::fromNami($fee);
@ -221,14 +228,6 @@ class Api {
// -------------------------------------
public function regions() {
$response = $this->client->get("/ica/rest/baseadmin/region", [
'cookies' => $this->cookie
]);
return json_decode((string)$response->getBody());
}
public function groupForActivity($activityId) {
$response = $this->client->get("/ica/rest//nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/{$activityId}", [

19
src/Region.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace Zoomyboy\LaravelNami;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Model;
class Region extends Model {
protected $guarded = [];
public static function fromNami($item) {
return new self([
'id' => $item['id'],
'name' => preg_replace('/\s*\(.*?\)/', '', $item['descriptor'])
]);
}
}