@@ -82,100 +82,6 @@ public function enableDoubleOptIn($auth_token)
8282 HttpHelper::post ($ apiEndpoints , $ requestParams , $ this ->_defaultHeader );
8383 }
8484
85- // public function addSubscriber($auth_token, $groupIds, $type, $finalData)
86- // {
87- // $apiEndpoints = $this->_baseUrl . 'subscribers';
88- // $splitGroupIds = null;
89-
90- // if (!empty($groupIds)) {
91- // $splitGroupIds = explode(',', $groupIds);
92- // }
93-
94- // if (empty($finalData['email'])) {
95- // return ['success' => false, 'message' => __('Required field Email is empty', 'bit-integrations'), 'code' => 400];
96- // }
97-
98- // if ('https://connect.mailerlite.com/api/' === $this->_baseUrl) {
99- // $requestParams = [
100- // 'email' => $finalData['email'],
101- // 'status' => $type ? $type : 'active',
102- // ];
103- // } else {
104- // $requestParams = [
105- // 'email' => $finalData['email'],
106- // 'type' => $type ? $type : 'active',
107- // ];
108- // }
109-
110- // foreach ($finalData as $key => $value) {
111- // if ('email' !== $key) {
112- // $requestParams['fields'][$key] = $value;
113- // }
114- // }
115- // $requestParams['fields'] = !empty($requestParams['fields']) ? (object) $requestParams['fields'] : [];
116- // $email = $finalData['email'];
117- // $isExist = $this->existSubscriber($auth_token, $email);
118- // $response = null;
119-
120- // if ($isExist && empty($this->_actions->update)) {
121- // return ['success' => false, 'message' => __('Subscriber already exist', 'bit-integrations'), 'code' => 400];
122- // }
123-
124- // if ($isExist && !empty($this->_actions->update)) {
125- // if (!empty($groupIds)) {
126- // if ('https://connect.mailerlite.com/api/' === $this->_baseUrl) {
127- // if (!empty($this->_actions->double_opt_in)) {
128- // $requestParams['opted_in_at'] = date('Y-m-d H:i:s');
129- // $requestParams['optin_ip'] = $_SERVER['REMOTE_ADDR'];
130- // }
131-
132- // $requestParams['groups'] = $splitGroupIds;
133- // $response = HttpHelper::post($apiEndpoints, $requestParams, $this->_defaultHeader);
134- // } else {
135- // if (!empty($this->_actions->double_opt_in)) {
136- // $this->enableDoubleOptIn($auth_token);
137- // }
138-
139- // for ($i = 0; $i < \count($splitGroupIds); $i++) {
140- // $apiEndpoints = $this->_baseUrl . 'groups/' . $splitGroupIds[$i] . '/subscribers';
141- // $response = HttpHelper::post($apiEndpoints, $requestParams, $this->_defaultHeader);
142- // }
143- // }
144-
145- // return $response;
146- // }
147- // $response = HttpHelper::post($apiEndpoints, $requestParams, $this->_defaultHeader);
148- // $response->update = true;
149- // } else {
150- // if (!empty($groupIds)) {
151- // if ('https://connect.mailerlite.com/api/' === $this->_baseUrl) {
152- // $requestParams['groups'] = $splitGroupIds;
153-
154- // if (!empty($this->_actions->double_opt_in)) {
155- // $requestParams['opted_in_at'] = date('Y-m-d H:i:s');
156- // $requestParams['optin_ip'] = $_SERVER['REMOTE_ADDR'];
157- // }
158-
159- // $response = HttpHelper::post($apiEndpoints, $requestParams, $this->_defaultHeader);
160- // } else {
161- // if (!empty($this->_actions->double_opt_in)) {
162- // $this->enableDoubleOptIn($auth_token);
163- // }
164-
165- // for ($i = 0; $i < \count($splitGroupIds); $i++) {
166- // $apiEndpoints = $this->_baseUrl . 'groups/' . $splitGroupIds[$i] . '/subscribers';
167- // $response = HttpHelper::post($apiEndpoints, $requestParams, $this->_defaultHeader);
168- // }
169- // }
170-
171- // return $response;
172- // }
173- // $response = HttpHelper::post($apiEndpoints, $requestParams, $this->_defaultHeader);
174- // }
175-
176- // return $response;
177- // }
178-
17985 public function addSubscriber ($ auth_token , $ groupIds , $ type , $ finalData )
18086 {
18187 if (empty ($ finalData ['email ' ])) {
0 commit comments