1: <?php
2:
3: namespace Crowdsdom;
4:
5: use Crowdsdom\Client\Client;
6:
7: class Crowdsdom
8: {
9:
10: const DEFAULT_AUTH_HOST = 'https://account.crowdsdom.com';
11: const DEFAULT_API_HOST = 'https://api.crowdsdom.com';
12: const DEFAULT_API_VERSION = 'v1';
13:
14: /**
15: * @var string
16: */
17: protected $authHost;
18:
19: /**
20: * @var string
21: */
22: protected $apiHost;
23:
24: /**
25: * @var string
26: */
27: protected $apiVersion;
28:
29: /**
30: * @var Client
31: */
32: protected $apiClient;
33:
34: /**
35: * @var Auth
36: */
37: protected $auth;
38:
39: /**
40: * @var Labor
41: */
42: protected $labor;
43:
44: /**
45: * Crowdsdom constructor.
46: * @param string $authHost
47: * @param string $apiHost
48: * @param string $apiVersion
49: */
50: public function __construct(
51: $clientId,
52: $clientSecret,
53: $authHost = self::DEFAULT_AUTH_HOST,
54: $apiHost = self::DEFAULT_API_HOST,
55: $apiVersion = self::DEFAULT_API_VERSION
56: ) {
57: $this->authHost = $authHost;
58: $this->apiHost = $apiHost;
59: $this->apiVersion = $apiVersion;
60:
61: $this->auth = new Auth($this->authHost, $clientId, $clientSecret);
62: $this->apiClient = new Client($this->auth, $this->apiHost, $this->apiVersion);
63: }
64:
65: public function labor()
66: {
67: if (!isset($this->labor)) {
68: $this->labor = new Labor($this->apiClient);
69: }
70: return $this->labor;
71: }
72:
73: }