Пример #1
0
        /// <summary>
        /// Creates a new Link from the given builder, signs it and executes the GraphQL
        /// mutation.
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="linkBuilder">The linkBuilder<see cref="TraceLinkBuilder{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        private async Task <TraceState <TState, TLinkData> > CreateLinkAsync <TLinkData>(TraceLinkBuilder <TLinkData> linkBuilder)
        {
            // extract signing key from config
            SdkConfig sdkConfig = await GetConfigAsync();

            Ed25519PrivateKeyParameters signingPrivateKey = sdkConfig.SigningPrivateKey;

            // build the link
            TraceLink <TLinkData> link = linkBuilder.Build();

            // sign the link
            link.Sign(signingPrivateKey.GetEncoded(), "[version,data,meta]");



            string linkObjJson = JsonHelper.ToJson(link.ALink);

            Dictionary <string, object> linkObj = JsonHelper.ObjectToMap(link.GetLink());


            Dictionary <string, object> dataObj = JsonHelper.ObjectToMap(((TraceLink <TLinkData>)link).FormData());

            Dictionary <string, object> variables = new Dictionary <string, object>
            {
                ["link"] = linkObj,
                ["data"] = dataObj
            };
            // Debug.WriteLine("Request : " + JsonHelper.ToJson(dataObj));
            // execute graphql query
            GraphQLResponse jsonResponse = await this.client.GraphqlAsync(GraphQL.MUTATION_CREATELINK, variables, null, null);

            var trace = jsonResponse.Data.createLink.trace;

            return(this.MakeTraceState <TLinkData>(trace));
        }
Пример #2
0
        /// <summary>
        /// The PullTrace
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="PullTransferInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > PullTraceAsync <TLinkData>(PullTransferInput <TLinkData> input)
        {
            // retrieve parent link
            TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null);
            TraceLink <TLinkData>             parentLink    = await this.GetHeadLinkAsync <TLinkData>(headLinkInput);

            TLinkData data = input.Data;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string userId     = sdkConfig.UserId;
            string groupId    = sdkConfig.GroupId;

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                // provide workflow id
                WorkflowId = workflowId,
                // and parent link to append to the existing trace
                ParentLink = parentLink
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            // this is a push transfer
            linkBuilder.ForPullTransfer(groupId, data).WithCreatedBy(userId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Пример #3
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><request><control><senderid>testsenderid</senderid><password>pass123!</password><controlid>unittest</controlid><uniqueid>false</uniqueid><dtdversion>3.0</dtdversion><includewhitespace>false</includewhitespace></control><operation transaction=""false""><authentication><sessionid>testsession..</sessionid></authentication><content /></operation></request>";

            SdkConfig config = new SdkConfig()
            {
                SenderId       = "testsenderid",
                SenderPassword = "******",
                SessionId      = "testsession..",
                ControlId      = "unittest",
            };

            Content contentBlock = new Content();

            RequestBlock requestBlock = new RequestBlock(config, contentBlock);

            Stream stream = requestBlock.WriteXml();

            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
        public void CredsFromProfileTest()
        {
            var parser = new FileIniDataParser();

            string ini = @"
[unittest]
sender_id = inisenderid
sender_password = inisenderpass
endpoint_url = https://unittest.intacct.com/ia/xmlgw.phtml";

            string tempFile = Path.Combine(Path.GetTempPath(), ".intacct", "credentials.ini");

            using (StreamWriter sw = new StreamWriter(tempFile))
            {
                sw.WriteLine(ini);
            }

            SdkConfig config = new SdkConfig()
            {
                ProfileFile = tempFile,
                ProfileName = "unittest",
            };

            SenderCredentials senderCreds = new SenderCredentials(config);

            Assert.AreEqual("inisenderid", senderCreds.SenderId);
            Assert.AreEqual("inisenderpass", senderCreds.Password);
            Assert.AreEqual("https://unittest.intacct.com/ia/xmlgw.phtml", senderCreds.Endpoint.Url);
        }
Пример #5
0
        public SessionCredentials(SdkConfig config, SenderCredentials senderCreds)
        {
            if (String.IsNullOrWhiteSpace(config.SessionId))
            {
                throw new ArgumentException("Required SessionId not supplied in params");
            }

            SessionId = config.SessionId;
            if (!String.IsNullOrWhiteSpace(config.EndpointUrl))
            {
                Endpoint = new Endpoint(config);
            }
            else
            {
                Endpoint = senderCreds.Endpoint;
            }

            SenderCreds           = senderCreds;
            CurrentCompanyId      = config.CurrentCompanyId;
            CurrentUserId         = config.CurrentUserId;
            CurrentUserIsExternal = config.CurrentUserIsExternal;
            MockHandler           = config.MockHandler;

            Logger           = config.Logger;
            LogMessageFormat = config.LogFormatter;
            LogLevel         = config.LogLevel;
        }
Пример #6
0
        /// <summary>
        /// Gets a new Intacct API session ID and endpoint URL
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private async Task <SdkConfig> getAPISession(SdkConfig config)
        {
            Content content = new Content();

            content.Add(new ApiSessionCreate());

            RequestHandler requestHandler = new RequestHandler(config);

            SynchronousResponse response = await requestHandler.ExecuteSynchronous(config, content);

            OperationBlock operation      = response.Operation;
            Authentication authentication = operation.Authentication;
            XElement       api            = operation.Results[0].Data.Element("api");

            SdkConfig session = new SdkConfig()
            {
                SessionId             = api.Element("sessionid").Value,
                EndpointUrl           = api.Element("endpoint").Value,
                CurrentCompanyId      = authentication.CompanyId,
                CurrentUserId         = authentication.UserId,
                CurrentUserIsExternal = authentication.SlideInUser,
                Logger       = config.Logger,
                LogFormatter = config.LogFormatter,
                LogLevel     = config.LogLevel,
            };

            return(session);
        }
Пример #7
0
        /// <summary>
        /// The NewTrace
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="NewTraceInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > NewTraceAsync <TLinkData>(NewTraceInput <TLinkData> input)
        {
            //extract info from input
            string    formId = input.FormId;
            TLinkData data   = input.Data;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string userId     = sdkConfig.UserId;
            string ownerId    = sdkConfig.OwnerId;
            string groupId    = sdkConfig.GroupId;
            IDictionary <string, string> actionNames = sdkConfig.ActionNames;

            // upload files and transform data
            await this.UploadFilesInLinkData(data);

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                WorkflowId = workflowId
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            var action = actionNames.ContainsKey(formId) ? actionNames[formId] : null;

            // this is an attestation
            linkBuilder.ForAttestation(formId, action, data).WithOwner(ownerId).WithGroup(groupId).WithCreatedBy(userId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Пример #8
0
        public async Task <TraceState <TState, TLinkData> > CancelTransferAsync <TLinkData>(TransferResponseInput <TLinkData> input)
        {
            // retrieve parent link
            TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null);
            TraceLink <TLinkData>             parentLink    = await this.GetHeadLinkAsync <TLinkData>(headLinkInput);

            TLinkData data = input.Data;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            String workflowId = sdkConfig.WorkflowId;
            String configId   = sdkConfig.ConfigId;
            String accountId  = sdkConfig.AccountId;

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                // provide workflow id
                WorkflowId = workflowId,
                // and workflow config id
                ConfigId = configId,
                // and parent link to append to the existing trace
                ParentLink = parentLink
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            linkBuilder // this is to cancel the transfer
            .ForCancelTransfer(data)
            // add creator info
            .WithCreatedBy(accountId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Пример #9
0
        public async Task FromSessionCredentialsTest()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<response>
      <control>
            <status>success</status>
            <senderid>testsenderid</senderid>
            <controlid>sessionProvider</controlid>
            <uniqueid>false</uniqueid>
            <dtdversion>3.0</dtdversion>
      </control>
      <operation>
            <authentication>
                  <status>success</status>
                  <userid>testuser</userid>
                  <companyid>testcompany</companyid>
                  <sessiontimestamp>2015-12-06T15:57:08-08:00</sessiontimestamp>
            </authentication>
            <result>
                  <status>success</status>
                  <function>getSession</function>
                  <controlid>testControlId</controlid>
                  <data>
                        <api>
                              <sessionid>fAkESesSiOnId..</sessionid>
                              <endpoint>https://unittest.intacct.com/ia/xml/xmlgw.phtml</endpoint>
                        </api>
                  </data>
            </result>
      </operation>
</response>";

            HttpResponseMessage mockResponse1 = new HttpResponseMessage()
            {
                StatusCode = System.Net.HttpStatusCode.OK,
                Content    = new StringContent(xml)
            };

            List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage>
            {
                mockResponse1,
            };

            MockHandler mockHandler = new MockHandler(mockResponses);

            SdkConfig config = new SdkConfig()
            {
                SessionId   = "fAkESesSiOnId..",
                EndpointUrl = "https://unittest.intacct.com/ia/xml/xmlgw.phtml",
                MockHandler = mockHandler,
            };

            SessionCredentials sessionCreds = new SessionCredentials(config, senderCreds);

            SessionCredentials newSessionCreds = await provider.FromSessionCredentials(sessionCreds);

            Assert.AreEqual("fAkESesSiOnId..", newSessionCreds.SessionId);
            StringAssert.Equals("https://unittest.intacct.com/ia/xml/xmlgw.phtml", newSessionCreds.Endpoint);
            Assert.IsInstanceOfType(newSessionCreds.SenderCreds, typeof(SenderCredentials));
        }
Пример #10
0
        public async Task MockDefaultNo524RetryTest()
        {
            HttpResponseMessage mockResponse1 = new HttpResponseMessage()
            {
                StatusCode = (HttpStatusCode)524,
            };

            List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage>
            {
                mockResponse1,
            };

            MockHandler mockHandler = new MockHandler(mockResponses);

            SdkConfig config = new SdkConfig()
            {
                SenderId       = "testsenderid",
                SenderPassword = "******",
                SessionId      = "testsession..",
                MockHandler    = mockHandler,
            };

            Content content = new Content();

            RequestBlock requestBlock = new RequestBlock(config, content);

            RequestHandler      requestHandler = new RequestHandler(config);
            SynchronousResponse response       = await requestHandler.ExecuteSynchronous(config, content);
        }
        public void GetXmlTest()
        {
            SdkConfig config = new SdkConfig()
            {
                SessionId = "testsessionid..",
            };

            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<authentication>
    <sessionid>testsessionid..</sessionid>
</authentication>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            SessionAuthentication sessionAuth = new SessionAuthentication(config);

            sessionAuth.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
        public void CredsFromProfileTest()
        {
            var parser = new FileIniDataParser();

            string ini = @"
[unittest]
company_id = inicompanyid
user_id = iniuserid
user_password = iniuserpass";

            string tempFile = Path.Combine(Path.GetTempPath(), ".intacct", "credentials.ini");

            using (StreamWriter sw = new StreamWriter(tempFile))
            {
                sw.WriteLine(ini);
            }

            SdkConfig config = new SdkConfig()
            {
                ProfileFile = tempFile,
                ProfileName = "unittest",
            };

            LoginCredentials loginCreds = new LoginCredentials(config, senderCreds);

            Assert.AreEqual("inicompanyid", loginCreds.CompanyId);
            Assert.AreEqual("iniuserid", loginCreds.UserId);
            Assert.AreEqual("iniuserpass", loginCreds.Password);
        }
        public void GetMockHandlerTest()
        {
            HttpResponseMessage mockResponse = new HttpResponseMessage()
            {
                StatusCode = System.Net.HttpStatusCode.OK,
            };
            List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage>
            {
                mockResponse,
            };

            MockHandler mockHandler = new MockHandler(mockResponses);

            SdkConfig config = new SdkConfig()
            {
                CompanyId    = "testcompany",
                UserId       = "testuser",
                UserPassword = "******",
                MockHandler  = mockHandler,
            };

            LoginCredentials loginCreds = new LoginCredentials(config, senderCreds);

            Assert.IsInstanceOfType(loginCreds.MockHandler, typeof(MockHandler));
        }
Пример #14
0
        public async Task TestGetConfigAsync()
        {
            var       sdk    = GetSdk();
            SdkConfig config = await sdk.GetConfigAsync();

            Assert.NotNull(config);
        }
Пример #15
0
        /// <summary>
        /// The NewTrace
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="NewTraceInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > NewTraceAsync <TLinkData>(NewTraceInput <TLinkData> input)
        {
            //extract info from input
            string    actionKey  = input.ActionKey;
            TLinkData data       = input.Data;
            string    groupLabel = input.GroupLabel;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string configId   = sdkConfig.ConfigId;
            string accountId  = sdkConfig.AccountId;
            string groupId    = sdkConfig.GetGroupId(groupLabel);

            // upload files and transform data
            await this.UploadFilesInLinkData(data);

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                WorkflowId = workflowId,
                // and workflow config id
                ConfigId = configId,
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            // this is an attestation
            linkBuilder.ForAttestation(actionKey, data).WithGroup(groupId).WithCreatedBy(accountId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Пример #16
0
        /// <summary>
        /// client set method.
        /// </summary>
        /// <returns>client</returns>
        public Client SetClient()
        {
            Client client;
            var    config = new SdkConfig(ApiUrl);

            client = new Client(config);
            return(client);
        }
 public void CredsFromArrayNoSessionTest()
 {
     SdkConfig config = new SdkConfig
     {
         SessionId = null
     };
     SessionCredentials sessionCreds = new SessionCredentials(config, senderCreds);
 }
 public void CredsFromArrayNoSenderPasswordTest()
 {
     SdkConfig config = new SdkConfig
     {
         SenderId = "testsenderid"
     };
     SenderCredentials senderCreds = new SenderCredentials(config);
 }
Пример #19
0
        public async Task ExecuteSynchronousTest()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<response>
      <control>
            <status>success</status>
            <senderid>testsenderid</senderid>
            <controlid>requestUnitTest</controlid>
            <uniqueid>false</uniqueid>
            <dtdversion>3.0</dtdversion>
      </control>
      <operation>
            <authentication>
                  <status>success</status>
                  <userid>testuser</userid>
                  <companyid>testcompany</companyid>
                  <sessiontimestamp>2015-12-06T15:57:08-08:00</sessiontimestamp>
            </authentication>
            <result>
                  <status>success</status>
                  <function>getAPISession</function>
                  <controlid>func1UnitTest</controlid>
                  <data>
                        <api>
                              <sessionid>unittest..</sessionid>
                              <endpoint>https://unittest.intacct.com/ia/xml/xmlgw.phtml</endpoint>
                        </api>
                  </data>
            </result>
      </operation>
</response>";

            HttpResponseMessage mockResponse1 = new HttpResponseMessage()
            {
                StatusCode = System.Net.HttpStatusCode.OK,
                Content    = new StringContent(xml)
            };

            List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage>
            {
                mockResponse1,
            };

            MockHandler mockHandler = new MockHandler(mockResponses);

            SdkConfig config = new SdkConfig
            {
                MockHandler = mockHandler,
            };

            Content content = new Content();

            content.Add(new ApiSessionCreate("func1UnitTest"));

            SynchronousResponse response = await client.Execute(content, false, "requestUnitTest", false, config);

            Assert.AreEqual("requestUnitTest", response.Control.ControlId);
        }
Пример #20
0
        public void ConstructWithLoginTest()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<response>
      <control>
            <status>success</status>
            <senderid>testsenderid</senderid>
            <controlid>sessionProvider</controlid>
            <uniqueid>false</uniqueid>
            <dtdversion>3.0</dtdversion>
      </control>
      <operation>
            <authentication>
                  <status>success</status>
                  <userid>testuser</userid>
                  <companyid>testcompany</companyid>
                  <sessiontimestamp>2015-12-06T15:57:08-08:00</sessiontimestamp>
            </authentication>
            <result>
                  <status>success</status>
                  <function>getAPISession</function>
                  <controlid>getSession</controlid>
                  <data>
                        <api>
                              <sessionid>helloworld..</sessionid>
                              <endpoint>https://p1.intacct.com/ia/xml/xmlgw.phtml</endpoint>
                        </api>
                  </data>
            </result>
      </operation>
</response>";

            HttpResponseMessage mockResponse1 = new HttpResponseMessage()
            {
                StatusCode = System.Net.HttpStatusCode.OK,
                Content    = new StringContent(xml)
            };

            List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage>
            {
                mockResponse1,
            };

            MockHandler mockHandler = new MockHandler(mockResponses);

            SdkConfig config = new SdkConfig
            {
                SenderId       = "testsenderid",
                SenderPassword = "******",
                SessionId      = "originalSeSsIonID..",
                MockHandler    = mockHandler,
            };

            IntacctClient test = new IntacctClient(config);

            Assert.AreEqual("helloworld..", test.SessionCreds.SessionId);
            StringAssert.Equals("https://p1.intacct.com/ia/xml/xmlgw.phtml", test.SessionCreds.Endpoint);
        }
Пример #21
0
        public void InvalidUrlEndpointTest()
        {
            SdkConfig config = new SdkConfig()
            {
                EndpointUrl = "invalidurl"
            };

            Endpoint endpoint = new Endpoint(config);
        }
        public void InvalidSessionIdTest()
        {
            SdkConfig config = new SdkConfig()
            {
                SessionId = null,
            };

            SessionAuthentication sessionAuth = new SessionAuthentication(config);
        }
Пример #23
0
        public void Initialize()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<response>
      <control>
            <status>success</status>
            <senderid>testsenderid</senderid>
            <controlid>sessionProvider</controlid>
            <uniqueid>false</uniqueid>
            <dtdversion>3.0</dtdversion>
      </control>
      <operation>
            <authentication>
                  <status>success</status>
                  <userid>testuser</userid>
                  <companyid>testcompany</companyid>
                  <sessiontimestamp>2015-12-06T15:57:08-08:00</sessiontimestamp>
            </authentication>
            <result>
                  <status>success</status>
                  <function>getAPISession</function>
                  <controlid>getSession</controlid>
                  <data>
                        <api>
                              <sessionid>testSeSsionID..</sessionid>
                              <endpoint>https://p1.intacct.com/ia/xml/xmlgw.phtml</endpoint>
                        </api>
                  </data>
            </result>
      </operation>
</response>";

            HttpResponseMessage mockResponse1 = new HttpResponseMessage()
            {
                StatusCode = System.Net.HttpStatusCode.OK,
                Content    = new StringContent(xml)
            };

            List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage>
            {
                mockResponse1,
            };

            MockHandler mockHandler = new MockHandler(mockResponses);

            SdkConfig config = new SdkConfig
            {
                SenderId       = "testsenderid",
                SenderPassword = "******",
                CompanyId      = "testcompany",
                UserId         = "testuser",
                UserPassword   = "******",
                MockHandler    = mockHandler,
            };

            client = new IntacctClient(config);
        }
Пример #24
0
        public void DefaultEndpointTest()
        {
            SdkConfig config = new SdkConfig();

            Endpoint endpoint = new Endpoint(config);

            Assert.AreEqual("https://api.intacct.com/ia/xml/xmlgw.phtml", endpoint.Url);
            StringAssert.Equals("https://api.intacct.com/ia/xml/xmlgw.phtml", endpoint);
        }
Пример #25
0
        public void InvalidIntacctEndpointTest()
        {
            SdkConfig config = new SdkConfig()
            {
                EndpointUrl = "https://api.notintacct.com"
            };

            Endpoint endpoint = new Endpoint(config);
        }
        public SessionAuthentication(SdkConfig config)
        {
            if (String.IsNullOrWhiteSpace(config.SessionId))
            {
                throw new ArgumentException("Required SessionId not supplied in params");
            }

            SessionId = config.SessionId;
        }
Пример #27
0
        public void InvalidEncodingTest()
        {
            SdkConfig config = new SdkConfig()
            {
                Encoding = "invalid",
            };

            RequestBlock requestBlock = new RequestBlock(config, new Content());
        }
Пример #28
0
        /// <summary>
        /// client set method.
        /// </summary>
        /// <returns>client</returns>
        public static Client SetClient()
         
        {
            Client client;
            var    config = new SdkConfig(Utils.ApiUrl);

            client = new Client(config);
            return(client);
        }
Пример #29
0
        public void WriteXmlLoginTest()
        {
            SdkConfig config = new SdkConfig()
            {
                CompanyId    = "testcompany",
                UserId       = "testuser",
                UserPassword = "******",
            };

            Content          contentBlock = new Content();
            ApiSessionCreate func         = new ApiSessionCreate()
            {
                ControlId = "unittest",
            };

            contentBlock.Add(func);

            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<operation transaction=""false"">
    <authentication>
        <login>
            <userid>testuser</userid>
            <companyid>testcompany</companyid>
            <password>testpass</password>
        </login>
    </authentication>
    <content>
        <function controlid=""unittest"">
            <getAPISession />
        </function>
    </content>
</operation>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            OperationBlock operationBlock = new OperationBlock(config, contentBlock);

            operationBlock.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
        public void GetCredentialsFromDefaultProfileTest()
        {
            var parser = new FileIniDataParser();

            string ini = @"
[default]
sender_id = defsenderid
sender_password = defsenderpass
company_id = defcompanyid
user_id = defuserid
user_password = defuserpass
endpoint_url = https://unittest.intacct.com/ia/xmlgw.phtml

[unittest]
company_id = inicompanyid
user_id = iniuserid
user_password = iniuserpass";

            string tempFile = Path.Combine(Path.GetTempPath(), ".intacct", "credentials.ini");

            using (StreamWriter sw = new StreamWriter(tempFile))
            {
                sw.WriteLine(ini);
            }

            SdkConfig config = new SdkConfig()
            {
                ProfileFile = tempFile,
            };

            SdkConfig loginCreds = provider.GetLoginCredentials(config);

            SdkConfig expectedLogin = new SdkConfig()
            {
                CompanyId    = "defcompanyid",
                UserId       = "defuserid",
                UserPassword = "******",
            };

            Assert.AreEqual(expectedLogin.CompanyId, loginCreds.CompanyId);
            Assert.AreEqual(expectedLogin.UserId, loginCreds.UserId);
            Assert.AreEqual(expectedLogin.UserPassword, loginCreds.UserPassword);

            SdkConfig senderCreds = provider.GetSenderCredentials(config);

            SdkConfig expectedSender = new SdkConfig()
            {
                SenderId       = "defsenderid",
                SenderPassword = "******",
                EndpointUrl    = "https://unittest.intacct.com/ia/xmlgw.phtml",
            };

            Assert.AreEqual(expectedSender.SenderId, senderCreds.SenderId);
            Assert.AreEqual(expectedSender.SenderPassword, senderCreds.SenderPassword);
            Assert.AreEqual(expectedSender.EndpointUrl, senderCreds.EndpointUrl);
        }
Пример #31
0
 /// <summary>
 /// Connects this instance.
 /// </summary>
 /// <returns></returns>
 public new bool Connect()
 {
     Sdk = SDKConfig.Current;
     return this.Connect(Sdk.Address, Sdk.Port,Sdk.UserName, Sdk.UserPass,Sdk.GroupCode);
 }