-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathSmithsonianIOAAPIClientController.php
More file actions
80 lines (76 loc) · 2.62 KB
/
SmithsonianIOAAPIClientController.php
File metadata and controls
80 lines (76 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* @Author Asim Sarwar
* Description Handle Smithsonian Institution Open Access API's Client
* ClassName SmithsonianIOAAPIClientController
*/
namespace App\Http\Controllers\Api\V1\Integration;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\CurrikiGo\Smithsonian\Client;
use App\CurrikiGo\Smithsonian\Contents\GetContentList;
use App\CurrikiGo\Smithsonian\Contents\GetContentDetail;
use App\Exceptions\GeneralException;
class SmithsonianIOAAPIClientController extends Controller
{
protected $client;
/**
* SmithsonianIOAAPIClientController constructor.
* Create a new Client instance.
* @return object $client
*/
public function __construct()
{
$this->client = new Client();
}
/**
* Get Smithsonian Contents List
* @param Request $request
* @bodyParam q string use for search record Example: q=online_visual_material:true AND IC 443
* @bodyParam start int like page number Example: 1
* @bodyParam rows int like page size or number of record per page Example: 10
* @bodyParam sort string Sort list by id, newest, updated and random field
* @bodyParam type string get list by type = edanmdm or ead_collection or ead_component or all
* @bodyParam row_group string The designated set of row types you are filtering it may be objects, archives
* @return object $response
* @throws GeneralException
*/
public function getContentList(Request $request)
{
$getParam = $request->only([
'q',
'start',
'rows',
'sort',
'type',
'row_group'
]);
$auth = \Auth::user();
if ( $auth && $auth->id ) {
$instance = new GetContentList($this->client);
$response = $instance->fetch($getParam);
return $response;
}
throw new GeneralException('Unauthorized!');
}
/**
* Get Smithsonian Content Detail
* @param Request $request
* @bodyParam id string Example: con-1620124231687-1620150333404-0
* @return object $response
* @throws GeneralException
*/
public function getContentDetail(Request $request)
{
$getParam = $request->only([
'id'
]);
$auth = \Auth::user();
if ( $auth && $auth->id && isset($getParam['id']) && $getParam['id'] != '') {
$instance = new GetContentDetail($this->client);
$response = $instance->fetch($getParam);
return $response;
}
throw new GeneralException('Please check you payload data. id field is require!');
}
}