getPhone example

if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $endpoint = sprintf('https://%s/1.0/sms/%s/jobs', $this->getEndpoint()$this->serviceName);

        $content = [
            'charset' => 'UTF-8',
            'class' => 'flash',
            'coding' => '8bit',
            'message' => $message->getSubject(),
            'receivers' => [$message->getPhone()],
            'noStopClause' => $this->noStopClause,
            'priority' => 'medium',
        ];

        if ('' !== $message->getFrom()) {
            $content['sender'] = $message->getFrom();
        } elseif ($this->sender) {
            $content['sender'] = $this->sender;
        } else {
            $content['senderForResponse'] = true;
        }

        
protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/messages/v2/send.json', [
            'json' => [
                'messages' => [
                    [
                        'phone' => $message->getPhone(),
                        'text' => $message->getSubject(),
                        'sender' => $message->getFrom() ?: $this->from,
                        'clientId' => uniqid(),
                    ],
                ],
                'login' => $this->login,
                'password' => $this->password,
            ],
        ]);

        try {
            
new Recipient('', '');
    }

    /** * @dataProvider provideValidEmailAndPhone */
    public function testCanBeConstructed(string $email, string $phone)
    {
        $recipient = new Recipient($email$phone);

        $this->assertSame($email$recipient->getEmail());
        $this->assertSame($phone$recipient->getPhone());
    }

    public static function provideValidEmailAndPhone()
    {
        yield ['test@test.de', '+0815'];
        yield ['test@test.de', ''];
        yield ['', '+0815'];
    }

    public function testEmailAndPhoneAreNotImmutable()
    {
        
$response = $this->client->request('POST', $endpoint[
            'headers' => [
                'Authorization' => 'App '.$this->authToken,
            ],
            'json' => [
                'messages' => [
                    [
                        'from' => $message->getFrom() ?: $this->from,
                        'destinations' => [
                            [
                                'to' => $message->getPhone(),
                            ],
                        ],
                        'text' => $message->getSubject(),
                    ],
                ],
            ],
        ]);

        try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            


            if (!preg_match('/^[a-zA-Z0-9 ]+$/', $from)) {
                throw new IncompleteDsnException('The Sender ID is invalid.');
            }
        }

        $endpoint = sprintf('https://%s/SMS/SEND', $this->getEndpoint());
        $response = $this->client->request('POST', $endpoint[
            'json' => [
                'from' => $from,
                'to' => [$message->getPhone()],
                'content' => $message->getSubject(),
                'key' => $this->authKey,
                'name' => $this->username,
                'password' => $this->password,
            ],
        ]);

        try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            throw new TransportException('Could not reach the remote Sendberry server.', $response, 0, $e);
        }
->to($recipient->getEmail())
            ->subject($this->getSubject())
            ->content($this->getContent() ?: $this->getDefaultContent('button below'))
            ->action('Sign in', $this->loginLinkDetails->getUrl())
        ;

        return new EmailMessage($email);
    }

    public function asSmsMessage(SmsRecipientInterface $recipient, string $transport = null): ?SmsMessage
    {
        return new SmsMessage($recipient->getPhone()$this->getDefaultContent('link').' '.$this->loginLinkDetails->getUrl());
    }

    private function getDefaultContent(string $target): string
    {
        $duration = $this->loginLinkDetails->getExpiresAt()->getTimestamp() - time();
        $durationString = floor($duration / 60).' minute'.($duration > 60 ? 's' : '');
        if (($hours = $duration / 3600) >= 1) {
            $durationString = floor($hours).' hour'.($hours >= 2 ? 's' : '');
        }

        return sprintf('Click on the %s to confirm you want to sign in. This link will expire in %s.', $target$durationString);
    }
$this->setCompany((string) $address->getCompany());
        $this->setDepartment((string) $address->getDepartment());
        $this->setSalutation((string) $address->getSalutation());
        $this->setFirstName((string) $address->getFirstname());
        $this->setLastName((string) $address->getLastname());
        $this->setStreet((string) $address->getStreet());
        $this->setCity((string) $address->getCity());
        $this->setZipCode((string) $address->getZipcode());
        $this->setAdditionalAddressLine1((string) $address->getAdditionalAddressLine1());
        $this->setAdditionalAddressLine2((string) $address->getAdditionalAddressLine2());
        $this->setCountry($address->getCountry());
        $this->setPhone($address->getPhone());
        $this->setTitle($address->getTitle());
        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            $this->setState(null);
        }

        $attributeData = Shopware()->Models()->toArray($address->getAttribute());
        $this->setAttribute($attributeData);
    }

    
return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $options = [];
        $options['from'] = $message->getFrom() ?: $this->from;
        $options['to'] = $message->getPhone();
        $options['message'] = $message->getSubject();

        $endpoint = sprintf('https://%s/a1/sms', $this->getEndpoint());
        $response = $this->client->request('POST', $endpoint[
            'auth_basic' => [$this->apiUsername, $this->apiPassword],
            'body' => array_filter($options),
        ]);

        try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            
protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['api_key'] = $this->apiKey;
        $options['sms'] = $message->getSubject();
        $options['from'] = $message->getFrom() ?: $this->from;
        $options['to'] = $message->getPhone();
        $options['channel'] ??= $this->channel;
        $options['type'] ??= 'plain';

        if (!preg_match('/^[a-zA-Z0-9\s]{3,11}$/', $options['from']) && !preg_match('/^\+?[1-9]\d{1,14}$/', $options['from'])) {
            throw new InvalidArgumentException(sprintf('The "From" number "%s" is not a valid phone number, shortcode, or alphanumeric sender ID.', $options['from']));
        }

        $endpoint = sprintf('https://%s/api/sms/send', $this->getEndpoint());
        $response = $this->client->request('POST', $endpoint[
            'json' => array_filter($options),
        ]);

        


    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v3/transactionalSMS/sms', [
            'json' => [
                'sender' => $message->getFrom() ?: $this->sender,
                'recipient' => $message->getPhone(),
                'content' => $message->getSubject(),
            ],
            'headers' => [
                'api-key' => $this->apiKey,
            ],
        ]);

        try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            throw new TransportException('Could not reach the remote Sendinblue server.', $response, 0, $e);
        }
protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $endpoint = sprintf('https://%s/xms/v1/%s/batches', $this->getEndpoint()$this->accountSid);
        $response = $this->client->request('POST', $endpoint[
            'auth_bearer' => $this->authToken,
            'json' => [
                'from' => $message->getFrom() ?: $this->from,
                'to' => [$message->getPhone()],
                'body' => $message->getSubject(),
            ],
        ]);

        try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            throw new TransportException('Could not reach the remote Sinch server.', $response, 0, $e);
        }

        if (201 !== $statusCode) {
            
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        if ('' !== $message->getFrom()) {
            throw new InvalidArgumentException(sprintf('The "%s" transport does not support "from" in "%s".', __CLASS__, SmsMessage::class));
        }

        $endpoint = sprintf('https://%s/v2/sms/single_send.json', self::HOST);
        $response = $this->client->request('POST', $endpoint[
            'body' => [
                'apikey' => $this->apiKey,
                'mobile' => $message->getPhone(),
                'text' => $message->getSubject(),
            ],
        ]);

        try {
            $data = $response->toArray(false);
        } catch (ExceptionInterface) {
            throw new TransportException('Unable to send the SMS.', $response);
        }

        if (isset($data['code']) && 0 !== (int) $data['code']) {
            


    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['text'] = $message->getSubject();
        $options['src'] = $message->getFrom() ?: $this->from;
        $options['dst'] = $message->getPhone();

        if (!preg_match('/^[a-zA-Z0-9\s]{2,11}$/', $options['src']) && !preg_match('/^\+?[1-9]\d{1,14}$/', $options['src'])) {
            throw new InvalidArgumentException(sprintf('The "From" number "%s" is not a valid phone number, shortcode, or alphanumeric sender ID. Phone number must contain only numbers and optional + character.', $options['src']));
        }

        $endpoint = sprintf('https://%s/v1/Account/%s/Message/', $this->getEndpoint()$this->authId);
        $response = $this->client->request('POST', $endpoint[
            'auth_basic' => [$this->authId, $this->authToken],
            'json' => array_filter($options),
        ]);

        
return $message instanceof SmsMessage && (null === $message->getOptions() || $message->getOptions() instanceof GatewayApiOptions);
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['sender'] = $message->getFrom() ?: $this->from;
        $options['recipients'] = [['msisdn' => $message->getPhone()]];
        $options['message'] = $message->getSubject();

        $endpoint = sprintf('https://%s/rest/mtsms', $this->getEndpoint());

        $response = $this->client->request('POST', $endpoint[
            'auth_basic' => [$this->authToken, ''],
            'json' => array_filter($options),
        ]);

        try {
            $statusCode = $response->getStatusCode();
        }
'lastname' => $customer->getLastname(),
            'birthday' => $this->formatDate($customer->getBirthday()),
            'customernumber' => $customer->getNumber(),
            'customer_group_id' => $customer->getCustomerGroup() ? $customer->getCustomerGroup()->getId() : null,
            'customer_group_name' => $customer->getCustomerGroup() ? $customer->getCustomerGroup()->getName() : '',
            'payment_id' => $customer->getPaymentId(),
            'company' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCompany() : '',
            'department' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getDepartment() : '',
            'street' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getStreet() : '',
            'zipcode' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getZipcode() : '',
            'city' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCity() : '',
            'phone' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getPhone() : '',
            'additional_address_line1' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getAdditionalAddressLine1() : '',
            'additional_address_line2' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getAdditionalAddressLine2() : '',
            'country_id' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCountryId() : null,
            'country_name' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCountry()->getName() : '',
            'state_id' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getStateId() : '',
            'age' => $customer->getAge(),
            'count_orders' => (int) $customer->getOrderInformation()->getOrderCount(),
            'product_avg' => (float) $customer->getOrderInformation()->getAvgProductPrice(),
            'invoice_amount_sum' => (float) $customer->getOrderInformation()->getTotalAmount(),
            'invoice_amount_avg' => (float) $customer->getOrderInformation()->getAvgAmount(),
            'invoice_amount_min' => (float) $customer->getOrderInformation()->getMinAmount(),
            
Home | Imprint | This part of the site doesn't use cookies.