@@ 57-74 (lines=18) @@ | ||
54 | * |
|
55 | * @return array |
|
56 | */ |
|
57 | public function getAddon(string $addonCode): array |
|
58 | { |
|
59 | $cacheKey = sprintf('addon_%s', $addonCode); |
|
60 | $hit = $this->getFromCache($cacheKey); |
|
61 | ||
62 | if (false === $hit) { |
|
63 | $response = $this->sendRequest('GET', sprintf('addons/%s', $addonCode)); |
|
64 | ||
65 | $data = $this->processResponse($response); |
|
66 | $addon = $data['addon']; |
|
67 | ||
68 | $this->saveToCache($cacheKey, $addon); |
|
69 | ||
70 | return $addon; |
|
71 | } |
|
72 | ||
73 | return $hit; |
|
74 | } |
|
75 | } |
|
76 |
@@ 21-39 (lines=19) @@ | ||
18 | * |
|
19 | * @return array |
|
20 | */ |
|
21 | public function getListCustomersByEmail(string $customerEmail): array |
|
22 | { |
|
23 | $cacheKey = sprintf('zoho_customer_%s', md5($customerEmail)); |
|
24 | $hit = $this->getFromCache($cacheKey); |
|
25 | ||
26 | if (false === $hit) { |
|
27 | $response = $this->sendRequest('GET', sprintf('customers?email=%s', $customerEmail)); |
|
28 | ||
29 | $result = $this->processResponse($response); |
|
30 | ||
31 | $customers = $result['customers']; |
|
32 | ||
33 | $this->saveToCache($cacheKey, $customers); |
|
34 | ||
35 | return $customers; |
|
36 | } |
|
37 | ||
38 | return $hit; |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * @param string $customerEmail |
|
@@ 64-81 (lines=18) @@ | ||
61 | * |
|
62 | * @return array |
|
63 | */ |
|
64 | public function getCustomerById(string $customerId): array |
|
65 | { |
|
66 | $cacheKey = sprintf('zoho_customer_%s', $customerId); |
|
67 | $hit = $this->getFromCache($cacheKey); |
|
68 | ||
69 | if (false === $hit) { |
|
70 | $response = $this->sendRequest('GET', sprintf('customers/%s', $customerId)); |
|
71 | $result = $this->processResponse($response); |
|
72 | ||
73 | $customer = $result['customer']; |
|
74 | ||
75 | $this->saveToCache($cacheKey, $customer); |
|
76 | ||
77 | return $customer; |
|
78 | } |
|
79 | ||
80 | return $hit; |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * @param string $customerId The customer's id |
@@ 23-41 (lines=19) @@ | ||
20 | * |
|
21 | * @return array |
|
22 | */ |
|
23 | public function listInvoicesByCustomer(string $customerId): array |
|
24 | { |
|
25 | $cacheKey = sprintf('zoho_invoices_%s', $customerId); |
|
26 | $hit = $this->getFromCache($cacheKey); |
|
27 | ||
28 | if (false === $hit) { |
|
29 | $response = $this->sendRequest('GET', sprintf('invoices?customer_id=%s', $customerId)); |
|
30 | ||
31 | $result = $this->processResponse($response); |
|
32 | ||
33 | $invoices = $result['invoices']; |
|
34 | ||
35 | $this->saveToCache($cacheKey, $invoices); |
|
36 | ||
37 | return $invoices; |
|
38 | } |
|
39 | ||
40 | return $hit; |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * @param string $invoiceId The invoice's id |
|
@@ 50-68 (lines=19) @@ | ||
47 | * |
|
48 | * @return array |
|
49 | */ |
|
50 | public function getInvoice(string $invoiceId) |
|
51 | { |
|
52 | $cacheKey = sprintf('zoho_invoice_%s', $invoiceId); |
|
53 | $hit = $this->getFromCache($cacheKey); |
|
54 | ||
55 | if (false === $hit) { |
|
56 | $response = $this->sendRequest('GET', sprintf('invoices/%s', $invoiceId)); |
|
57 | ||
58 | $result = $this->processResponse($response); |
|
59 | ||
60 | $invoice = $result['invoice']; |
|
61 | ||
62 | $this->saveToCache($cacheKey, $invoice); |
|
63 | ||
64 | return $invoice; |
|
65 | } |
|
66 | ||
67 | return $hit; |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * @param string $invoiceId The invoice's id |
@@ 64-81 (lines=18) @@ | ||
61 | * |
|
62 | * @return array |
|
63 | */ |
|
64 | public function getPlan(string $planCode): array |
|
65 | { |
|
66 | $cacheKey = sprintf('plan_%s', $planCode); |
|
67 | $hit = $this->getFromCache($cacheKey); |
|
68 | ||
69 | if (false === $hit) { |
|
70 | $response = $this->sendRequest('GET', sprintf('plans/%s', $planCode)); |
|
71 | ||
72 | $data = $this->processResponse($response); |
|
73 | $plan = $data['plan']; |
|
74 | ||
75 | $this->saveToCache($cacheKey, $plan); |
|
76 | ||
77 | return $plan; |
|
78 | } |
|
79 | ||
80 | return $hit; |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * get reccurent addons for given plan. |
@@ 84-102 (lines=19) @@ | ||
81 | * |
|
82 | * @return array |
|
83 | */ |
|
84 | public function getSubscription(string $subscriptionId) |
|
85 | { |
|
86 | $cacheKey = sprintf('zoho_subscription_%s', $subscriptionId); |
|
87 | $hit = $this->getFromCache($cacheKey); |
|
88 | ||
89 | if (false === $hit) { |
|
90 | $response = $this->sendRequest('GET', sprintf('subscriptions/%s', $subscriptionId)); |
|
91 | ||
92 | $result = $this->processResponse($response); |
|
93 | ||
94 | $subscription = $result['subscription']; |
|
95 | ||
96 | $this->saveToCache($cacheKey, $subscription); |
|
97 | ||
98 | return $subscription; |
|
99 | } |
|
100 | ||
101 | return $hit; |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * @param string $customerId The customer's id |
|
@@ 111-129 (lines=19) @@ | ||
108 | * |
|
109 | * @return array |
|
110 | */ |
|
111 | public function listSubscriptionsByCustomer(string $customerId) |
|
112 | { |
|
113 | $cacheKey = sprintf('zoho_subscriptions_%s', $customerId); |
|
114 | $hit = $this->getFromCache($cacheKey); |
|
115 | ||
116 | if (false === $hit) { |
|
117 | $response = $this->sendRequest('GET', sprintf('subscriptions?customer_id=%s', $customerId)); |
|
118 | ||
119 | $result = $this->processResponse($response); |
|
120 | ||
121 | $invoices = $result['subscriptions']; |
|
122 | ||
123 | $this->saveToCache($cacheKey, $invoices); |
|
124 | ||
125 | return $invoices; |
|
126 | } |
|
127 | ||
128 | return $hit; |
|
129 | } |
|
130 | } |
|
131 |