1: <?php
2: /**
3: * This file is part of the Pipeliner API client library for PHP
4: *
5: * Copyright 2014 Pipelinersales, Inc. All Rights Reserved.
6: * For the full license information, see the attached LICENSE file.
7: */
8:
9: namespace PipelinerSales\ApiClient\Repository\Rest;
10:
11: use PipelinerSales\ApiClient\InfoMethodsInterface;
12: use PipelinerSales\ApiClient\Http\HttpInterface;
13:
14: class RestInfoMethods implements InfoMethodsInterface
15: {
16:
17: private $baseUrl;
18: private $httpClient;
19:
20: public function __construct($baseUrl, HttpInterface $httpClient)
21: {
22: $this->baseUrl = $baseUrl;
23: $this->httpClient = $httpClient;
24: }
25:
26: public function fetchTeamPipelineUrl()
27: {
28: return $this->httpClient->request('GET', $this->baseUrl . '/teamPipelineUrl')->decodeJson(true);
29: }
30:
31: public function fetchTeamPipelineVersion()
32: {
33: return $this->httpClient->request('GET', $this->baseUrl . '/teamPipelineVersion')->decodeJson(true);
34: }
35:
36: public function fetchServerAPIUtcDateTime()
37: {
38: return $this->httpClient->request('GET', $this->baseUrl . '/serverAPIUtcDateTime')->decodeJson(true);
39: }
40:
41: public function fetchErrorCodes()
42: {
43: return $this->httpClient->request('GET', $this->baseUrl . '/errorCodes')->decodeJson(true);
44: }
45:
46: public function fetchCollections()
47: {
48: //not / as described in the docs (no / at the end)
49: return $this->httpClient->request('GET', $this->baseUrl)->decodeJson(true);
50: }
51:
52: public function fetchEntityPublic()
53: {
54: return $this->httpClient->request('GET', $this->baseUrl . '/entityPublic')->decodeJson(true);
55: }
56:
57: public function fetchEntityFields($entityName)
58: {
59: return $this->httpClient->request('GET', $this->baseUrl . '/getFields/' . $entityName)->decodeJson(true);
60: }
61:
62: public function getHttpClient()
63: {
64: return $this->httpClient;
65: }
66:
67: public function getBaseUrl()
68: {
69: return $this->baseUrl;
70: }
71: }
72: