1 | <?php |
||
12 | class MyQ { |
||
|
|||
13 | |||
14 | /** @var string|null $username contains the username used to authenticate with the MyQ API */ |
||
15 | protected $username = null; |
||
16 | /** @var string|null $password contains the password used to authenticate with the MyQ API */ |
||
17 | protected $password = null; |
||
18 | /** @var string|null $appId is the application ID used to register with the MyQ API */ |
||
19 | protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx'; |
||
20 | //protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi'; |
||
21 | /** @var string|null $securityToken is the auth token returned after a successful login */ |
||
22 | protected $securityToken = null; |
||
23 | /** @var string|null $userAgent is the User-Agent header value sent with each API request */ |
||
24 | protected $userAgent = 'Chamberlain/3.4.1'; |
||
25 | /** @var string|null $culture is the API culture code for the API */ |
||
26 | protected $culture = 'en'; |
||
27 | /** @var string|null $contentType is the content type used for all cURL requests */ |
||
28 | protected $contentType = 'application/json'; |
||
29 | /** @var array $headers contain HTTP headers for cURL requests */ |
||
30 | protected $_headers = array(); |
||
31 | protected $_deviceId = null; |
||
32 | protected $_locationName = null; |
||
33 | protected $_doorName = null; |
||
34 | protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate'; |
||
35 | protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true'; |
||
36 | protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute'; |
||
37 | /** @var resource|null $_conn is the web connection to the MyQ API */ |
||
38 | protected $_conn = null; |
||
39 | /** |
||
40 | * Initializes class. Optionally allows user to override variables |
||
41 | * |
||
42 | * @param array $params A associative array for overwriting class variables |
||
43 | * |
||
44 | * @return MyQ |
||
45 | */ |
||
46 | public function __construct ($params = array()) { |
||
64 | /** |
||
65 | * Perform a login request |
||
66 | * |
||
67 | * @param string|null $username Username to use when logging in |
||
68 | * @param string|null $password Password to use for logging in |
||
69 | * |
||
70 | * @return MyQ |
||
71 | */ |
||
72 | public function login ($username = null, $password = null) { |
||
103 | |||
104 | public function getDetails() { |
||
107 | |||
108 | private function _init () { |
||
184 | } |
Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.