1 | <?php |
||
2 | |||
3 | namespace ThinkOne\LaravelSproutsocialsApi\RequestGroups; |
||
4 | |||
5 | use ThinkOne\LaravelSproutsocialsApi\SproutsocialsApi; |
||
6 | |||
7 | abstract class AbstractRequestGroup |
||
8 | { |
||
9 | protected SproutsocialsApi $api; |
||
10 | |||
11 | /** |
||
12 | * AbstractRequestGroup constructor. |
||
13 | * @param SproutsocialsApi $api |
||
14 | */ |
||
15 | 5 | public function __construct(SproutsocialsApi $api) |
|
16 | { |
||
17 | 5 | $this->api = $api; |
|
18 | } |
||
19 | |||
20 | /** |
||
21 | * Get client instance |
||
22 | * @return SproutsocialsApi |
||
23 | */ |
||
24 | 1 | public function apiClient(): SproutsocialsApi |
|
25 | { |
||
26 | 1 | return $this->api; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * Get customer ID form options |
||
31 | * @param array $options |
||
32 | * |
||
33 | * @return int|mixed|string |
||
34 | * @throws \ThinkOne\LaravelSproutsocialsApi\NotSetCustomerException |
||
35 | */ |
||
36 | 3 | public function customerId($options = []) |
|
37 | { |
||
38 | 3 | if (is_numeric($options) && $options) { |
|
0 ignored issues
–
show
introduced
by
![]() |
|||
39 | 1 | return $options; |
|
40 | } |
||
41 | |||
42 | 3 | if (is_array($options)) { |
|
43 | 2 | return $options['customer_id'] ?? $this->api->defaultCustomerId(); |
|
44 | } |
||
45 | |||
46 | 1 | return $this->api->defaultCustomerId(); |
|
47 | } |
||
48 | } |
||
49 |