| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; |
| 4 |
|
| 5 |
class WC_Vipps_Checkout_Session_Customer extends WC_Vipps_Model { |
| 6 |
public ?string $first_name = null; |
| 7 |
public ?string $last_name = null; |
| 8 |
public ?string $email = null; |
| 9 |
public ?string $phone_number = null; |
| 10 |
public ?string $street_address = null; |
| 11 |
public ?string $city = null; |
| 12 |
public ?string $postal_code = null; |
| 13 |
public ?string $country = null; |
| 14 |
|
| 15 |
public function set_first_name( string $first_name ): self { |
| 16 |
$this->first_name = $first_name; |
| 17 |
|
| 18 |
return $this; |
| 19 |
} |
| 20 |
|
| 21 |
public function set_last_name( string $last_name ): self { |
| 22 |
$this->last_name = $last_name; |
| 23 |
|
| 24 |
return $this; |
| 25 |
} |
| 26 |
|
| 27 |
public function set_email( string $email ): self { |
| 28 |
$this->email = $email; |
| 29 |
|
| 30 |
return $this; |
| 31 |
} |
| 32 |
|
| 33 |
public function set_phone_number( string $phone_number ): self { |
| 34 |
$this->phone_number = $phone_number; |
| 35 |
|
| 36 |
return $this; |
| 37 |
} |
| 38 |
|
| 39 |
public function set_street_address( string $street_address ): self { |
| 40 |
$this->street_address = $street_address; |
| 41 |
|
| 42 |
return $this; |
| 43 |
} |
| 44 |
|
| 45 |
public function set_city( string $city ): self { |
| 46 |
$this->city = $city; |
| 47 |
|
| 48 |
return $this; |
| 49 |
} |
| 50 |
|
| 51 |
public function set_postal_code( string $postal_code ): self { |
| 52 |
$this->postal_code = $postal_code; |
| 53 |
|
| 54 |
return $this; |
| 55 |
} |
| 56 |
|
| 57 |
public function set_country( string $country ): self { |
| 58 |
$this->country = $country; |
| 59 |
|
| 60 |
return $this; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* @throws WC_Vipps_Recurring_Missing_Value_Exception |
| 65 |
*/ |
| 66 |
public function to_array( bool $check_required = false ): array { |
| 67 |
if ( $check_required ) { |
| 68 |
$this->check_required(); |
| 69 |
} |
| 70 |
|
| 71 |
return array_merge( |
| 72 |
$this->conditional( "firstName", $this->first_name ), |
| 73 |
$this->conditional( "lastName", $this->last_name ), |
| 74 |
$this->conditional( "email", $this->email ), |
| 75 |
$this->conditional( "phoneNumber", $this->phone_number ), |
| 76 |
$this->conditional( "streetAddress", $this->street_address ), |
| 77 |
$this->conditional( "city", $this->city ), |
| 78 |
$this->conditional( "postalCode", $this->postal_code ), |
| 79 |
$this->conditional( "country", $this->country ), |
| 80 |
); |
| 81 |
} |
| 82 |
} |
| 83 |
|