OrderIdMappingResponseParser
in package
Class OrderIdMappingResponseParser
Table of Contents
- MANAGEABLE_SUCCESS_VALUES = ['1', '0']
- MESSAGE_ALREADY_TRANSMITTED = 'Diese Bestellung wurde bereits erfasst'
- parse() : AfterbuyOrderIdMapping
- isAlreadyTransmitted() : true|null
- Checks <errorlist> xml element to contain an error message that the order was already transmitted.
- parseErrorResponse() : AfterbuyOrderIdMapping
- Parses the Afterbuy Shop-API (legacy) xml error response, which might contain the shops- and Afterbuy order id.
- parseSuccessResponse() : AfterbuyOrderIdMapping
- Parses Afterbuy Shop-API (legacy) xml response which contained `<success>` = '1', extracting the Shop- and Afterbuy order id.
- tryGetElement() : SimpleXMLElement|null
- Tries to get a property as `SimpleXMLElement` from the given xml.
- tryGetElementAsString() : string|null
- Tries to get a property as string from the given xml.
- validateXml() : array<string|int, mixed>
- Validates the xml response.
Constants
MANAGEABLE_SUCCESS_VALUES
private
mixed
MANAGEABLE_SUCCESS_VALUES
= ['1', '0']
MESSAGE_ALREADY_TRANSMITTED
private
mixed
MESSAGE_ALREADY_TRANSMITTED
= 'Diese Bestellung wurde bereits erfasst'
Methods
parse()
public
parse(string $xmlResponse) : AfterbuyOrderIdMapping
Parameters
- $xmlResponse : string
Tags
Return values
AfterbuyOrderIdMapping —isAlreadyTransmitted()
Checks <errorlist> xml element to contain an error message that the order was already transmitted.
private
isAlreadyTransmitted(SimpleXMLElement $errorList) : true|null
Parameters
- $errorList : SimpleXMLElement
Return values
true|null —parseErrorResponse()
Parses the Afterbuy Shop-API (legacy) xml error response, which might contain the shops- and Afterbuy order id.
private
parseErrorResponse(SimpleXMLElement $xml, string $xmlResponse) : AfterbuyOrderIdMapping
This is the case e.g. if the order has already been entered.
Parameters
- $xml : SimpleXMLElement
- $xmlResponse : string
Tags
Return values
AfterbuyOrderIdMapping —parseSuccessResponse()
Parses Afterbuy Shop-API (legacy) xml response which contained `<success>` = '1', extracting the Shop- and Afterbuy order id.
private
parseSuccessResponse(SimpleXMLElement $xml, string $xmlResponse) : AfterbuyOrderIdMapping
Parameters
- $xml : SimpleXMLElement
- $xmlResponse : string
Tags
Return values
AfterbuyOrderIdMapping —tryGetElement()
Tries to get a property as `SimpleXMLElement` from the given xml.
private
tryGetElement(SimpleXMLElement $xml, string $property) : SimpleXMLElement|null
Returns null if the property was not found or is not of type SimpleXMLElement
Parameters
- $xml : SimpleXMLElement
- $property : string
Return values
SimpleXMLElement|null —tryGetElementAsString()
Tries to get a property as string from the given xml.
private
tryGetElementAsString(SimpleXMLElement $xml, string $property) : string|null
Returns null if the property was not found or can't be used as string.
Parameters
- $xml : SimpleXMLElement
- $property : string
Return values
string|null —validateXml()
Validates the xml response.
private
validateXml(string $xmlResponse) : array<string|int, mixed>
This method throws exceptions if the xml is invalid and can't be parsed, the <success> element
is missing or don't contain the values '0' or '1'.
The value '0' is also allowed, because the response may contain the afterbuy order id and shop order id in the error list of the xml response.
Parameters
- $xmlResponse : string