コード例 #1
0
        public static RestServiceClientBase GetRestClient(string type)
        {
            RestServiceClientBase restClient = null;

            switch (type)
            {
            case "OrganizationRestClient":
                restClient = new OrganizationRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "PaymentReportsRestClient":
                restClient = new PaymentReportsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "OrdersRestClient":
                restClient = new OrdersRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "ReportsRestClient":
                restClient = new ReportsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "ContractsRestClient":
                restClient = new ContractsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "PaymentsRestClient":
                restClient = new PaymentsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "UserRestClient":
                restClient = new UserRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "ReferencesRestClient":
                restClient = new ReferencesRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "SiteRestClient":
                restClient = new SiteRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "OrdersDocumentsRestClient":
                restClient = new OrdersDocumentsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "FlightsRestClient":
                restClient = new FlightsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "SystemRestClient":
                restClient = new SystemRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            default:
                throw new Exception("RestClient type was set incorrectly.");
            }
            restClient.ImpersonationToken = new ImpersonationToken(Config.UserLogin, Config.UserPassword);
            return(restClient);
        }
コード例 #2
0
        private OrdersDocumentsRestClient CreateRestClient()
        {
            var restClient = new OrdersDocumentsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);

            restClient.ImpersonationToken = new ImpersonationToken(Config.UserLogin, Config.UserPassword);

            return(restClient);
        }