public void update_existing_customer_request_generation()
        {
            const string expected = @"
                <CRMMessage language=""en_US"" currency=""DKK"">
                  <RequestSource name=""acme.com"" version=""1"" />
                  <RequestCode>SetCustomer</RequestCode>
                  <DataSet>
                    <DataSetColumns>
                      <DSColumn name=""firstname"" />
                      <DSColumn name=""lastname"" />
                    </DataSetColumns>
                    <Rows>
                      <Row id=""123"">
                        <Col>Rubber</Col>
                        <Col>Duck</Col>
                      </Row>
                    </Rows>
                  </DataSet>
                </CRMMessage>";

            var request = new SetCustomerRequest(
                "acme.com",
                123,
                new[]
            {
                new ColumnValue("firstname", "Rubber"),
                new ColumnValue("lastname", "Duck")
            });

            var requestXml = request.BuildRequestDocument();

            Assert.Equal(XE.Parse(expected).ToString(), requestXml.ToString());
        }
        public void create_new_customer_request_generation()
        {
            // Causion: a request without sortValue = 1 and PrimaryPosRef =
            // <account-number> creates a new customer that isn't associated
            // with any account. CRM API appear to not support associating the
            // customer with an account after the fact.
            const string expected = @"
                <CRMMessage language=""en_US"" currency=""DKK"">
                    <RequestSource name=""acme.com"" version=""1"" />
                    <RequestCode>SetCustomer</RequestCode>
                    <DataSet>
                        <DataSetColumns>
                            <DSColumn name=""firstName""/>
                            <DSColumn name=""lastName""/>
                            <DSColumn name=""sortValue""/>
                            <DSColumn name=""PrimaryPosRef""/>
                        </DataSetColumns>
                        <Rows>
                            <Row>
                                <Col>Jane</Col>
                                <Col>Doe</Col>
                                <Col>1</Col>
                                <Col>2200000</Col>
                            </Row>
                        </Rows>
                    </DataSet>
                </CRMMessage>";

            var request = new SetCustomerRequest(
                "acme.com",
                null,
                new[]
            {
                new ColumnValue("firstName", "Jane"),
                new ColumnValue("lastName", "Doe"),
                new ColumnValue("sortValue", "1"),
                new ColumnValue("PrimaryPosRef", "2200000")
            });

            var requestXml = request.BuildRequestDocument();

            Assert.Equal(XE.Parse(expected).ToString(), requestXml.ToString());
        }
Beispiel #3
0
        public async Task <SetCustomerResponse> SetCustomerAsync(int?rowId, ColumnValue[] dataSetColumnValues, CancellationToken cancellationToken = default)
        {
            try
            {
                var request     = new SetCustomerRequest(_options.CustomerRelationshipManagementOperations.RequestSourceName, rowId, dataSetColumnValues);
                var requestXml  = request.BuildRequestDocument();
                var responseXml = await _executor.ExecuteAsync(requestXml, cancellationToken);

                return(new SetCustomerResponse(requestXml, responseXml));
            }
            catch (OracleHospitalityClientException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new OracleHospitalityClientException($"{RequestCode.Kind.SetCustomer} operation failed", e);
            }
        }