1 | <?php namespace Cornford\Packtpublr; |
||
8 | class Packtpublr extends PacktpublrBase implements RedeemableInterface |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * The base URL. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $baseUrl = 'https://www.packtpub.com'; |
||
17 | |||
18 | /** |
||
19 | * The login URL. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $loginUrl = '/'; |
||
24 | |||
25 | /** |
||
26 | * The redeem URL. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $redeemUrl = '/packt/offers/free-learning'; |
||
31 | |||
32 | /** |
||
33 | * The logout URL. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $logoutUrl = '/logout'; |
||
38 | |||
39 | /** |
||
40 | * The login form fields. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $loginFormFields = [ |
||
45 | 'op' => 'Login', |
||
46 | 'form_build_id' => 'form-80807b1adfed1b70ff728d255a89cc65', |
||
47 | 'form_id' => 'packt_user_login_form', |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * The login email address. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $email; |
||
56 | |||
57 | /** |
||
58 | * The login password. |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $password; |
||
63 | |||
64 | /** |
||
65 | * Login. |
||
66 | * |
||
67 | * @param string $email |
||
68 | * @param string $password |
||
69 | * |
||
70 | * @throws PacktpublrRequestException |
||
71 | * |
||
72 | * @return boolean |
||
73 | */ |
||
74 | public function login($email = null, $password = null) |
||
87 | |||
88 | /** |
||
89 | * Redeem. |
||
90 | * |
||
91 | * @throws PacktpublrRequestException |
||
92 | * @throws PacktpublrRedeemException |
||
93 | * |
||
94 | * @return boolean |
||
95 | */ |
||
96 | public function redeem() |
||
114 | |||
115 | /** |
||
116 | * Logout. |
||
117 | * |
||
118 | * @throws PacktpublrRequestException |
||
119 | * |
||
120 | * @return boolean |
||
121 | */ |
||
122 | public function logout() |
||
132 | |||
133 | /** |
||
134 | * Run. |
||
135 | * |
||
136 | * @param string $email |
||
137 | * @param string $password |
||
138 | * |
||
139 | * @return boolean |
||
140 | */ |
||
141 | public function run($email = null, $password = null) |
||
179 | |||
180 | } |