Skip to content

Commit dd6a97a

Browse files
authored
feat(api): add Alliance contact endpoint (#76)
Add Alliance contact endpoint
1 parent fc81d08 commit dd6a97a

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
/*
4+
* This file is part of SeAT
5+
*
6+
* Copyright (C) 2015 to 2022 Leon Jacobs
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License along
19+
* with this program; if not, write to the Free Software Foundation, Inc.,
20+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*/
22+
23+
namespace Seat\Api\Http\Controllers\Api\v2;
24+
25+
use Seat\Api\Http\Resources\ContactResource;
26+
use Seat\Api\Http\Traits\Filterable;
27+
use Seat\Eveapi\Models\Contacts\AllianceContact;
28+
29+
/**
30+
* Class AllianceController.
31+
*
32+
* @package Seat\Api\Http\Controllers\Api\v2
33+
*/
34+
class AllianceController extends ApiController
35+
{
36+
use Filterable;
37+
38+
/**
39+
* @OA\Get(
40+
* path="/v2/alliance/contacts/{alliance_id}",
41+
* tags={"Contacts"},
42+
* summary="Get a list of contacts for a alliance",
43+
* description="Returns a list of contacts",
44+
* security={
45+
* {"ApiKeyAuth": {}}
46+
* },
47+
* @OA\Parameter(
48+
* name="alliance_id",
49+
* description="Alliance id",
50+
* required=true,
51+
* @OA\Schema(
52+
* type="integer"
53+
* ),
54+
* in="path"
55+
* ),
56+
* @OA\Parameter(
57+
* in="query",
58+
* name="$filter",
59+
* description="Query filter following OData format",
60+
* @OA\Schema(
61+
* type="string"
62+
* )
63+
* ),
64+
* @OA\Response(response=200, description="Successful operation",
65+
* @OA\JsonContent(
66+
* type="object",
67+
* @OA\Property(
68+
* type="array",
69+
* property="data",
70+
* @OA\Items(ref="#/components/schemas/AllianceContact")
71+
* ),
72+
* @OA\Property(
73+
* property="links",
74+
* ref="#/components/schemas/ResourcePaginatedLinks"
75+
* ),
76+
* @OA\Property(
77+
* property="meta",
78+
* ref="#/components/schemas/ResourcePaginatedMetadata"
79+
* )
80+
* )
81+
* ),
82+
* @OA\Response(response=400, description="Bad request"),
83+
* @OA\Response(response=401, description="Unauthorized"),
84+
* )
85+
*
86+
* @param int $alliance_id
87+
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
88+
*/
89+
public function getContacts(int $alliance_id)
90+
{
91+
request()->validate([
92+
'$filter' => 'string',
93+
]);
94+
95+
$query = AllianceContact::with('labels')
96+
->where('alliance_id', $alliance_id)
97+
->where(function ($sub_query) {
98+
$this->applyFilters(request(), $sub_query);
99+
});
100+
101+
return ContactResource::collection($query->paginate()->appends(request()->except('page')));
102+
}
103+
}

src/Http/routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@
135135
Route::get('/wallet-journal/{corporation_id}')->uses('CorporationController@getWalletJournal');
136136
Route::get('/wallet-transactions/{corporation_id}')->uses('CorporationController@getWalletTransactions');
137137
});
138+
139+
Route::group(['prefix' => 'alliance'], function () {
140+
141+
Route::get('/contacts/{alliance_id}')->uses('AllianceController@getContacts');
142+
});
138143
});
139144

140145
});

0 commit comments

Comments
 (0)