// If an error occurs and response code isn't "Approved", form of // response is // // <ResponseCode hostCode="20">D</ResponseCode> // <DisplayMessage>Missing SVAN Element</DisplayMessage> // // A successful response code has the form <ResponseCode>A</ResponseCode> // and sometimes, but not always, contains DisplayMessage element. public ResponseCode(XE responseCode) { // POS API spec, Page 19: according to DisplayMessage documentation, // additional response codes include E, V, and P. Those should be // shown to POS terminal user. We haven't encountered these codes // and thus doesn't parse those. var value = responseCode.Value; FieldTypes.AssertA1(value); if (value == "A") { Value = Kind.Approved; } else if (value == "D") { var hostCodeAttribute = ExpectAttribute(responseCode, C.hostCode); HostCode = hostCodeAttribute.Value; Value = Kind.DataCenterInitiatedError; } else { throw new ArgumentException($"Unsupported {nameof(Kind)} value: '{value}'"); } }
public Transmission(string value) { FieldTypes.AssertA1(value); Value = value switch { "n" => Kind.Normal, "y" => Kind.Retransmission, _ => throw new ArgumentException($"Unsupported {nameof(Kind)} value: '{value}'") }; }
public ItemType(string value) { // UNDOCUMENTED: according to POS API spec, Page 21, ItemType is of // type XML with no field type definition. We've yet to encounter // any XML beneath the ItemType element. In the responses we've // encountered, the format is <ItemType>T</ItemType>. FieldTypes.AssertA1(value); Value = value switch { "M" => Kind.MenuOrSalesItem, "D" => Kind.Discount, "S" => Kind.ServiceCharge, "T" => Kind.Tender, _ => throw new ArgumentException($"Unsupported {nameof(Kind)} value: '{value}'"), }; }