1 <?php
2 /* === AUTO-GENERATED - DO NOT EDIT === */
3
4 /*
5 Copyright (c) 2012, University of Cambridge Computing Service
6
7 This file is part of the Lookup/Ibis client library.
8
9 This library is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 require_once dirname(__FILE__) . "/../client/IbisException.php";
24
25 /**
26 * Common methods for searching for objects in the Lookup/Ibis database.
27 *
28 * @author Dean Rasheed (dev-group@ucs.cam.ac.uk)
29 */
30 class IbisMethods
31 {
32 // The connection to the server
33 private $conn;
34
35 /**
36 * Create a new IbisMethods object.
37 *
38 * @param ClientConnection $conn The ClientConnection object to use to
39 * invoke methods on the server.
40 */
41 public function __construct($conn)
42 {
43 $this->conn = $conn;
44 }
45
46 /**
47 * Get the ID of the last (most recent) transaction.
48 *
49 * A transaction represents an edit made to data in Lookup. Each
50 * transaction is assigned a unique, sequential, numeric ID. Thus
51 * this last transaction ID will increase each time some data in
52 * Lookup is changed.
53 *
54 * ``[ HTTP: GET /api/v1/last-transaction ]``
55 *
56 * @return long The ID of the latest transaction.
57 */
58 public function getLastTransactionId()
59 {
60 $pathParams = array();
61 $queryParams = array();
62 $formParams = array();
63 $result = $this->conn->invokeMethod("GET",
64 'api/v1/last-transaction',
65 $pathParams,
66 $queryParams,
67 $formParams);
68 if (isset($result->error))
69 throw new IbisException($result->error);
70 return intval($result->value);
71 }
72
73 /**
74 * Get the current API version number.
75 *
76 * ``[ HTTP: GET /api/v1/version ]``
77 *
78 * @return String The API version number string.
79 */
80 public function getVersion()
81 {
82 $pathParams = array();
83 $queryParams = array();
84 $formParams = array();
85 $result = $this->conn->invokeMethod("GET",
86 'api/v1/version',
87 $pathParams,
88 $queryParams,
89 $formParams);
90 if (isset($result->error))
91 throw new IbisException($result->error);
92 return $result->value;
93 }
94 }
95