--- 1.patch	2023-04-20 17:02:22.654042597 +0530
+++ phpcs-3354242-4.patch	2023-04-20 17:00:08.061083179 +0530
@@ -114,7 +114,7 @@
 \ No newline at end of file
 +  base_route: sendpulse_api.config
 diff --git a/sendpulse_api.module b/sendpulse_api.module
-index 40e1927..8d2d52f 100644
+index 40e1927..d97eddf 100644
 --- a/sendpulse_api.module
 +++ b/sendpulse_api.module
 @@ -6,12 +6,9 @@
@@ -355,12 +355,13 @@
              $data['mailing_list_id'] = $list_data[0]['value'];
            }
            $response = $cc->unsubscribeContact($data, $lists);
-@@ -250,4 +252,4 @@ function _sendpulse_api_entity_subscribe_on_save($entity, $op = 'update') {
+@@ -250,4 +252,5 @@ function _sendpulse_api_entity_subscribe_on_save($entity, $op = 'update') {
        }
      }
    }
 -}
 \ No newline at end of file
++  return $response;
 +}
 diff --git a/sendpulse_api.permissions.yml b/sendpulse_api.permissions.yml
 index cb26311..4e825a3 100644
@@ -373,7 +374,7 @@
 \ No newline at end of file
 +  restrict access: TRUE
 diff --git a/src/Controller/AuthenticationCallback.php b/src/Controller/AuthenticationCallback.php
-index e82e3e6..debc984 100644
+index e82e3e6..5bc93e5 100644
 --- a/src/Controller/AuthenticationCallback.php
 +++ b/src/Controller/AuthenticationCallback.php
 @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -384,13 +385,19 @@
  /**
   * Sendpulse Api Callback Controller.
   *
-@@ -101,20 +102,20 @@ class AuthenticationCallback extends ControllerBase {
-     $api_secret = isset($settings['api_secret']) ? $settings['api_secret'] : NULL;
-     $tokenUrl = isset($settings['token_url']) ? $settings['token_url'] : NULL;
-     $client_secret = isset($settings['client_secret']) ? $settings['client_secret'] : NULL;
+@@ -98,23 +99,23 @@ class AuthenticationCallback extends ControllerBase {
+     $errorDescription = $request->get('error_description');
+ 
+     $settings = $this->sendpulseApi->getConfig();
+-    $api_secret = isset($settings['api_secret']) ? $settings['api_secret'] : NULL;
+-    $tokenUrl = isset($settings['token_url']) ? $settings['token_url'] : NULL;
+-    $client_secret = isset($settings['client_secret']) ? $settings['client_secret'] : NULL;
 -    $codeVerifier = isset($settings['code_verifier']) ? $settings['code_verifier'] : NULL;
 -
 -    $hasRequiredFields = false;
++    $api_secret = $settings['api_secret'] ?? NULL;
++    $tokenUrl = $settings['token_url'] ?? NULL;
++    $client_secret = $settings['client_secret'] ?? NULL;
 +    // $codeVerifier = isset($settings['code_verifier']) ?
 +    // $settings['code_verifier'] : NULL;
 +    $hasRequiredFields = FALSE;
@@ -479,7 +486,7 @@
 \ No newline at end of file
 +}
 diff --git a/src/Form/SendpulseApiBlockForm.php b/src/Form/SendpulseApiBlockForm.php
-index cb1686c..64eb1fb 100644
+index cb1686c..b999b23 100644
 --- a/src/Form/SendpulseApiBlockForm.php
 +++ b/src/Form/SendpulseApiBlockForm.php
 @@ -38,7 +38,7 @@ class SendpulseApiBlockForm extends FormBase {
@@ -624,10 +631,11 @@
          if ($listConfig['lists_user_select'] === 1) {
            $form['list_id'] = [
 -            '#type' =>  'checkboxes',
-+            '#type' => 'checkboxes',
-             '#title' => isset($listConfig['lists_select_label']) ? $listConfig['lists_select_label'] : $this->t('Sign me up for:'),
+-            '#title' => isset($listConfig['lists_select_label']) ? $listConfig['lists_select_label'] : $this->t('Sign me up for:'),
 -            '#required' => true,
 -            '#options' => $options
++            '#type' => 'checkboxes',
++            '#title' => $listConfig['lists_select_label'] ?? $this->t('Sign me up for:'),
 +            '#required' => TRUE,
 +            '#options' => $options,
            ];
@@ -671,7 +679,7 @@
      }
  
 diff --git a/src/Form/SendpulseApiConfig.php b/src/Form/SendpulseApiConfig.php
-index ce80057..5c28ff3 100755
+index ce80057..4515818 100755
 --- a/src/Form/SendpulseApiConfig.php
 +++ b/src/Form/SendpulseApiConfig.php
 @@ -15,8 +15,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
@@ -733,11 +741,14 @@
 -  {
 +  public function buildForm(array $form, FormStateInterface $form_state) {
      $settings = $this->sendpulseApi->getConfig();
-     $api_user_id = isset($settings['api_user_id']) ? $settings['api_user_id'] : NULL;
-     $api_secret = isset($settings['api_secret']) ? $settings['api_secret'] : NULL;
-     $configType = isset($settings['config_type']) ? $settings['config_type'] : 'config';
+-    $api_user_id = isset($settings['api_user_id']) ? $settings['api_user_id'] : NULL;
+-    $api_secret = isset($settings['api_secret']) ? $settings['api_secret'] : NULL;
+-    $configType = isset($settings['config_type']) ? $settings['config_type'] : 'config';
 -    $codeChallenge = null;
 -
++    $api_user_id = $settings['api_user_id'] ?? NULL;
++    $api_secret = $settings['api_secret'] ?? NULL;
++    $configType = $settings['config_type'] ?? 'config';
 +    // $codeChallenge = NULL;
      if (version_compare(PHP_VERSION, '8.0', '<')) {
        $this->messenger->addMessage($this->t('The Sendpulse module is not compatible with your current version of PHP and should be upgraded to latest version or greater than 8.0.'), 'error');
@@ -841,11 +852,21 @@
            foreach ($lists as $list) {
              $output[$list->list_id] = [
 diff --git a/src/Plugin/ApiClient.php b/src/Plugin/ApiClient.php
-index afa6c19..fcd2124 100755
+index afa6c19..ddf3133 100755
 --- a/src/Plugin/ApiClient.php
 +++ b/src/Plugin/ApiClient.php
-@@ -11,565 +11,547 @@
+@@ -1,575 +1,644 @@
+ <?php
  
+-/*
+- * SendPulse REST API Client
+- *
+- * Documentation
+- * https://sendpulse.com/integrations/api
+- * https://sendpulse.com/api
+- *
+- */
+-
  namespace Drupal\sendpulse_api\Plugin;
  
 -use Exception;
@@ -1408,20 +1429,50 @@
 -     */
 -    public function createCampaign(
 +/**
-+ *
++ * ApiClient class implements ApiInterface.
 + */
 +class ApiClient implements ApiInterface {
-+
++  /**
++   * ApiUrl harcoded.
++   *
++   * @var string
++   */
 +  private $apiUrl = 'https://api.sendpulse.com';
-+
++  /**
++   * UserId of the API.
++   *
++   * @var string
++   */
 +  private $userId;
++  /**
++   * Secret variable.
++   *
++   * @var string
++   */
 +  private $secret;
++  /**
++   * Token for the API.
++   *
++   * @var string
++   */
 +  private $token;
 +
++  /**
++   * Count of refresh token.
++   *
++   * @var int
++   */
 +  private $refreshToken = 0;
++  /**
++   * Boolean retry.
++   *
++   * @var bool
++   */
 +  private $retry = FALSE;
 +
 +  /**
++   * Token Storage variable.
++   *
 +   * @var null|TokenStorageInterface
 +   */
 +  private $tokenStorage;
@@ -1429,11 +1480,15 @@
 +  /**
 +   * Sendpulse API constructor.
 +   *
-+   * @param $userId
-+   * @param $secret
++   * @param string $userId
++   *   UserID variable.
++   * @param string $secret
++   *   Secret variable.
 +   * @param TokenStorageInterface $tokenStorage
++   *   TokenStorage variable.
 +   *
 +   * @throws \Exception
++   *    Construct function.
 +   */
 +  public function __construct($userId, $secret, TokenStorageInterface $tokenStorage = NULL) {
 +    if ($tokenStorage === NULL) {
@@ -1447,9 +1502,8 @@
 +    $this->userId = $userId;
 +    $this->secret = $secret;
 +    $this->tokenStorage = $tokenStorage;
-+    $hashName = md5($userId . '::' . $secret);
-+
-+    /** load token from storage */
++    // $hashName = md5($userId . '::' . $secret);
++    // Load token from storage.
 +    // $this->token = $this->tokenStorage->get($hashName);
 +    $this->token = '';
 +
@@ -1462,6 +1516,7 @@
 +   * Get token and store it.
 +   *
 +   * @return bool
++   *   Returns boolean value.
 +   */
 +  private function getToken() {
 +    $data = [
@@ -1479,8 +1534,8 @@
 +    $this->refreshToken = 0;
 +    $this->token = $requestResult->data->access_token;
 +
-+    $hashName = md5($this->userId . '::' . $this->secret);
-+    /** Save token to storage */
++    // $hashName = md5($this->userId . '::' . $this->secret);
++    // Save token to storage
 +    // $this->tokenStorage->set($hashName, $this->token);
 +    return TRUE;
 +  }
@@ -1488,12 +1543,17 @@
 +  /**
 +   * Form and send request to API service.
 +   *
-+   * @param $path
++   * @param string $path
++   *   Path variable.
 +   * @param string $method
++   *   Method variable.
 +   * @param array $data
++   *   Data variable.
 +   * @param bool $useToken
++   *   useToken variable.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  protected function sendRequest($path, $method = 'GET', $data = [], $useToken = TRUE) {
 +    $url = $this->apiUrl . '/' . $path;
@@ -1567,9 +1627,11 @@
 +  /**
 +   * Process results.
 +   *
-+   * @param $data
++   * @param string $data
++   *   Data variable.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  protected function handleResult($data) {
 +    if (empty($data->data)) {
@@ -1592,8 +1654,10 @@
 +   * Process errors.
 +   *
 +   * @param null $customMessage
++   *   customMessage variable.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  protected function handleError($customMessage = NULL) {
 +    $message = new \stdClass();
@@ -1612,9 +1676,11 @@
 +  /**
 +   * Create address book.
 +   *
-+   * @param $bookName
++   * @param string $bookName
++   *   Bookname variable.
 +   *
 +   * @return object
++   *   Returns Object value.
 +   */
 +  public function createAddressBook($bookName) {
 +    if (empty($bookName)) {
@@ -1630,10 +1696,13 @@
 +  /**
 +   * Edit address book name.
 +   *
-+   * @param $id
-+   * @param $newName
++   * @param int $id
++   *   Id variable.
++   * @param string $newName
++   *   Variable newName.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function editAddressBook($id, $newName) {
 +    if (empty($newName) || empty($id)) {
@@ -1649,9 +1718,11 @@
 +  /**
 +   * Remove address book.
 +   *
-+   * @param $id
++   * @param int $id
++   *   Id variable.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function removeAddressBook($id) {
 +    if (empty($id)) {
@@ -1667,9 +1738,12 @@
 +   * Get list of address books.
 +   *
 +   * @param null $limit
++   *   Limit variable.
 +   * @param null $offset
++   *   Offset variable.
 +   *
 +   * @return mixed
++   *   Returns mixed value.
 +   */
 +  public function listAddressBooks($limit = NULL, $offset = NULL) {
 +    $data = [];
@@ -1688,9 +1762,11 @@
 +  /**
 +   * Get information about book.
 +   *
-+   * @param $id
++   * @param int $id
++   *   Id variable.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function getBookInfo($id) {
 +    if (empty($id)) {
@@ -1705,10 +1781,11 @@
 +  /**
 +   * Get variables from book.
 +   *
-+   * @param $id
++   * @param int $id
 +   *   Address book id.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function getBookVariables($id) {
 +    if (empty($id)) {
@@ -1724,12 +1801,14 @@
 +   * Change varible by user email.
 +   *
 +   * @param int $bookID
++   *   Book id.
 +   * @param string $email
 +   *   User email.
 +   * @param array $vars
 +   *   User vars in [key=>value] format.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function updateEmailVariables(int $bookID, string $email, array $vars) {
 +    if (empty($bookID)) {
@@ -1749,11 +1828,15 @@
 +  /**
 +   * List email addresses from book.
 +   *
-+   * @param $id
-+   * @param $limit
-+   * @param $offset
++   * @param int $id
++   *   ID.
++   * @param int $limit
++   *   Limit.
++   * @param int $offset
++   *   Offset.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function getEmailsFromBook($id, $limit = NULL, $offset = NULL) {
 +    if (empty($id)) {
@@ -1776,11 +1859,15 @@
 +  /**
 +   * Add new emails to address book.
 +   *
-+   * @param $bookID
-+   * @param $emails
-+   * @param $additionalParams
++   * @param int $bookID
++   *   Book ID.
++   * @param string $emails
++   *   Email.
++   * @param array $additionalParams
++   *   Additional Parameters.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function addEmails($bookID, $emails, $additionalParams = []) {
 +    if (empty($bookID) || empty($emails)) {
@@ -1803,10 +1890,13 @@
 +  /**
 +   * Remove email addresses from book.
 +   *
-+   * @param $bookID
-+   * @param $emails
++   * @param int $bookID
++   *   Book ID.
++   * @param string $emails
++   *   Email.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function removeEmails($bookID, $emails) {
 +    if (empty($bookID) || empty($emails)) {
@@ -1825,10 +1915,13 @@
 +  /**
 +   * Get information about email address from book.
 +   *
-+   * @param $bookID
-+   * @param $email
++   * @param int $bookID
++   *   BookID.
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Returns Object value.
 +   */
 +  public function getEmailInfo($bookID, $email) {
 +    if (empty($bookID) || empty($email)) {
@@ -1843,9 +1936,11 @@
 +  /**
 +   * Get cost of campaign based on address book.
 +   *
-+   * @param $bookID
++   * @param int $bookID
++   *   Book ID.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function campaignCost($bookID) {
 +    if (empty($bookID)) {
@@ -1861,9 +1956,12 @@
 +   * Get list of campaigns.
 +   *
 +   * @param null $limit
++   *   Limit.
 +   * @param null $offset
++   *   Offset.
 +   *
 +   * @return mixed
++   *   Returns mixed value.
 +   */
 +  public function listCampaigns($limit = NULL, $offset = NULL) {
 +    $data = [];
@@ -1881,9 +1979,11 @@
 +  /**
 +   * Get information about campaign.
 +   *
-+   * @param $id
++   * @param int $id
++   *   ID.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function getCampaignInfo($id) {
 +    if (empty($id)) {
@@ -1898,9 +1998,11 @@
 +  /**
 +   * Get campaign statistic by countries.
 +   *
-+   * @param $id
++   * @param int $id
++   *   ID.
 +   *
 +   * @return object
++   *   Returns object variable.
 +   */
 +  public function campaignStatByCountries($id) {
 +    if (empty($id)) {
@@ -1915,9 +2017,11 @@
 +  /**
 +   * Get campaign statistic by referrals.
 +   *
-+   * @param $id
++   * @param int $id
++   *   ID.
 +   *
 +   * @return object
++   *   Retuns object value.
 +   */
 +  public function campaignStatByReferrals($id) {
 +    if (empty($id)) {
@@ -1932,26 +2036,39 @@
 +  /**
 +   * Create new campaign.
 +   *
-+   * @param $senderName
-+   * @param $senderEmail
-+   * @param $subject
-+   * @param $bodyOrTemplateId
-+   * @param $bookId
++   * @param string $senderName
++   *   SenderName.
++   * @param string $senderEmail
++   *   SenderEmail.
++   * @param string $subject
++   *   Subject.
++   * @param string $bodyOrTemplateId
++   *   Body.
++   * @param int $bookId
++   *   BookID.
 +   * @param string $name
++   *   Name.
 +   * @param array $attachments
++   *   Attachments.
 +   * @param string $type
++   *   Type.
 +   * @param bool $useTemplateId
++   *   Boolean.
 +   * @param string $sendDate
++   *   Send Date.
 +   * @param int|null $segmentId
++   *   Segment Id.
 +   * @param array $attachmentsBinary
++   *   Attachment.
 +   *
 +   * @return mixed
++   *   Returns mixed value.
 +   */
 +  public function createCampaign(
          $senderName,
          $senderEmail,
          $subject,
-@@ -578,1054 +560,1021 @@ class ApiClient implements ApiInterface
+@@ -578,1054 +647,1143 @@ class ApiClient implements ApiInterface
          $name = '',
          $attachments = [],
          $type = '',
@@ -2002,11 +2119,8 @@
 -        $requestResult = $this->sendRequest('campaigns', 'POST', $data);
 -
 -        return $this->handleResult($requestResult);
-+    ) {
-+    if (empty($senderName) || empty($senderEmail) || empty($subject) || empty($bodyOrTemplateId) || empty($bookId)) {
-+      return $this->handleError('Not all data.');
-     }
- 
+-    }
+-
 -    /**
 -     * Cancel campaign
 -     *
@@ -2023,10 +2137,7 @@
 -        $requestResult = $this->sendRequest('campaigns/' . $id, 'DELETE');
 -
 -        return $this->handleResult($requestResult);
-+    if ($useTemplateId) {
-+      $paramName = 'template_id';
-+      $paramValue = $bodyOrTemplateId;
-     }
+-    }
 -
 -    /**
 -     * List all senders
@@ -2038,11 +2149,8 @@
 -        $requestResult = $this->sendRequest('senders');
 -
 -        return $this->handleResult($requestResult);
-+    else {
-+      $paramName = 'body';
-+      $paramValue = base64_encode($bodyOrTemplateId);
-     }
- 
+-    }
+-
 -    /**
 -     * List SMS senders
 -     *
@@ -2075,21 +2183,22 @@
 -        );
 -
 -        $requestResult = $this->sendRequest('senders', 'POST', $data);
-+    $data = [
-+      'sender_name' => $senderName,
-+      'sender_email' => $senderEmail,
-+      'subject' => $subject,
-+      $paramName => $paramValue,
-+      'list_id' => $bookId,
-+      'name' => $name,
-+      'type' => $type,
-+    ];
- 
+-
 -        return $this->handleResult($requestResult);
-+    if (!empty($attachments)) {
-+      $data['attachments'] = $attachments;
++    ) {
++    if (empty($senderName) || empty($senderEmail) || empty($subject) || empty($bodyOrTemplateId) || empty($bookId)) {
++      return $this->handleError('Not all data.');
++    }
++
++    if ($useTemplateId) {
++      $paramName = 'template_id';
++      $paramValue = $bodyOrTemplateId;
++    }
++    else {
++      $paramName = 'body';
++      $paramValue = base64_encode($bodyOrTemplateId);
      }
--
+ 
 -    /**
 -     * Remove sender
 -     *
@@ -2110,10 +2219,8 @@
 -        $requestResult = $this->sendRequest('senders', 'DELETE', $data);
 -
 -        return $this->handleResult($requestResult);
-+    elseif (!empty($attachmentsBinary)) {
-+      $data['attachments_binary'] = $attachmentsBinary;
-     }
- 
+-    }
+-
 -    /**
 -     * Activate sender using code
 -     *
@@ -2135,10 +2242,8 @@
 -        $requestResult = $this->sendRequest('senders/' . $email . '/code', 'POST', $data);
 -
 -        return $this->handleResult($requestResult);
-+    if (!empty($sendDate)) {
-+      $data['send_date'] = $sendDate;
-     }
- 
+-    }
+-
 -    /**
 -     * Request mail with activation code
 -     *
@@ -2151,13 +2256,9 @@
 -        if (empty($email)) {
 -            return $this->handleError('Empty email');
 -        }
-+    if (!empty($segmentId)) {
-+      $data['segment_id'] = $segmentId;
-+    }
- 
+-
 -        $requestResult = $this->sendRequest('senders/' . $email . '/code');
-+    $requestResult = $this->sendRequest('campaigns', 'POST', $data);
- 
+-
 -        return $this->handleResult($requestResult);
 -    }
 -
@@ -2173,24 +2274,12 @@
 -        if (empty($email)) {
 -            return $this->handleError('Empty email');
 -        }
-+    return $this->handleResult($requestResult);
-+  }
- 
+-
 -        $requestResult = $this->sendRequest('emails/' . $email);
 -
 -        return $this->handleResult($requestResult);
-+  /**
-+   * Cancel campaign.
-+   *
-+   * @param $id
-+   *
-+   * @return object
-+   */
-+  public function cancelCampaign($id) {
-+    if (empty($id)) {
-+      return $this->handleError('Empty campaign id');
-     }
- 
+-    }
+-
 -    /**
 -     * Get global information about list of emails
 -     *
@@ -2202,36 +2291,12 @@
 -        if (empty($emails)) {
 -            return $this->handleError('Empty emails list');
 -        }
-+    $requestResult = $this->sendRequest('campaigns/' . $id, 'DELETE');
-+
-+    return $this->handleResult($requestResult);
-+  }
-+
-+  /**
-+   * List all senders.
-+   *
-+   * @return mixed
-+   */
-+  public function listSenders() {
-+    $requestResult = $this->sendRequest('senders');
- 
+-
 -        $requestResult = $this->sendRequest('emails', 'POST', $emails);
-+    return $this->handleResult($requestResult);
-+  }
-+
-+  /**
-+   * List SMS senders.
-+   *
-+   * @return mixed
-+   */
-+  public function listSMSSenders() {
-+    $requestResult = $this->sendRequest('sms/senders');
- 
+-
 -        return $this->handleResult($requestResult);
 -    }
-+    return $this->handleResult($requestResult);
-+  }
- 
+-
 -    /**
 -     * Remove email from all books
 -     *
@@ -2244,27 +2309,9 @@
 -        if (empty($email)) {
 -            return $this->handleError('Empty email');
 -        }
-+  /**
-+   * Add new sender.
-+   *
-+   * @param $senderName
-+   * @param $senderEmail
-+   *
-+   * @return object
-+   */
-+  public function addSender($senderName, $senderEmail) {
-+    if (empty($senderName) || empty($senderEmail)) {
-+      return $this->handleError('Empty sender name or email');
-+    }
-+
-+    $data = [
-+      'email' => $senderEmail,
-+      'name' => $senderName,
-+    ];
- 
+-
 -        $requestResult = $this->sendRequest('emails/' . $email, 'DELETE');
-+    $requestResult = $this->sendRequest('senders', 'POST', $data);
- 
+-
 -        return $this->handleResult($requestResult);
 -    }
 -
@@ -3091,15 +3138,113 @@
 -    }
 -}
 \ No newline at end of file
++    $data = [
++      'sender_name' => $senderName,
++      'sender_email' => $senderEmail,
++      'subject' => $subject,
++      $paramName => $paramValue,
++      'list_id' => $bookId,
++      'name' => $name,
++      'type' => $type,
++    ];
++
++    if (!empty($attachments)) {
++      $data['attachments'] = $attachments;
++    }
++    elseif (!empty($attachmentsBinary)) {
++      $data['attachments_binary'] = $attachmentsBinary;
++    }
++
++    if (!empty($sendDate)) {
++      $data['send_date'] = $sendDate;
++    }
++
++    if (!empty($segmentId)) {
++      $data['segment_id'] = $segmentId;
++    }
++
++    $requestResult = $this->sendRequest('campaigns', 'POST', $data);
++
++    return $this->handleResult($requestResult);
++  }
++
++  /**
++   * Cancel campaign.
++   *
++   * @param int $id
++   *   Id.
++   *
++   * @return object
++   *   Returns object value.
++   */
++  public function cancelCampaign($id) {
++    if (empty($id)) {
++      return $this->handleError('Empty campaign id');
++    }
++
++    $requestResult = $this->sendRequest('campaigns/' . $id, 'DELETE');
++
++    return $this->handleResult($requestResult);
++  }
++
++  /**
++   * List all senders.
++   *
++   * @return mixed
++   *   Returns mixed value.
++   */
++  public function listSenders() {
++    $requestResult = $this->sendRequest('senders');
++
++    return $this->handleResult($requestResult);
++  }
++
++  /**
++   * List SMS senders.
++   *
++   * @return mixed
++   *   Return mixed value.
++   */
++  public function listSmsSenders() {
++    $requestResult = $this->sendRequest('sms/senders');
++
++    return $this->handleResult($requestResult);
++  }
++
++  /**
++   * Add new sender.
++   *
++   * @param string $senderName
++   *   SenderName.
++   * @param string $senderEmail
++   *   Sender Email.
++   *
++   * @return object
++   *   Returns Object value.
++   */
++  public function addSender($senderName, $senderEmail) {
++    if (empty($senderName) || empty($senderEmail)) {
++      return $this->handleError('Empty sender name or email');
++    }
++
++    $data = [
++      'email' => $senderEmail,
++      'name' => $senderName,
++    ];
++
++    $requestResult = $this->sendRequest('senders', 'POST', $data);
++
 +    return $this->handleResult($requestResult);
 +  }
 +
 +  /**
 +   * Remove sender.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function removeSender($email) {
 +    if (empty($email)) {
@@ -3118,10 +3263,13 @@
 +  /**
 +   * Activate sender using code.
 +   *
-+   * @param $email
-+   * @param $code
++   * @param string $email
++   *   Email.
++   * @param string $code
++   *   Code.
 +   *
 +   * @return object
++   *   Returns object value.
 +   */
 +  public function activateSender($email, $code) {
 +    if (empty($email) || empty($code)) {
@@ -3140,9 +3288,11 @@
 +  /**
 +   * Request mail with activation code.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function getSenderActivationMail($email) {
 +    if (empty($email)) {
@@ -3157,9 +3307,11 @@
 +  /**
 +   * Get global information about email.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getEmailGlobalInfo($email) {
 +    if (empty($email)) {
@@ -3178,6 +3330,7 @@
 +   *   Emails list.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getEmailsGlobalInfo($emails) {
 +    if (empty($emails)) {
@@ -3192,9 +3345,11 @@
 +  /**
 +   * Remove email from all books.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function removeEmailFromAllBooks($email) {
 +    if (empty($email)) {
@@ -3209,9 +3364,11 @@
 +  /**
 +   * Get email statistic by all campaigns.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Returns Object.
 +   */
 +  public function emailStatByCampaigns($email) {
 +    if (empty($email)) {
@@ -3227,6 +3384,7 @@
 +   * Get all emails from blacklist.
 +   *
 +   * @return mixed
++   *   Returns mixed value.
 +   */
 +  public function getBlackList() {
 +    $requestResult = $this->sendRequest('blacklist');
@@ -3237,11 +3395,13 @@
 +  /**
 +   * Add email to blacklist.
 +   *
-+   * @param $emails
-+   *   - string with emails, separator - ,
++   * @param string $emails
++   *   String with emails, separator.
 +   * @param string $comment
++   *   Comment.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function addToBlackList($emails, $comment = '') {
 +    if (empty($emails)) {
@@ -3261,10 +3421,11 @@
 +  /**
 +   * Remove emails from blacklist.
 +   *
-+   * @param $emails
-+   *   - string with emails, separator - ,
++   * @param string $emails
++   *   String with emails, separator.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function removeFromBlackList($emails) {
 +    if (empty($emails)) {
@@ -3284,8 +3445,10 @@
 +   * Get balance.
 +   *
 +   * @param string $currency
++   *   Currency.
 +   *
 +   * @return mixed
++   *   Returns mixed.
 +   */
 +  public function getBalance($currency = '') {
 +    $currency = strtoupper($currency);
@@ -3303,14 +3466,22 @@
 +   * SMTP: get list of emails.
 +   *
 +   * @param int $limit
++   *   Limit.
 +   * @param int $offset
++   *   Offset.
 +   * @param string $fromDate
++   *   FromDate.
 +   * @param string $toDate
++   *   ToDate.
 +   * @param string $sender
++   *   Sender.
 +   * @param string $recipient
++   *   Recipient.
 +   * @param string $country
++   *   Country.
 +   *
 +   * @return mixed
++   *   Returns mixed.
 +   */
 +  public function smtpListEmails($limit = 0, $offset = 0, $fromDate = '', $toDate = '', $sender = '', $recipient = '', $country = 'off') {
 +    $data = [
@@ -3331,9 +3502,11 @@
 +  /**
 +   * Get information about email by id.
 +   *
-+   * @param $id
++   * @param int $id
++   *   ID.
 +   *
 +   * @return object
++   *   Returns object
 +   */
 +  public function smtpGetEmailInfoById($id) {
 +    if (empty($id)) {
@@ -3349,9 +3522,12 @@
 +   * SMTP: get list of unsubscribed emails.
 +   *
 +   * @param null $limit
++   *   Limit.
 +   * @param null $offset
++   *   Offset.
 +   *
 +   * @return mixed
++   *   Returns mixed.
 +   */
 +  public function smtpListUnsubscribed($limit = NULL, $offset = NULL) {
 +    $data = [];
@@ -3370,9 +3546,11 @@
 +  /**
 +   * SMTP: add emails to unsubscribe list.
 +   *
-+   * @param $emails
++   * @param string $emails
++   *   Email.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function smtpUnsubscribeEmails($emails) {
 +    if (empty($emails)) {
@@ -3391,9 +3569,11 @@
 +  /**
 +   * SMTP: remove emails from unsubscribe list.
 +   *
-+   * @param $emails
++   * @param string $emails
++   *   Emails.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function smtpRemoveFromUnsubscribe($emails) {
 +    if (empty($emails)) {
@@ -3413,8 +3593,9 @@
 +   * Get list of IP.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
-+  public function smtpListIP() {
++  public function smtpListIp() {
 +    $requestResult = $this->sendRequest('smtp/ips');
 +
 +    return $this->handleResult($requestResult);
@@ -3424,6 +3605,7 @@
 +   * SMTP: get list of allowed domains.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function smtpListAllowedDomains() {
 +    $requestResult = $this->sendRequest('smtp/domains');
@@ -3434,9 +3616,11 @@
 +  /**
 +   * SMTP: add new domain.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function smtpAddDomain($email) {
 +    if (empty($email)) {
@@ -3455,9 +3639,11 @@
 +  /**
 +   * SMTP: verify domain.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Returns object.
 +   */
 +  public function smtpVerifyDomain($email) {
 +    if (empty($email)) {
@@ -3472,9 +3658,11 @@
 +  /**
 +   * SMTP: send mail.
 +   *
-+   * @param $email
++   * @param string $email
++   *   Email.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function smtpSendMail($email) {
 +    if (empty($email)) {
@@ -3506,9 +3694,12 @@
 +   * Get list of push campaigns.
 +   *
 +   * @param null $limit
++   *   Limit.
 +   * @param null $offset
++   *   Offset.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushListCampaigns($limit = NULL, $offset = NULL) {
 +    $data = [];
@@ -3528,9 +3719,12 @@
 +   * Get list of websites.
 +   *
 +   * @param null $limit
++   *   Limit.
 +   * @param null $offset
++   *   Offset.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushListWebsites($limit = NULL, $offset = NULL) {
 +    $data = [];
@@ -3550,6 +3744,7 @@
 +   * Get amount of websites.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushCountWebsites() {
 +    $requestResult = $this->sendRequest('push/websites/total');
@@ -3560,9 +3755,11 @@
 +  /**
 +   * Get list of all variables for website.
 +   *
-+   * @param $websiteId
++   * @param string $websiteId
++   *   WebsiteID.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushListWebsiteVariables($websiteId) {
 +    $requestResult = $this->sendRequest('push/websites/' . $websiteId . '/variables');
@@ -3573,12 +3770,15 @@
 +  /**
 +   * Get list of subscriptions for the website.
 +   *
-+   * @param $websiteID
-+   *
++   * @param string $websiteID
++   *   WebsiteID.
 +   * @param null $limit
++   *   Limit.
 +   * @param null $offset
++   *   Offset.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushListWebsiteSubscriptions($websiteID, $limit = NULL, $offset = NULL) {
 +    $data = [];
@@ -3597,9 +3797,11 @@
 +  /**
 +   * Get amount of subscriptions for the site.
 +   *
-+   * @param $websiteID
++   * @param string $websiteID
++   *   WebsiteID.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushCountWebsiteSubscriptions($websiteID) {
 +    $requestResult = $this->sendRequest('push/websites/' . $websiteID . '/subscriptions/total');
@@ -3610,10 +3812,13 @@
 +  /**
 +   * Set state for subscription.
 +   *
-+   * @param $subscriptionID
-+   * @param $stateValue
++   * @param int $subscriptionID
++   *   Subscribe id.
++   * @param int $stateValue
++   *   Value.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushSetSubscriptionState($subscriptionID, $stateValue) {
 +    $data = [
@@ -3629,9 +3834,11 @@
 +  /**
 +   * Get common website info.
 +   *
-+   * @param $websiteId
++   * @param int $websiteId
++   *   websiteID.
 +   *
 +   * @return mixed
++   *   Return mixed.
 +   */
 +  public function pushGetWebsiteInfo($websiteId) {
 +    $requestResult = $this->sendRequest('push/websites/info/' . $websiteId);
@@ -3642,10 +3849,13 @@
 +  /**
 +   * Create new push campaign.
 +   *
-+   * @param $taskInfo
++   * @param string $taskInfo
++   *   TaskInfo.
 +   * @param array $additionalParams
++   *   Additional parameters.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function createPushTask($taskInfo, array $additionalParams = []) {
 +    $data = $taskInfo;
@@ -3669,9 +3879,11 @@
 +  /**
 +   * Get integration code for Push Notifications.
 +   *
-+   * @param $websiteID
++   * @param int $websiteID
++   *   websiteId.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getPushIntegrationCode($websiteID) {
 +    if (empty($websiteID)) {
@@ -3686,9 +3898,11 @@
 +  /**
 +   * Get stats for push campaign.
 +   *
-+   * @param $campaignID
++   * @param int $campaignID
++   *   Campaign id.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getPushCampaignStat($campaignID) {
 +    $requestResult = $this->sendRequest('push/tasks/' . $campaignID);
@@ -3697,10 +3911,15 @@
 +  }
 +
 +  /**
-+   * @Author Maksym Dzhym m.jim@sendpulse.com
-+   * @param $eventName
++   * StartEvent Automation.
++   *
++   * @param string $eventName
++   *   Event Name.
 +   * @param array $variables
++   *   Array of Variables.
++   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function startEventAutomation360($eventName, array $variables) {
 +    if (!$eventName) {
@@ -3718,10 +3937,13 @@
 +  /**
 +   * Add phones to addressbook.
 +   *
-+   * @param $bookID
++   * @param int $bookID
++   *   BookID.
 +   * @param array $phones
++   *   Phones.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function addPhones($bookID, array $phones) {
 +    if (empty($bookID)) {
@@ -3741,10 +3963,13 @@
 +  /**
 +   * Add phones with variables to addressbook.
 +   *
-+   * @param $bookID
-+   * @param array $phones
++   * @param int $bookID
++   *   BookID.
++   * @param array $phonesWithVariables
++   *   Phones.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function addPhonesWithVariables($bookID, array $phonesWithVariables) {
 +    if (empty($bookID)) {
@@ -3764,11 +3989,15 @@
 +  /**
 +   * Update variables for phones.
 +   *
-+   * @param $bookID
++   * @param int $bookID
++   *   BookID.
 +   * @param array $phones
++   *   Phones.
 +   * @param array $variables
++   *   Array of variables.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function updatePhoneVaribales($bookID, array $phones, array $variables) {
 +    if (empty($bookID)) {
@@ -3789,10 +4018,13 @@
 +  /**
 +   * Delete phones from book.
 +   *
-+   * @param $bookID
++   * @param int $bookID
++   *   BookID.
 +   * @param array $phones
++   *   Phones.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function deletePhones($bookID, array $phones) {
 +    if (empty($bookID)) {
@@ -3812,10 +4044,13 @@
 +  /**
 +   * Get information about phone number.
 +   *
-+   * @param $bookID
-+   * @param $phoneNumber
++   * @param string $bookID
++   *   BookID.
++   * @param string $phoneNumber
++   *   PhoneNumber.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getPhoneInfo($bookID, $phoneNumber) {
 +    if (empty($bookID)) {
@@ -3830,10 +4065,11 @@
 +  /**
 +   * Add phones to blacklist.
 +   *
-+   * @param $bookID
 +   * @param array $phones
++   *   Phones.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function addPhonesToBlacklist(array $phones) {
 +    $data = [
@@ -3849,8 +4085,10 @@
 +   * Delete phones from blacklist.
 +   *
 +   * @param array $phones
++   *   Phones.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function removePhonesFromBlacklist(array $phones) {
 +    $data = [
@@ -3866,6 +4104,7 @@
 +   * Get list of phones from blacklist.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getPhonesFromBlacklist() {
 +    $requestResult = $this->sendRequest('sms/black_list');
@@ -3876,11 +4115,15 @@
 +  /**
 +   * Create sms campaign based on phones in book.
 +   *
-+   * @param $bookID
++   * @param string $bookID
++   *   BookID.
 +   * @param array $params
++   *   Parameters.
 +   * @param array $additionalParams
++   *   Additional Parameters.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function sendSmsByBook($bookID, array $params, array $additionalParams = []) {
 +    if (empty($bookID)) {
@@ -3905,11 +4148,15 @@
 +  /**
 +   * Create sms campaign based on list.
 +   *
-+   * @param $phones
++   * @param array $phones
++   *   Phones.
 +   * @param array $params
++   *   Parameters.
 +   * @param array $additionalParams
++   *   Additional Parameters.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function sendSmsByList(array $phones, array $params, array $additionalParams) {
 +    $data = [
@@ -3930,9 +4177,11 @@
 +  /**
 +   * List sms campaigns.
 +   *
-+   * @param $params
++   * @param array $params
++   *   Parameters.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function listSmsCampaigns(array $params = NULL) {
 +    $requestResult = $this->sendRequest('sms/campaigns/list', 'GET', $params);
@@ -3943,9 +4192,11 @@
 +  /**
 +   * Get info about sms campaign.
 +   *
-+   * @param $campaignID
++   * @param string $campaignID
++   *   Campaign ID.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getSmsCampaignInfo($campaignID) {
 +    $requestResult = $this->sendRequest('sms/campaigns/info/' . $campaignID);
@@ -3956,9 +4207,11 @@
 +  /**
 +   * Cancel SMS campaign.
 +   *
-+   * @param $campaignID
++   * @param string $campaignID
++   *   Campaign id.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function cancelSmsCampaign($campaignID) {
 +    $requestResult = $this->sendRequest('sms/campaigns/cancel/' . $campaignID, 'PUT');
@@ -3970,9 +4223,12 @@
 +   * Get SMS campaign cost based on book or simple list.
 +   *
 +   * @param array $params
++   *   Parameters.
 +   * @param array|null $additionalParams
++   *   Additional Parameters.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function getSmsCampaignCost(array $params, array $additionalParams = NULL) {
 +    if (!isset($params['addressBookId']) && !isset($params['phones'])) {
@@ -3991,9 +4247,11 @@
 +  /**
 +   * Delete SMS campaign.
 +   *
-+   * @param $campaignID
++   * @param string $campaignID
++   *   Campaign Id.
 +   *
 +   * @return object
++   *   Return object.
 +   */
 +  public function deleteSmsCampaign($campaignID) {
 +    $requestResult = $this->sendRequest('sms/campaigns', 'DELETE', ['id' => $campaignID]);
@@ -4003,7 +4261,7 @@
 +
 +}
 diff --git a/src/Plugin/ApiInterface.php b/src/Plugin/ApiInterface.php
-index c8b3257..ec3855e 100644
+index c8b3257..afd9bcb 100644
 --- a/src/Plugin/ApiInterface.php
 +++ b/src/Plugin/ApiInterface.php
 @@ -1,256 +1,302 @@
@@ -4298,7 +4556,7 @@
 +   *   Subject.
 +   * @param string $body
 +   *   Body.
-+   * @param string $bookID
++   * @param string $bookId
 +   *   Book Id.
 +   * @param string $name
 +   *   Name.
@@ -4459,7 +4717,7 @@
 +   *
 +   * @param string $email
 +   *   Email.
-+   * @param $code
++   * @param string $code
 +   *   Code.
 +   */
 +  public function activateSender($email, $code);
@@ -4549,7 +4807,7 @@
          $limit = 0,
          $offset = 0,
          $fromDate = '',
-@@ -260,273 +306,301 @@ interface ApiInterface
+@@ -260,273 +306,302 @@ interface ApiInterface
          $country = 'off'
      );
  
@@ -4822,7 +5080,7 @@
 -     */
 -    public function deleteSmsCampaign($campaignID);
 +  /**
-+   * Get information about email by his id.
++   * Get information about email by id.
 +   *
 +   * @param string $id
 +   *   ID.
@@ -4858,7 +5116,7 @@
 +  /**
 +   * Get list of allowed IPs using SMTP.
 +   */
-+  public function smtpListIP();
++  public function smtpListIp();
 +
 +  /**
 +   * Get list of allowed domains using SMTP.
@@ -4971,7 +5229,8 @@
 +  public function getPushIntegrationCode($websiteID);
 +
 +  /**
-+   * @Author Maksym Dzhym m.jim@sendpulse.com
++   * Start Event Automtion 360.
++   *
 +   * @param string $eventName
 +   *   Event name.
 +   * @param array $variables
@@ -5026,7 +5285,7 @@
 +   *
 +   * @param string $bookID
 +   *   Book ID.
-+   * @param array $phones
++   * @param array $phoneNumber
 +   *   Phones.
 +   */
 +  public function getPhoneInfo($bookID, $phoneNumber);
@@ -5120,10 +5379,30 @@
  
  }
 diff --git a/src/Plugin/Block/SendpulseApiBlock.php b/src/Plugin/Block/SendpulseApiBlock.php
-index 14d4ecb..7ad2c8e 100644
+index 14d4ecb..7034ac0 100644
 --- a/src/Plugin/Block/SendpulseApiBlock.php
 +++ b/src/Plugin/Block/SendpulseApiBlock.php
-@@ -90,77 +90,78 @@ class SendpulseApiBlock extends BlockBase implements ContainerFactoryPluginInter
+@@ -75,92 +75,93 @@ class SendpulseApiBlock extends BlockBase implements ContainerFactoryPluginInter
+     foreach ($ccConfig['fields'] as $fieldName => $fieldLabel) {
+       $form['cc_fields']['field_' . $fieldName] = [
+         '#type' => 'fieldset',
+-        '#title' => $this->t($fieldLabel),
++        '#title' => $this->t('@label', ['@label' => $fieldLabel]),
+       ];
+ 
+       $form['cc_fields']['field_' . $fieldName][$fieldName] = [
+         '#type' => 'checkbox',
+-        '#title' => $this->t('Display ' . $fieldLabel . ' field?'),
+-        '#default_value' => isset($config[$fieldName]) ? $config[$fieldName] : 0,
++        '#title' => $this->t('Display @label field?', ['@label' => $fieldLabel]),
++        '#default_value' => $config[$fieldName] ?? 0,
+       ];
+       $form['cc_fields']['field_' . $fieldName][$fieldName . '_required'] = [
+         '#type' => 'checkbox',
+-        '#title' => $this->t('Require ' . $fieldLabel . ' field?'),
+-        '#default_value' => isset($config[$fieldName . '_required']) ? $config[$fieldName . '_required'] : 0,
++        '#title' => $this->t('Require @label field?', ['@label' => $fieldLabel]),
++        '#default_value' => $config[$fieldName . '_required'] ?? 0,
        ];
      }
  
@@ -5162,16 +5441,16 @@
 +
 +        $form['custom_fields'][$field->custom_field_id] = [
 +          '#type' => 'fieldset',
-+          '#title' => $this->t($field->label),
++          '#title' => $this->t('@label', ['@label' => $field->label]),
 +        ];
 +        $form['custom_fields'][$field->custom_field_id]['display'] = [
 +          '#type' => 'checkbox',
-+          '#title' => $this->t('Display ' . $field->label . ' field'),
-+          '#default_value' => isset($config['custom_fields'][$field->custom_field_id]['display']) ? $config['custom_fields'][$field->custom_field_id]['display'] : NULL,
++          '#title' => $this->t('Display @label field', ['@label' => $fieldLabel]),
++          '#default_value' => $config['custom_fields'][$field->custom_field_id]['display'] ?? NULL,
 +        ];
 +        $form['custom_fields'][$field->custom_field_id]['required'] = [
 +          '#type' => 'checkbox',
-+          '#title' => $this->t('Require ' . $field->label . ' field'),
++          '#title' => $this->t('Require @label field', ['@label' => $fieldLabel]),
 +          '#default_value' => $field_required,
 +          '#attributes' => $attributes,
 +        ];
@@ -5232,7 +5511,7 @@
 +    $form['success_message'] = [
 +      '#type' => 'textarea',
 +      '#title' => $this->t('Custom Success Message'),
-+      '#default_value' => isset($config['success_message']) ? $config['success_message'] : NULL,
++      '#default_value' => $config['success_message'] ?? NULL,
 +    ];
  
 -      if ($field->type === 'date') {
@@ -5261,10 +5540,10 @@
     * {@inheritdoc}
     */
 diff --git a/src/Plugin/Block/SendpulseApiMultiBlock.php b/src/Plugin/Block/SendpulseApiMultiBlock.php
-index 44ccb8b..a5b67d3 100644
+index 44ccb8b..7547039 100644
 --- a/src/Plugin/Block/SendpulseApiMultiBlock.php
 +++ b/src/Plugin/Block/SendpulseApiMultiBlock.php
-@@ -61,13 +61,13 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
+@@ -61,41 +61,41 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
      $customFields = $this->sendpulseApi->getCustomFields();
      $enabled = $this->config->get('sendpulse_api.enabled_lists')->getRawData();
  
@@ -5280,7 +5559,24 @@
        ];
  
        foreach ($customFields->custom_fields as $field) {
-@@ -87,15 +87,15 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
+         $form['custom_fields'][$field->custom_field_id] = [
+           '#type' => 'fieldset',
+-          '#title' => $this->t($field->label),
++          '#title' => $this->t('@label', ['@label' => $field->label]),
+         ];
+         $form['custom_fields'][$field->custom_field_id]['display'] = [
+           '#type' => 'checkbox',
+-          '#title' => $this->t('Display ' . $field->label . ' field'),
+-          '#default_value' => isset($config['custom_fields'][$field->custom_field_id]['display']) ? $config['custom_fields'][$field->custom_field_id]['display'] : NULL,
++          '#title' => $this->t('Display @label field', ['@label' => $field->label]),
++          '#default_value' => $config['custom_fields'][$field->custom_field_id]['display'] ?? NULL,
+         ];
+         $form['custom_fields'][$field->custom_field_id]['required'] = [
+           '#type' => 'checkbox',
+-          '#title' => $this->t('Require ' . $field->label . ' field'),
+-          '#default_value' => isset($config['custom_fields'][$field->custom_field_id]['required']) ? $config['custom_fields'][$field->custom_field_id]['required'] : NULL,
++          '#title' => $this->t('Require @label field', ['@label' => $field->label]),
++          '#default_value' => $config['custom_fields'][$field->custom_field_id]['required'] ?? NULL,
          ];
          $form['custom_fields'][$field->custom_field_id]['name'] = [
            '#type' => 'hidden',
@@ -5308,7 +5604,24 @@
      $form['body'] = [
        '#type' => 'text_format',
        '#title' => $this->t('Body'),
-@@ -132,8 +132,9 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
+@@ -113,14 +113,14 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
+     $form['success_message'] = [
+       '#type' => 'textarea',
+       '#title' => $this->t('Custom Success Message'),
+-      '#default_value' => isset($config['success_message']) ? $config['success_message'] : NULL,
++      '#default_value' => $config['success_message'] ?? NULL,
+     ];
+ 
+     $form['lists'] = [
+       '#type' => 'checkboxes',
+       '#title' => $this->t('Your Sendpulse Api Lists'),
+       '#description' => $this->t('Check the lists you would like to enable in this block. Note that if a list is missing, make sure it is enabled <a href="/admin/config/services/sendpulse-api/lists" target="_blank">here</a>.'),
+-      '#default_value' => isset($config['lists']) ? $config['lists'] : NULL,
++      '#default_value' => $config['lists'] ?? NULL,
+     ];
+ 
+     if (isset($ccConfig['api_secret'])) {
+@@ -132,21 +132,22 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
              $form['lists']['#options'][$list->list_id] = $list->name;
            }
          }
@@ -5320,6 +5633,29 @@
        $form['lists']['#description'] = $this->t('You must authorize Sendpulse Api before enabling a list.');
      }
  
+     $form['lists_select_label'] = [
+       '#type' => 'textfield',
+       '#title' => $this->t('Label for list checkboxes'),
+-      '#default_value' => isset($config['lists_select_label']) ? $config['lists_select_label'] : 'Sign me up for:',
++      '#default_value' => $config['lists_select_label'] ?? 'Sign me up for:',
+     ];
+ 
+     $form['lists_user_select'] = [
+       '#type' => 'checkbox',
+       '#title' => $this->t('Allow user to choose which lists from above?'),
+-      '#default_value' => isset($config['lists_user_select']) ? $config['lists_user_select'] : 0,
++      '#default_value' => $config['lists_user_select'] ?? 0,
+     ];
+ 
+     return $form;
+@@ -158,7 +159,6 @@ class SendpulseApiMultiBlock extends BlockBase implements ContainerFactoryPlugin
+   public function blockSubmit($form, FormStateInterface $form_state) {
+     parent::blockSubmit($form, $form_state);
+     $values = $form_state->getValues();
+-    $customFields = $values['custom_fields'];
+ 
+     $this->configuration['custom_fields'] = $values['custom_fields'];
+     $this->configuration['body'] = $values['body'];
 diff --git a/src/Plugin/Derivative/SendpulseApiBlockDerivative.php b/src/Plugin/Derivative/SendpulseApiBlockDerivative.php
 index 800ef2d..e1a8d40 100644
 --- a/src/Plugin/Derivative/SendpulseApiBlockDerivative.php
@@ -5350,7 +5686,7 @@
 \ No newline at end of file
 +}
 diff --git a/src/Plugin/Field/FieldType/SendpulseApiListItem.php b/src/Plugin/Field/FieldType/SendpulseApiListItem.php
-index 43c2577..a40a109 100644
+index 43c2577..0705850 100644
 --- a/src/Plugin/Field/FieldType/SendpulseApiListItem.php
 +++ b/src/Plugin/Field/FieldType/SendpulseApiListItem.php
 @@ -13,7 +13,7 @@ use Drupal\Core\TypedData\OptionsProviderInterface;
@@ -5485,7 +5821,7 @@
      ];
  
      $element['field_mapping'] = [
-@@ -129,8 +124,8 @@ class SendpulseApiListItem extends FieldItemBase implements OptionsProviderInter
+@@ -129,22 +124,22 @@ class SendpulseApiListItem extends FieldItemBase implements OptionsProviderInter
        '#title' => $this->t('Entity Field Mapping to Sendpulse Api Fields'),
        '#tree' => TRUE,
        '#states' => [
@@ -5496,8 +5832,10 @@
      ];
  
      $element['field_mapping']['email_address'] = [
-@@ -139,12 +134,12 @@ class SendpulseApiListItem extends FieldItemBase implements OptionsProviderInter
-       '#default_value' => isset($this->getSetting('field_mapping')['email_address']) ? $this->getSetting('field_mapping')['email_address'] : NULL,
+       '#type' => 'select',
+       '#title' => $this->t('Email'),
+-      '#default_value' => isset($this->getSetting('field_mapping')['email_address']) ? $this->getSetting('field_mapping')['email_address'] : NULL,
++      '#default_value' => $this->getSetting('field_mapping')['email_address'] ?? NULL,
        '#description' => $this->t('Requires a field of type <strong>email</strong>'),
        '#states' => [
 -        'required' => [':input[name="settings[subscribe_on_save]"]' => ['checked' => TRUE]]
@@ -5600,10 +5938,10 @@
 \ No newline at end of file
 +}
 diff --git a/src/Plugin/WebformHandler/WebformSendpulseApiHandler.php b/src/Plugin/WebformHandler/WebformSendpulseApiHandler.php
-index 78bd653..c7084c1 100644
+index 78bd653..0650b08 100644
 --- a/src/Plugin/WebformHandler/WebformSendpulseApiHandler.php
 +++ b/src/Plugin/WebformHandler/WebformSendpulseApiHandler.php
-@@ -26,21 +26,21 @@ use Drupal\Core\Cache\CacheBackendInterface;
+@@ -26,28 +26,28 @@ use Drupal\Core\Cache\CacheBackendInterface;
   */
  class WebformSendpulseApiHandler extends WebformHandlerBase {
  
@@ -5629,6 +5967,14 @@
  
    /**
     * The token manager.
+    *
+    * @var \Drupal\webform\WebformTokenManagerInterface
+    */
+-  protected $token_manager;
++  protected $tokenManager;
+ 
+   /**
+    * {@inheritdoc}
 @@ -66,20 +66,21 @@ class WebformSendpulseApiHandler extends WebformHandlerBase {
    }
  
@@ -5644,8 +5990,10 @@
 -   * Set Token Manager dependency
 +   * Set Token Manager dependency.
     */
-   protected function setTokenManager(WebformTokenManagerInterface $token_manager) {
-     $this->tokenManager = $token_manager;
+-  protected function setTokenManager(WebformTokenManagerInterface $token_manager) {
+-    $this->tokenManager = $token_manager;
++  protected function setTokenManager(WebformTokenManagerInterface $tokenManager) {
++    $this->tokenManager = $tokenManager;
    }
  
    /**
@@ -5654,14 +6002,23 @@
     */
    protected function setSendpulseApi(SendpulseApi $sendpulseApi) {
      $this->sendpulseApi = $sendpulseApi;
-@@ -98,7 +99,6 @@ class WebformSendpulseApiHandler extends WebformHandlerBase {
+@@ -96,14 +97,13 @@ class WebformSendpulseApiHandler extends WebformHandlerBase {
+     if (!empty($fields[$this->configuration['email']])) {
+       $email_summary = $fields[$this->configuration['email']]['#title'];
      }
-     $email_summary = '<strong>' . $this->t('Email') . ': </strong>' . $email_summary;
- 
+-    $email_summary = '<strong>' . $this->t('Email') . ': </strong>' . $email_summary;
 -
++    $email_summary = $this->t('<strong>Email:</strong>@summary', ['@summary' => $email_summary]);
+ 
      $list_summary = $this->configuration['list'];
      if (!empty($lists[$this->configuration['list']])) {
        $list_summary = $lists[$this->configuration['list']]->name;
+     }
+-    $list_summary = '<strong>' . $this->t('List') . ': </strong>' . $list_summary;
++    $list_summary = $this->t('<strong>List:</strong>@summary', ['@summary' => $list_summary]);
+ 
+     $markup = "$email_summary<br/>$list_summary";
+     return [
 @@ -169,7 +169,7 @@ class WebformSendpulseApiHandler extends WebformHandlerBase {
      ];
  
@@ -5714,7 +6071,7 @@
 -  return $form;
 -}
 +          '#type' => 'webform_select_other',
-+          '#title' => $this->t($custom_field->label),
++          '#title' => $this->t('@label', ['@label' => $custom_field->label]),
 +          '#required' => FALSE,
 +          '#options' => $custom_options,
 +          '#default_value' => $this->configuration[$custom_field->custom_field_id],
@@ -5774,6 +6131,15 @@
            $configuration['list'] = $fields['data'][$fieldToken];
          }
        }
+@@ -301,7 +300,7 @@ class WebformSendpulseApiHandler extends WebformHandlerBase {
+     \Drupal::moduleHandler()->alter('webform_sendpulse_api_lists_mergevars', $mergevars, $webform_submission, $this);
+ 
+     $handler_link = Link::createFromRoute(
+-      t('Edit handler'),
++      $this->t('Edit handler'),
+       'entity.webform.handler.edit_form',
+       [
+         'webform' => $this->getWebform()->id(),
 @@ -319,32 +318,32 @@ class WebformSendpulseApiHandler extends WebformHandlerBase {
  
      if (!empty($configuration['list']) && !empty($email)) {
@@ -5868,7 +6234,7 @@
 +
  }
 diff --git a/src/Service/SendpulseApi.php b/src/Service/SendpulseApi.php
-index 94fd7db..d3c6726 100644
+index 94fd7db..7818a92 100644
 --- a/src/Service/SendpulseApi.php
 +++ b/src/Service/SendpulseApi.php
 @@ -5,7 +5,6 @@ namespace Drupal\sendpulse_api\Service;
@@ -5908,6 +6274,17 @@
     * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory
     *   The factory for logging channels.
     * @param \Drupal\Core\Messenger\MessengerInterface $messenger
+@@ -152,8 +149,8 @@ class SendpulseApi {
+   public function getConfig() {
+     // Get our settings from settings.php.
+     $settings = $this->settings::get('sendpulse_api');
+-    $api_user_id = isset($settings['api_user_id']) ? $settings['api_user_id'] : NULL;
+-    $api_secret = isset($settings['api_secret']) ? $settings['api_secret'] : NULL;
++    $api_user_id = $settings['api_user_id'] ?? NULL;
++    $api_secret = $settings['api_secret'] ?? NULL;
+     $configType = 'settings.php';
+ 
+     // If nothing is in settings.php, let's check our config files.
 @@ -163,16 +160,16 @@ class SendpulseApi {
        $configType = 'config';
      }
@@ -6172,14 +6549,14 @@
          $api_secret = $config['api_secret'];
  
 -        $SPApiClient = new ApiClient($api_user_id, $api_secret, null);
-+        $SPApiClient = new ApiClient($api_user_id, $api_secret, NULL);
++        $spaPiClient = new ApiClient($api_user_id, $api_secret, NULL);
  
          try {
  
 -         $mailing_lists = $SPApiClient->listAddressBooks();
 -
 -       } catch (Exception $e) {
-+          $mailing_lists = $SPApiClient->listAddressBooks();
++          $mailing_lists = $spaPiClient->listAddressBooks();
  
 -       }
 -
@@ -6676,12 +7053,12 @@
 +      ];
  
 -     $SPApiClient = new ApiClient($api_user_id, $api_secret, null);
-+      $SPApiClient = new ApiClient($api_user_id, $api_secret, NULL);
++      $spaPiClient = new ApiClient($api_user_id, $api_secret, NULL);
  
 -     foreach ($listIDs as $key => $bookID) {
 -       $response = $SPApiClient->addEmails($bookID, $emails);
 +      foreach ($listIDs as $bookID) {
-+        $response = $SPApiClient->addEmails($bookID, $emails);
++        $response = $spaPiClient->addEmails($bookID, $emails);
  
 -       $this->handleResponse($response, 'submitContactForm');
 +        $this->handleResponse($response, 'submitContactForm');
@@ -6766,8 +7143,8 @@
  
 -       $SPApiClient = new ApiClient($api_user_id, $api_secret, null);
 -       $response = $SPApiClient->removeEmails($mailing_list_id, $emails);
-+        $SPApiClient = new ApiClient($api_user_id, $api_secret, NULL);
-+        $response = $SPApiClient->removeEmails($mailing_list_id, $emails);
++        $spaPiClient = new ApiClient($api_user_id, $api_secret, NULL);
++        $response = $spaPiClient->removeEmails($mailing_list_id, $emails);
  
 -       $this->handleResponse($response, 'unsubscribeContact');
 -     }
