modules/acm_customer/src/Commands/AcmCustomerDrushCommands.php
public static function pushCustomerDataToUpstream(string $mail) {
    $logger = \Drupal::logger('AcmCustomerDrushCommands');

    /** @var \Drupal\user\Entity\User $user */
    $user = user_load_by_mail($mail);

    if (empty($user)) {
      $logger->warning('User with @mail not found, skipping.', [
        '@mail' => $mail,
      ]);
    }
    elseif (empty($user->get('acm_customer_id')->getString())) {
      $logger->warning('User with @mail does not have customer id, skipping.', [
        '@mail' => $mail,
      ]);
    }

    $customer_array = [
      'customer_id' => $user->get('acm_customer_id')->getString(),
      'firstname' => $user->get('field_first_name')->getString(),
      'lastname' => $user->get('field_last_name')->getString(),
      'email' => $user->getEmail(),
    ];

    /** @var \Drupal\acm\Connector\APIWrapper $api_wrapper */
    $api_wrapper = \Drupal::service('acm.api');

    try {
      if ($api_wrapper->updateCustomer($customer_array)) {
        $logger->info('Successfully pushed for user with @mail.', [
          '@mail' => $mail,
        ]);
      }
      else {
        $logger->warning('Something went wrong while pushing user with @mail.', [
          '@mail' => $mail,
        ]);
      }
    }
    catch (\Exception $e) {
      $logger->error('Failed to push for user with @mail, message: @message.', [
        '@mail' => $mail,
        '@message' => $e->getMessage(),
      ]);
    }
  }
public static function pushCustomerDataToUpstream(string $mail) {
    $logger = \Drupal::logger('AcmCustomerDrushCommands');

    /** @var \Drupal\user\Entity\User $user */
    $user = user_load_by_mail($mail);

    if (empty($user)) {
      $logger->warning('User with @mail not found, skipping.', [
        '@mail' => $mail,
      ]);
    }
    elseif (empty($user->get('acm_customer_id')->getString())) {
      $logger->warning('User with @mail does not have customer id, skipping.', [
        '@mail' => $mail,
      ]);
    }

    $customer_array = [
      'customer_id' => $user->get('acm_customer_id')->getString(),
      'firstname' => $user->get('field_first_name')->getString(),
      'lastname' => $user->get('field_last_name')->getString(),
      'email' => $user->getEmail(),
    ];

    /** @var \Drupal\acm\Connector\APIWrapper $api_wrapper */
    $api_wrapper = \Drupal::service('acm.api');

    try {
      if ($api_wrapper->updateCustomer($customer_array)) {
        $logger->info('Successfully pushed for user with @mail.', [
          '@mail' => $mail,
        ]);
      }
      else {
        $logger->warning('Something went wrong while pushing user with @mail.', [
          '@mail' => $mail,
        ]);
      }
    }
    catch (\Exception $e) {
      $logger->error('Failed to push for user with @mail, message: @message.', [
        '@mail' => $mail,
        '@message' => $e->getMessage(),
      ]);
    }
  }
public static function pushCustomerDataToUpstream ( string $ mail ) { $ logger = \ Drupal :: logger ( 'AcmCustomerDrushCommands' ) ; /** @var \Drupal\user\Entity\User $user */ $ user = user_load_by_mail ( $ mail ) ; if ( empty ( $ user ) ) { $ logger -> warning ( 'User with @mail not found, skipping.' , [ '@mail' => $ mail , ] ) ; } elseif ( empty ( $ user -> get ( 'acm_customer_id' ) -> getString ( ) ) ) { $ logger -> warning ( 'User with @mail does not have customer id, skipping.' , [ '@mail' => $ mail , ] ) ; } $ customer_array = [ 'customer_id' => $ user -> get ( 'acm_customer_id' ) -> getString ( ) , 'firstname' => $ user -> get ( 'field_first_name' ) -> getString ( ) , 'lastname' => $ user -> get ( 'field_last_name' ) -> getString ( ) , 'email' => $ user -> getEmail ( ) , ] ; /** @var \Drupal\acm\Connector\APIWrapper $api_wrapper */ $ api_wrapper = \ Drupal :: service ( 'acm.api' ) ; try { if ( $ api_wrapper -> updateCustomer ( $ customer_array ) ) { $ logger -> info ( 'Successfully pushed for user with @mail.' , [ '@mail' => $ mail , ] ) ; } else { $ logger -> warning ( 'Something went wrong while pushing user with @mail.' , [ '@mail' => $ mail , ] ) ; } } catch ( \ Exception $ e ) { $ logger -> error ( 'Failed to push for user with @mail, message: @message.' , [ '@mail' => $ mail , '@message' => $ e -> getMessage ( ) , ] ) ; } }
Wrapper function to push data for particular customer.

@param string $mail
E-Mail address of the customer to push.
Wrapper function to push data for particular customer .