Beispiel #1
0
        public void BaseFixtureSetup()
        {
            _config = CreateConfiguration();

            _api = new RestfulBusinessApiClient(_config);

            _api.Authenticate();
        }
        public void GetJson_AutoAuthenticate_UsageExample()
        {
            var apiConfig = RqlApiConfiguration.FromAppConfig();

            var api = new BasicBusinessApiClient(apiConfig);

            var widget = api.GetJson <string>("Widgets/123");

            Console.WriteLine(widget);
        }
        public BasicBusinessApiClient(RqlApiConfiguration apiConfig)
        {
            if (apiConfig == null)
            {
                throw new ArgumentNullException(nameof(apiConfig));
            }
            if (string.IsNullOrEmpty(apiConfig.Site))
            {
                throw new ArgumentException("SiteName cannot be null or empty", nameof(apiConfig));
            }
            if (string.IsNullOrEmpty(apiConfig.UserName))
            {
                throw new ArgumentException("UserName cannot be null or empty", nameof(apiConfig));
            }
            if (string.IsNullOrEmpty(apiConfig.Password))
            {
                throw new ArgumentException("Password cannot be null or empty", nameof(apiConfig));
            }

            _apiConfig = apiConfig;

            EnableTls();
        }
        public void PostJson_ManuallyAuthenticate_UsageExample()
        {
            var apiConfig = RqlApiConfiguration.FromAppConfig();

            var api = new BasicBusinessApiClient(apiConfig);

            api.Authenticate();

            var widget = api.PostJson <string>("Widgets", new
            {
                Id          = "123",
                Name        = "Widget Name",
                Type        = "Type A Widget",
                StringArray = new[] { "string 1", "string 2" },
                ExtraInfo   = new Dictionary <string, string>
                {
                    { "Key1", "Value1" }
                }
            }
                                               );

            Console.WriteLine(widget);
        }