Skip to content

Commit

Permalink
add phone field and children (#26)
Browse files Browse the repository at this point in the history
* add phone field and children
* Address parameter issue in billTo
  • Loading branch information
isybuy authored Jan 26, 2024
1 parent 4d4d14e commit 77a13a1
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/CXml/Builder/OrderRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use CXml\Model\Message\PunchOutOrderMessage;
use CXml\Model\MoneyWrapper;
use CXml\Model\MultilanguageString;
use CXml\Model\Phone;
use CXml\Model\PostalAddress;
use CXml\Model\Request\OrderRequest;
use CXml\Model\Request\OrderRequestHeader;
Expand Down Expand Up @@ -103,7 +104,7 @@ public function billTo(
string $addressId = null,
string $addressIdDomain = null,
string $email = null,
string $phone = null,
Phone $phone = null,
string $fax = null,
string $url = null
): self {
Expand Down
6 changes: 3 additions & 3 deletions src/CXml/Model/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Address
* @Ser\SerializedName("Phone")
* @Ser\XmlElement (cdata=false)
*/
private ?string $phone = null;
private ?Phone $phone = null;

/**
* @Ser\SerializedName("Fax")
Expand All @@ -53,7 +53,7 @@ class Address
*/
private ?string $url = null;

public function __construct(MultilanguageString $name, PostalAddress $postalAddress = null, string $addressId = null, string $addressIdDomain = null, string $email = null, string $phone = null, string $fax = null, string $url = null)
public function __construct(MultilanguageString $name, PostalAddress $postalAddress = null, string $addressId = null, string $addressIdDomain = null, string $email = null, Phone $phone = null, string $fax = null, string $url = null)
{
$this->addressId = $addressId;
$this->addressIdDomain = $addressIdDomain;
Expand Down Expand Up @@ -90,7 +90,7 @@ public function getEmail(): ?string
return $this->email;
}

public function getPhone(): ?string
public function getPhone(): ?Phone
{
return $this->phone;
}
Expand Down
35 changes: 35 additions & 0 deletions src/CXml/Model/CountryCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace CXml\Model;

use JMS\Serializer\Annotation as Ser;

class CountryCode
{
/**
* @Ser\XmlAttribute
* @Ser\SerializedName("isoCountryCode")
*/
private string $isoCountryCode;

/**
* @Ser\XmlValue(cdata=false)
*/
private ?string $name = null;

public function __construct(string $isoCountryCode, string $name = null)
{
$this->isoCountryCode = $isoCountryCode;
$this->name = $name;
}

public function getIsoCountryCode(): string
{
return $this->isoCountryCode;
}

public function getName(): ?string
{
return $this->name;
}
}
36 changes: 36 additions & 0 deletions src/CXml/Model/Phone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace CXml\Model;

use JMS\Serializer\Annotation as Ser;

class Phone
{
/**
* @Ser\SerializedName("TelephoneNumber")
* @Ser\XmlElement (cdata=false)
*/
private TelephoneNumber $telephoneNumber;

/**
* @Ser\XmlAttribute
* @Ser\SerializedName("name")
*/
private ?string $name = null;

public function __construct(TelephoneNumber $telephoneNumber, string $name = null)
{
$this->telephoneNumber = $telephoneNumber;
$this->name = $name;
}

public function getTelephoneNumber(): TelephoneNumber
{
return $this->telephoneNumber;
}

public function getName(): ?string
{
return $this->name;
}
}
48 changes: 48 additions & 0 deletions src/CXml/Model/TelephoneNumber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace CXml\Model;

use JMS\Serializer\Annotation as Ser;

class TelephoneNumber
{
/**
* @Ser\SerializedName("CountryCode")
* @Ser\XmlElement (cdata=false)
*/
private CountryCode $countryCode;

/**
* @Ser\SerializedName("AreaOrCityCode")
* @Ser\XmlElement (cdata=false)
*/
private ?string $areaOrCityCode = null;

/**
* @Ser\SerializedName("Number")
* @Ser\XmlElement (cdata=false)
*/
private ?string $number = null;

public function __construct(CountryCode $countryCode, string $areaOrCityCode = null, string $number = null)
{
$this->countryCode = $countryCode;
$this->areaOrCityCode = $areaOrCityCode;
$this->number = $number;
}

public function getCountryCode(): CountryCode
{
return $this->countryCode;
}

public function getAreaOrCityCode(): ?string
{
return $this->areaOrCityCode;
}

public function getNumber(): ?string
{
return $this->number;
}
}
25 changes: 25 additions & 0 deletions tests/CXmlTest/Model/OrderRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use CXml\Model\Classification;
use CXml\Model\Comment;
use CXml\Model\Country;
use CXml\Model\CountryCode;
use CXml\Model\Credential;
use CXml\Model\Description;
use CXml\Model\ItemDetail;
Expand All @@ -16,11 +17,13 @@
use CXml\Model\MoneyWrapper;
use CXml\Model\MultilanguageString;
use CXml\Model\PayloadIdentity;
use CXml\Model\Phone;
use CXml\Model\PostalAddress;
use CXml\Model\Request\OrderRequest;
use CXml\Model\Request\OrderRequestHeader;
use CXml\Model\Request\Request;
use CXml\Model\ShipTo;
use CXml\Model\TelephoneNumber;
use CXml\Payload\PayloadIdentityFactoryInterface;
use CXml\Serializer;
use CXml\Validation\DtdValidator;
Expand Down Expand Up @@ -75,6 +78,17 @@ public function testMinimumExample(): void
'CA',
'90489',
'default'
),
null,
null,
null,
new Phone(
new TelephoneNumber(
new CountryCode('US', '1'),
'800',
'5551212'
),
'personal'
)
)
),
Expand All @@ -92,6 +106,17 @@ public function testMinimumExample(): void
null,
'42699',
'default'
),
null,
null,
null,
new Phone(
new TelephoneNumber(
new CountryCode('DE', '49'),
'761',
'1234567'
),
'company'
)
)
),
Expand Down
14 changes: 14 additions & 0 deletions tests/CXmlTest/Model/PunchOutSetupRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use CXml\Model\Address;
use CXml\Model\Classification;
use CXml\Model\Country;
use CXml\Model\CountryCode;
use CXml\Model\Credential;
use CXml\Model\Description;
use CXml\Model\Extrinsic;
Expand All @@ -15,10 +16,12 @@
use CXml\Model\MoneyWrapper;
use CXml\Model\MultilanguageString;
use CXml\Model\PayloadIdentity;
use CXml\Model\Phone;
use CXml\Model\PostalAddress;
use CXml\Model\Request\PunchOutSetupRequest;
use CXml\Model\SelectedItem;
use CXml\Model\ShipTo;
use CXml\Model\TelephoneNumber;
use CXml\Payload\PayloadIdentityFactoryInterface;
use CXml\Serializer;
use CXml\Validation\DtdValidator;
Expand Down Expand Up @@ -75,6 +78,17 @@ public function testMinimumExample(): void
'CA',
'90489',
'default'
),
null,
null,
null,
new Phone(
new TelephoneNumber(
new CountryCode('US', '1'),
'800',
'5551212'
),
'personal'
)
)
),
Expand Down
14 changes: 14 additions & 0 deletions tests/CXmlTest/Model/QuoteMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
use CXml\Model\Address;
use CXml\Model\Contact;
use CXml\Model\Country;
use CXml\Model\CountryCode;
use CXml\Model\Credential;
use CXml\Model\Message\QuoteMessage;
use CXml\Model\Message\QuoteMessageHeader;
use CXml\Model\MoneyWrapper;
use CXml\Model\MultilanguageString;
use CXml\Model\OrganizationId;
use CXml\Model\PayloadIdentity;
use CXml\Model\Phone;
use CXml\Model\PostalAddress;
use CXml\Model\ShipTo;
use CXml\Model\TelephoneNumber;
use CXml\Payload\PayloadIdentityFactoryInterface;
use CXml\Serializer;
use CXml\Validation\DtdValidator;
Expand Down Expand Up @@ -83,6 +86,17 @@ public function testMinimumExample(): void
null,
'CA',
'90489'
),
null,
null,
null,
new Phone(
new TelephoneNumber(
new CountryCode('US', '1'),
'800',
'1234567'
),
'company'
)
)
);
Expand Down
14 changes: 14 additions & 0 deletions tests/metadata/cxml/samples/OrderRequest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
<PostalCode>90489</PostalCode>
<Country isoCountryCode="US">United States</Country>
</PostalAddress>
<Phone name="personal">
<TelephoneNumber>
<CountryCode isoCountryCode="US">1</CountryCode>
<AreaOrCityCode>800</AreaOrCityCode>
<Number>5551212</Number>
</TelephoneNumber>
</Phone>
</Address>
</ShipTo>
<BillTo>
Expand All @@ -52,6 +59,13 @@
<PostalCode>42699</PostalCode>
<Country isoCountryCode="DE">Deutschland</Country>
</PostalAddress>
<Phone name="company">
<TelephoneNumber>
<CountryCode isoCountryCode="DE">49</CountryCode>
<AreaOrCityCode>761</AreaOrCityCode>
<Number>1234567</Number>
</TelephoneNumber>
</Phone>
</Address>
</BillTo>
<Comments>
Expand Down
7 changes: 7 additions & 0 deletions tests/metadata/cxml/samples/PunchOutSetupRequest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
<PostalCode>90489</PostalCode>
<Country isoCountryCode="US">United States</Country>
</PostalAddress>
<Phone name="personal">
<TelephoneNumber>
<CountryCode isoCountryCode="US">1</CountryCode>
<AreaOrCityCode>800</AreaOrCityCode>
<Number>5551212</Number>
</TelephoneNumber>
</Phone>
</Address>
</ShipTo>
<SelectedItem>
Expand Down
7 changes: 7 additions & 0 deletions tests/metadata/cxml/samples/QuoteMessage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
<PostalCode>90489</PostalCode>
<Country isoCountryCode="US">United States</Country>
</PostalAddress>
<Phone name="company">
<TelephoneNumber>
<CountryCode isoCountryCode="US">1</CountryCode>
<AreaOrCityCode>800</AreaOrCityCode>
<Number>1234567</Number>
</TelephoneNumber>
</Phone>
</Address>
</ShipTo>

Expand Down

0 comments on commit 77a13a1

Please sign in to comment.