コード例 #1
0
            //Respones in private methods.
            internal void ExchangeRate(IAPIProspect result, APIConfiguration config)
            {
                if (result is RealtimeCurrencyExchange)
                {
                    var res = (result as RealtimeCurrencyExchange).RealtimeCurrencyExchangeRate;

                    "Exchange Currency ".Write(ConsoleTextStyle.INVERSE); "Information Received...".WriteLine(ConsoleTextStyle.SUCCESS);
                    $@"     >> From {res?.FromCurrencyName}({res?.FromCurrencyCode}) to {res?.ToCurrencyName}({res?.ToCurrencyCode}) => Exchange Rate: {res?.ExchangeRate}"
                    .WriteLine(ConsoleTextStyle.WARNING);

                    //if (_exchangeCountry > 2) config?.Cancel(); //Cancellation Token used.
                    //if (_exchangeCountry > 2) config?.CancelCurrentRepeat(); //Cancellation only for current Repeated API.

                    if (_exchangeCountry < _currencies.Length)
                    {
                        config?.UpdateObjectParams(new ExchangeCurrency {
                            ToCurrency = _currencies[_exchangeCountry++]
                        },
                                                   new StockQuoteSymbols {
                            Symbols = "DIS,AXP"
                        });
                    }
                    config?.InsertObjectParam(res);
                }
            }
コード例 #2
0
 public FilterOperatorExpressionTest()
 {
     entityList = APIConfiguration.Init <DataContext>(new AutoAPIOptions()
     {
         Path = "/api/data"
     });
 }
コード例 #3
0
 public RestAPIControllerTests()
 {
     entityList = APIConfiguration.Init <DataContext>(new AutoAPIOptions()
     {
         Path = "/api"
     });
 }
コード例 #4
0
 public AutoAPIMiddlewareTests()
 {
     entityList = APIConfiguration.Init <DataContext>(new AutoAPIOptions()
     {
         Path = "/api/data"
     });
 }
コード例 #5
0
 public AzureStorageRepositoryService(
     APIConfiguration configuration,
     IFileService fileService)
 {
     _configuration = configuration;
     _fileService   = fileService;
 }
コード例 #6
0
        public static List <Models.Movie> SearchMovie(string title)
        {
            try
            {
                SearchContainer <SearchMovie> results = APIConfiguration.ConnectAPI().SearchMovie("star wars");
                List <Models.Movie>           mlist   = new List <Models.Movie>();

                if (!String.IsNullOrEmpty(title))
                {
                    results = APIConfiguration.ConnectAPI().SearchMovie(title);
                }

                foreach (SearchMovie result in results.Results)
                {
                    TMDbLib.Objects.Movies.Movie trial = APIConfiguration.ConnectAPI().GetMovie(result.Id, MovieMethods.Videos);

                    Models.Movie movie = new Models.Movie()
                    {
                        MovieID = result.Id,
                        Poster  = ConfigurationManager.AppSettings["PosterPath"] + result.PosterPath,
                        Summary = result.Overview,
                        Title   = result.Title,
                        URL     = trial.Videos.Results.Count > 0 ? ConfigurationManager.AppSettings["YouTubePath"] + trial.Videos.Results[0].Key : ConfigurationManager.AppSettings["YouTubePath"]
                    };
                    mlist.Add(movie);
                }
                return(mlist);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw;
            }
        }
        public async Task ProvideVersions()
        {
            var version           = new Version(1, 1);
            var academicYear      = "1920";
            var cancellationToken = CancellationToken.None;

            var repositoryServiceMock = new Mock <IRepositoryService>();

            repositoryServiceMock
            .Setup(rs => rs.IsLatestDesktopApplicationVersion(academicYear, version, cancellationToken))
            .ReturnsAsync(true);

            var apiCacheProviderMock = new Mock <IAPICacheRetrievalService>();

            apiCacheProviderMock
            .Setup(cp => cp.GetOrCreate("Versions1920", It.IsAny <int>(), It.IsAny <Task <bool> >()))
            .ReturnsAsync(true);

            var config = new APIConfiguration
            {
                SubmitLearnerDataDownloadsUrl = "TestURl",
                CacheExpiration = 5
            };

            var service = NewService(repositoryServiceMock.Object, apiCacheProviderMock.Object, config);
            var result  = await service.IsLatestVersion(academicYear, version, cancellationToken);

            result.Should().Be(true);
        }
コード例 #8
0
        public SpeakerIBMWatson(APIConfiguration config)
        {
            IamAuthenticator authenticator = new IamAuthenticator(apikey: config.APIKey);

            _service = new IBM.Watson.TextToSpeech.v1.TextToSpeechService(authenticator);
            _service.SetServiceUrl(config.APIEndpoint);
        }
コード例 #9
0
        public ConnectorFacade CreateConnectorFacade(SafeType <Connector> clazz)
        {
            if (null == _facade)
            {
                PropertyBag propertyBag = TestHelpers.GetProperties(clazz.RawType);

                string assemblyFolder         = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string testModulePath         = Path.GetFullPath(Path.Combine(assemblyFolder, "..\\..\\..\\Samples\\Tests\\TestModule.psm1"));
                string objectChacheModulePath = typeof(ObjectCacheLibrary).Assembly.Location;

                var importModules = new string[] { testModulePath, objectChacheModulePath };


                APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, propertyBag, "configuration");
                impl.ConfigurationProperties.SetPropertyValue("PsModulesToImport", importModules);
                //
                impl.ProducerBufferSize = 0;
                impl.ResultsHandlerConfiguration.EnableAttributesToGetSearchResultsHandler = false;
                impl.ResultsHandlerConfiguration.EnableCaseInsensitiveFilter     = false;
                impl.ResultsHandlerConfiguration.EnableFilteredResultsHandler    = false;
                impl.ResultsHandlerConfiguration.EnableNormalizingResultsHandler = false;

                //We timeout after 10s
                impl.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(CreateApiOp)), 10000);
                impl.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(UpdateApiOp)), 10000);
                impl.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(DeleteApiOp)), 10000);
                _facade = ConnectorFacadeFactory.GetInstance().NewInstance(impl);
            }
            return(_facade);
        }
コード例 #10
0
 public ExpressionBuilderTests()
 {
     entityList = APIConfiguration.Init <DataContext>(new AutoAPIOptions()
     {
         Path = "/api/data"
     });
 }
コード例 #11
0
        /// <summary>
        /// Create - create a new project group (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project_group.md#create---create-a-new-project-group"/>)
        /// </summary>
        public static ProjectGroupCreateResponse Create(string name, string locale = "en", APIConfiguration configuration = null)
        {
            // Should actually return a rich ProjectGroupCreateResponse including Data but it seems there is a bug in the API and it returns an empty string right now

            Dictionary<string, object> args = new Dictionary<string, object>();

            args["name"] = name;

            if (locale != "en") {
                args["locale"] = locale;
            }

            IRestResponse resp = APIBase.GetResponse<IRestResponse>(configuration, "project-groups", args, RestSharp.Method.POST);

            if (resp.StatusCode != System.Net.HttpStatusCode.Created) {
                throw new Exception("Failed to create Project Group", new Exception(string.Format("Status: {0}", (int)resp.StatusCode)));
            }

            ProjectGroupCreateResponse respData = new ProjectGroupCreateResponse() {
                Meta = new Metadata() { Status = (int)resp.StatusCode },
                Data = null
            };

            return respData;
        }
コード例 #12
0
 public void Error <T>(T exception, APIConfiguration config, params object[] others) where T : APIException
 {
     if (exception != null)
     {
         Console.WriteLine($"Error Status({exception.Status})/Message ('{exception.Message}') , URL '{exception.Url}' ");
     }
 }
コード例 #13
0
        public IList <ConnectorFacade> CreateStateFulFacades()
        {
            IList <ConnectorFacade> test = new List <ConnectorFacade>(2);

            ConnectorInfoManager manager = GetConnectorInfoManager();
            ConnectorInfo        info    = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstStatefulConnector");

            Assert.IsNotNull(info);

            APIConfiguration config = info.CreateDefaultAPIConfiguration();

            test.Add(ConnectorFacadeFactory.GetInstance().NewInstance(config));

            info = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstStatefulPoolableConnector");
            Assert.IsNotNull(info);

            config = info.CreateDefaultAPIConfiguration();

            config.ConnectorPoolConfiguration.MinIdle = 0;
            config.ConnectorPoolConfiguration.MaxIdle = 0;

            test.Add(ConnectorFacadeFactory.GetInstance().NewInstance(config));

            return(test);
        }
コード例 #14
0
        public void TestConfiguration()
        {
            APIConfiguration result = Config.Client.GetAPIConfiguration().Sync();

            Assert.NotNull(result);

            Assert.Contains(result.Images.BackdropSizes, c => c == "original");
        }
コード例 #15
0
        public void TestTimeout()
        {
            ConnectorInfoManager manager = GetConnectorInfoManager();
            ConnectorInfo        info1   = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstConnector");

            Assert.IsNotNull(info1);

            APIConfiguration config = info1.CreateDefaultAPIConfiguration();

            config.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(CreateApiOp)), 5000);
            config.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(SearchApiOp)), 5000);
            ConfigurationProperties props    = config.ConfigurationProperties;
            ConfigurationProperty   property = props.GetProperty("numResults");

            // 1000 is several times the remote size between pauses
            property.Value = 2;
            OperationOptionsBuilder opBuilder = new OperationOptionsBuilder();

            opBuilder.SetOption("delay", 10000);

            ConnectorFacade facade1 = ConnectorFacadeFactory.GetInstance().NewInstance(config);

            ICollection <ConnectorAttribute> attrs = CollectionUtil.NewReadOnlySet <ConnectorAttribute>();

            try
            {
                facade1.Create(ObjectClass.ACCOUNT, attrs, opBuilder.Build()).GetUidValue();
                Assert.Fail("expected timeout");
            }
            catch (OperationTimeoutException)
            {
                // expected
            }
            //catch (RemoteWrappedException e)
            //{
            //    Assert.IsTrue(e.Is(typeof(OperationTimeoutException)));
            //}

            try
            {
                facade1.Search(ObjectClass.ACCOUNT, null, new ResultsHandler()
                {
                    Handle = obj =>
                    {
                        return(true);
                    }
                }, opBuilder.Build());
                Assert.Fail("expected timeout");
            }
            catch (OperationTimeoutException)
            {
                // expected
            }
            //catch (RemoteWrappedException e)
            //{
            //    Assert.IsTrue(e.Is(typeof(OperationTimeoutException)));
            //}
        }
 public ReferenceDataVersionsController(
     APIConfiguration configuration,
     IReferenceDataVersionProvider provider,
     IFileProviderService fileProviderService)
 {
     _configuration       = configuration;
     _provider            = provider;
     _fileProviderService = fileProviderService;
 }
 public ReferenceDataVersionProvider(
     IRepositoryService repositoryService,
     IAPICacheRetrievalService apiCacheRetrieval,
     APIConfiguration configuration)
 {
     _repositoryService = repositoryService;
     _apiCacheRetrieval = apiCacheRetrieval;
     _configuration     = configuration;
 }
コード例 #18
0
        public void ConferencesConnectorListConferencesTest()
        {
            const string methodName = "listConferences";

            using (new MockServer(Port, "Accounts/{accountSid}/Conferences.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("GET"))
                {
                    throw new ArgumentException();
                }

                // Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(
                        assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseListJsonFileNameConference}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // List conferences using conferences connector
                var conferenceList = service.ConferencesConnector.ListConferences("TestConference",
                                                                                  jsonRequest.QueryParameter("FriendlyName"),
                                                                                  EnumHelper.ParseEnum <ConferenceStatus>(jsonRequest.QueryParameter("Status")),
                                                                                  ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateCreated>")),
                                                                                  ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateCreated<")),
                                                                                  ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateUpdated>")),
                                                                                  ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateUpdated<")),
                                                                                  Convert.ToInt32(jsonRequest.QueryParameter("Page")),
                                                                                  Convert.ToInt32(jsonRequest.QueryParameter("PageSize")));

                Assert.AreEqual(2, conferenceList.Total);

                var conference = conferenceList.Elements.First();

                Assert.AreEqual("TestConferenceSid", conference.Sid);
                Assert.AreEqual(ConferenceStatus.COMPLETED, conference.Status);
                Assert.AreEqual("TestConference", conference.FriendlyName);
            }
        }
コード例 #19
0
 public ApplicationVersionsProvider(
     IRepositoryService applicationVersionsRepositoryService,
     IAPICacheRetrievalService apiCacheRetrieval,
     APIConfiguration configuration)
 {
     _applicationVersionsRepositoryService = applicationVersionsRepositoryService;
     _apiCacheRetrieval = apiCacheRetrieval;
     _configuration     = configuration;
 }
コード例 #20
0
        /// <summary>
        /// 判断API Key是否有效
        /// </summary>
        /// <param name="apiKey">API Key</param>
        /// <param name="secretKey">Secret Key</param>
        /// <returns>API响应状态,响应状态码为1时有效</returns>
        public static APIResponse Login(string apiKey, string secretKey)
        {
            APIConfiguration configuration = new APIConfiguration(apiKey, secretKey);
            HttpUtility      httpUtility   = new HttpUtility(configuration);
            string           result        = httpUtility.PostAPIRequest("domain");
            APIResponse      response      = JsonConvert.DeserializeObject <APIResponse>(result);

            return(response);
        }
コード例 #21
0
        public void CallsConnectorListCalls()
        {
            const string methodName = "listCalls";

            using (new MockServer(Port, "Accounts/{accountSid}/Calls.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("GET"))
                {
                    throw new ArgumentException();
                }

                //// Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseListJsonFileName}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // List calls using calls connector
                var callList = service.CallsConnector.ListCalls(jsonRequest.QueryParameter("To"),
                                                                jsonRequest.QueryParameter("From"), EnumHelper.ParseEnum <CallStatus>(jsonRequest.QueryParameter("Status")),
                                                                ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("StartTime>")),
                                                                ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("StartTime<")), Convert.ToInt32(jsonRequest.QueryParameter("Page")),
                                                                Convert.ToInt32(jsonRequest.QueryParameter("PageSize")));

                Assert.AreEqual(1, callList.Total);
                Assert.AreEqual(1, callList.Numpages);
                Assert.AreEqual(jsonRequest.QueryParameter("Page"), callList.Page.ToString());
                Assert.AreEqual(jsonRequest.QueryParameter("PageSize"), callList.Pagesize.ToString());

                var call = callList.Elements.First();

                Assert.AreEqual(jsonRequest.QueryParameter("To"), call.To);
                Assert.AreEqual(AnsweredBy.TBD, call.AnsweredBy);
                Assert.AreEqual(Convert.ToDecimal(0.1872), call.Price);
                Assert.AreEqual(CallStatus.COMPLETED, call.Status);
            }
        }
コード例 #22
0
        public void TranscriptionsConnectorListTranscriptionsTest()
        {
            const string methodName = "listTranscriptions";

            using (new MockServer(Port, "Accounts/{accountSid}/Transcriptions.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("GET"))
                {
                    throw new ArgumentException();
                }

                // Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseListJsonFileName}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // List transcriptions using transcriptions connector
                var transcriptionsList = service.TranscriptionsConnector.ListTranscriptions(
                    EnumHelper.ParseEnum <TranscriptionStatus>(jsonRequest.QueryParameter("Status")),
                    ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateTranscribed>")),
                    ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateTranscribed<")),
                    Convert.ToInt32(jsonRequest.QueryParameter("Page")), Convert.ToInt32(jsonRequest.QueryParameter("PageSize")));

                Assert.AreEqual(Convert.ToInt32(jsonRequest.QueryParameter("PageSize")), transcriptionsList.Pagesize);
                Assert.AreEqual(Convert.ToInt32(jsonRequest.QueryParameter("Page")), transcriptionsList.Page);
                Assert.AreEqual(2, transcriptionsList.Total);

                var transcription = transcriptionsList.Elements.First();

                Assert.AreEqual("http://dev.calyx.hr/~vprenner/zang.mp3", transcription.AudioUrl);
                Assert.AreEqual(TranscriptionStatus.COMPLETED, transcription.Status);
                Assert.AreEqual(50, transcription.Duration);
            }
        }
コード例 #23
0
        public void IncomingPhoneNumbersConnectorPurchaseIncomingNumberTest()
        {
            const string methodName = "purchaseIncomingPhoneNumber";

            using (new MockServer(Port, "/Accounts/{accountSid}/IncomingPhoneNumbers.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("POST"))
                {
                    throw new ArgumentException();
                }

                // Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseJsonFileName}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // Purchase incoming phone number using incoming phone numbers connector
                var phoneNumber = service.IncomingPhoneNumbersConnector.PurchaseIncomingNumber("TestAccountSid",
                                                                                               jsonRequest.BodyParameter("PhoneNumber"), jsonRequest.BodyParameter("AreaCode"), jsonRequest.BodyParameter("FriendlyName"),
                                                                                               jsonRequest.BodyParameter("VoiceUrl"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("VoiceMethod")),
                                                                                               jsonRequest.BodyParameter("VoiceFallbackUrl"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("VoiceFallbackMethod")),
                                                                                               Convert.ToBoolean(jsonRequest.BodyParameter("VoiceCallerIdLookup")),
                                                                                               jsonRequest.BodyParameter("SmsUrl"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("SmsMethod")),
                                                                                               jsonRequest.BodyParameter("SmsFallbackUrl"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("SmsFallbackMethod")),
                                                                                               jsonRequest.BodyParameter("HeartbeatUrl"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("HeartbeatMethod")),
                                                                                               jsonRequest.BodyParameter("StatusCallback"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("StatusCallbackMethod")),
                                                                                               jsonRequest.BodyParameter("HangupCallback"), EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("HangupCallbackMethod")),
                                                                                               jsonRequest.BodyParameter("VoiceApplicationSid"), jsonRequest.BodyParameter("SmsApplicationSid"));

                Assert.AreEqual("(989) 494-5633", phoneNumber.FriendlyName);
                Assert.AreEqual(jsonRequest.BodyParameter("PhoneNumber"), phoneNumber.PhoneNumber);
                Assert.AreEqual(jsonRequest.BodyParameter("SmsUrl"), phoneNumber.SmsUrl);
            }
        }
コード例 #24
0
        public void IncomingPhoneNumbersConnectorListIncomingPhoneNumbersTest()
        {
            const string methodName = "listIncomingPhoneNumbers";

            using (new MockServer(Port, "Accounts/{accountSid}/IncomingPhoneNumbers.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("GET"))
                {
                    throw new ArgumentException();
                }

                // Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseListJsonFileName}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // List View incoming phone numbers using incoming phone numbers connector
                var phoneNumbersList =
                    service.IncomingPhoneNumbersConnector.ListIncomingNumbers(jsonRequest.QueryParameter("Contains"),
                                                                              jsonRequest.QueryParameter("FriendlyName"), Convert.ToInt32(jsonRequest.QueryParameter("Page")),
                                                                              Convert.ToInt32(jsonRequest.QueryParameter("PageSize")));

                Assert.AreEqual(Convert.ToInt32(jsonRequest.QueryParameter("PageSize")), phoneNumbersList.Pagesize);
                Assert.AreEqual(Convert.ToInt32(jsonRequest.QueryParameter("Page")), phoneNumbersList.Page);

                Assert.AreEqual(1, phoneNumbersList.Total);

                var phoneNumber = phoneNumbersList.Elements.First();

                Assert.AreEqual("(989) 494-5633", phoneNumber.FriendlyName);
                Assert.AreEqual(IncomingPhoneNumberType.LOCAL, phoneNumber.Type);
            }
        }
コード例 #25
0
        public void TestAPIConfiguration()
        {
            ConnectorInfoManager manager =
                GetConnectorInfoManager();
            ConnectorInfo info =
                FindConnectorInfo(manager,
                                  "1.0.0.0",
                                  "org.identityconnectors.testconnector.TstConnector");

            Assert.IsNotNull(info);
            APIConfiguration api = info.CreateDefaultAPIConfiguration();

            ConfigurationProperties props    = api.ConfigurationProperties;
            ConfigurationProperty   property = props.GetProperty("tstField");

            Assert.IsNotNull(property);
            ICollection <SafeType <APIOperation> > operations =
                property.Operations;

            Assert.AreEqual(1, operations.Count);
            Assert.IsTrue(operations.Contains(SafeType <APIOperation> .Get <SyncApiOp>()));

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
            Assert.AreEqual("Help for test field.", property.GetHelpMessage(null));
            Assert.AreEqual("Display for test field.", property.GetDisplayName(null));
            Assert.AreEqual("Group for test field.", property.GetGroup(null));
            Assert.AreEqual("Test Framework Value",
                            info.Messages.Format("TEST_FRAMEWORK_KEY", "empty"));

            CultureInfo eslocale = new CultureInfo("es");

            Thread.CurrentThread.CurrentUICulture = eslocale;
            Assert.AreEqual("tstField.help_es", property.GetHelpMessage(null));
            Assert.AreEqual("tstField.display_es", property.GetDisplayName(null));

            CultureInfo esESlocale = new CultureInfo("es-ES");

            Thread.CurrentThread.CurrentUICulture = esESlocale;
            Assert.AreEqual("tstField.help_es-ES", property.GetHelpMessage(null));
            Assert.AreEqual("tstField.display_es-ES", property.GetDisplayName(null));

            CultureInfo esARlocale = new CultureInfo("es-AR");

            Thread.CurrentThread.CurrentUICulture = esARlocale;
            Assert.AreEqual("tstField.help_es", property.GetHelpMessage(null));
            Assert.AreEqual("tstField.display_es", property.GetDisplayName(null));

            ConnectorFacadeFactory facf   = ConnectorFacadeFactory.GetInstance();
            ConnectorFacade        facade = facf.NewInstance(api);

            // call the various create/update/delete commands..
            facade.Schema();
        }
コード例 #26
0
        public void RecordingsConnectorListRecordingsTest()
        {
            const string methodName = "listRecordings";

            using (new MockServer(Port, "Accounts/{accountSid}/Recordings.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("GET"))
                {
                    throw new ArgumentException();
                }

                // Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseListJsonFileName}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // List recordings using recordings connector
                var recordingsList = service.RecordingsConnector.ListRecordings("TestCallSid",
                                                                                ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateCreated>")),
                                                                                ParametersHelper.GetDateFromString(jsonRequest.QueryParameter("DateCreated<")),
                                                                                Convert.ToInt32(jsonRequest.QueryParameter("Page")),
                                                                                Convert.ToInt32(jsonRequest.QueryParameter("PageSize")));

                Assert.AreEqual(Convert.ToInt32(jsonRequest.QueryParameter("PageSize")), recordingsList.Pagesize);
                Assert.AreEqual(Convert.ToInt32(jsonRequest.QueryParameter("Page")), recordingsList.Page);
                Assert.AreEqual(1, recordingsList.Total);

                var recording = recordingsList.Elements.First();

                Assert.AreEqual("http://recordings.telapi.com/RBfcc94a3e2b5d4e4c89f7017d6387ffb8/RE4288908463cd614b41084509ad8893a7.mp3", recording.RecordingUrl);
                Assert.AreEqual(15, recording.Duration);
            }
        }
コード例 #27
0
        public void CallsConnectorRecordLiveCall()
        {
            const string methodName = "recordLiveCall";

            using (new MockServer(Port, "Accounts/{accountSid}/Calls/{callSid}.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("POST"))
                {
                    throw new ArgumentException();
                }

                //// Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseJsonFileName}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // Record live call using calls connector
                var call = service.CallsConnector.RecordLiveCall("TestCallSid",
                                                                 Convert.ToBoolean(jsonRequest.BodyParameter("Record")),
                                                                 EnumHelper.ParseEnum <RecordingAudioDirection>(jsonRequest.BodyParameter("Direction")),
                                                                 Convert.ToInt32(jsonRequest.BodyParameter("TimeLimit")),
                                                                 jsonRequest.BodyParameter("CallbackUrl"),
                                                                 EnumHelper.ParseEnum <RecordingFileFormat>(jsonRequest.BodyParameter("FileFormat")),
                                                                 Convert.ToBoolean(jsonRequest.BodyParameter("TrimSilence")),
                                                                 Convert.ToBoolean(jsonRequest.BodyParameter("Transcribe")),
                                                                 EnumHelper.ParseEnum <TranscribeQuality>(jsonRequest.BodyParameter("TranscribeQuality")),
                                                                 jsonRequest.BodyParameter("TranscribeCallback"));

                Assert.AreEqual(AnsweredBy.TBD, call.AnsweredBy);
                Assert.AreEqual(Convert.ToDecimal(0.1872), call.Price);
                Assert.AreEqual(CallStatus.COMPLETED, call.Status);
            }
        }
        private AzureStorageRepositoryService NewService(APIConfiguration configuration = null, IFileService fileService = null)
        {
            var config = new APIConfiguration
            {
                Container = "Container",
                ApplicationFileNameReference = "Desktop",
                RefDataFileNameReference     = "FISReferenceData",
                RefDataFilePathPrefix        = "DesktopReferenceData/1920"
            };

            return(new AzureStorageRepositoryService(configuration ?? config, fileService));
        }
コード例 #29
0
        public void SipDomainsConnectorCreateDomainTest()
        {
            const string methodName = "createDomain";

            using (new MockServer(Port, "Accounts/{accountSid}/SIP/Domains.json", (req, rsp, prm) =>
            {
                // Check http method
                if (!req.HttpMethod.Equals("POST"))
                {
                    throw new ArgumentException();
                }

                // Check parameter equality
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "bodyParams", req);
                ParametersHelper.CheckParametersEquality(TestGroupName, methodName, "queryParams", req);

                // Define server response
                var assembly = Assembly.GetExecutingAssembly();
                var streamReader =
                    new StreamReader(assembly.GetManifestResourceStream($"AvayaCPaaS.Tests.{ResponseJsonFileNameDomain}"));
                var json = streamReader.ReadToEnd();

                var buffer = Encoding.ASCII.GetBytes(json);
                rsp.Content(buffer);
            }))
            {
                // Create configuration
                var configuration = new APIConfiguration(AccountSid, AuthToken);
                configuration.BaseUrl = $"http://localhost:{Port}/";

                // Get json request from json file
                var jsonRequest = ParametersHelper.GetJsonRequestByGroupAndMethod(TestGroupName, methodName);

                // Create service
                var service = new CPaaSService(configuration);

                // Create domain using domains connector
                var domain = service.SipDomainsConnector.CreateDomain("TestAccountSid",
                                                                      jsonRequest.BodyParameter("DomainName"), jsonRequest.BodyParameter("FriendlyName"),
                                                                      jsonRequest.BodyParameter("VoiceUrl"),
                                                                      EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("VoiceMethod")),
                                                                      jsonRequest.BodyParameter("VoiceFallbackUrl"),
                                                                      EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("VoiceFallbackMethod")),
                                                                      jsonRequest.BodyParameter("HeartbeatUrl"),
                                                                      EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("HeartbeatMethod")),
                                                                      jsonRequest.BodyParameter("VoiceStatusCallback"),
                                                                      EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("VoiceStatusCallbackMethod")));

                Assert.AreEqual(jsonRequest.BodyParameter("DomainName"), domain.DomainName);
                Assert.AreEqual(jsonRequest.BodyParameter("FriendlyName"), domain.FriendlyName);
                Assert.AreEqual(EnumHelper.ParseEnum <HttpMethod>(jsonRequest.BodyParameter("VoiceMethod")), domain.VoiceMethod);
            }
        }
コード例 #30
0
        private ReferenceDataVersionsController NewController(APIConfiguration configuration = null, IReferenceDataVersionProvider provider = null, IFileProviderService fileProviderService = null)
        {
            var config = new APIConfiguration
            {
                Container = "Container",
                ApplicationFileNameReference = "Desktop",
                RefDataFileNameReference     = "FISReferenceData",
                RefDataFilePathPrefix        = "DesktopReferenceData"
            };

            return(new ReferenceDataVersionsController(configuration ?? config, provider, fileProviderService));
        }
コード例 #31
0
        public void TestConnectionPooling()
        {
            ConnectorPoolManager.Dispose();
            ConnectorInfoManager manager =
                GetConnectorInfoManager();
            ConnectorInfo info1 =
                FindConnectorInfo(manager,
                                  "1.0.0.0",
                                  "org.identityconnectors.testconnector.TstConnector");

            Assert.IsNotNull(info1);
            //reset connection count
            {
                //trigger TstConnection.init to be called
                APIConfiguration config2 =
                    info1.CreateDefaultAPIConfiguration();
                config2.ConfigurationProperties.GetProperty("resetConnectionCount").Value = (true);
                ConnectorFacade facade2 =
                    ConnectorFacadeFactory.GetInstance().NewInstance(config2);
                facade2.Schema(); //force instantiation
            }

            APIConfiguration config =
                info1.CreateDefaultAPIConfiguration();

            config.ConnectorPoolConfiguration.MinIdle = (0);
            config.ConnectorPoolConfiguration.MaxIdle = (0);

            ConnectorFacade facade1 =
                ConnectorFacadeFactory.GetInstance().NewInstance(config);

            OperationOptionsBuilder builder = new OperationOptionsBuilder();

            builder.SetOption("testPooling", "true");
            OperationOptions options = builder.Build();
            ICollection <ConnectorAttribute> attrs = CollectionUtil.NewReadOnlySet <ConnectorAttribute>();

            Assert.AreEqual("1", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("2", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("3", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("4", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            config =
                info1.CreateDefaultAPIConfiguration();
            config.ConnectorPoolConfiguration.MinIdle = (1);
            config.ConnectorPoolConfiguration.MaxIdle = (2);
            facade1 =
                ConnectorFacadeFactory.GetInstance().NewInstance(config);
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
        }
コード例 #32
0
        /// <summary>
        /// List - retrieve all project groups (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project_group.md#list---retrieve-all-project-groups"/>)
        /// </summary>
        public static ProjectGroupListResponse List(int page = 1, int groupsPerPage = 50, APIConfiguration configuration = null)
        {
            Dictionary<string, object> args = new Dictionary<string, object>();

            if (page != 1) {
                args["page"] = page;
            }

            if (groupsPerPage != 50) {
                args["per_page"] = groupsPerPage;
            }

            return APIBase.GetResponse<ProjectGroupListResponse>(configuration, "project-groups", args);
        }
コード例 #33
0
        /// <summary>
        /// Delete - remove project (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md#delete---remove-project"/>)
        /// </summary>
        public static ProjectDeleteResponse Delete(int projectId, APIConfiguration configuration = null)
        {
            string methodName = string.Format("projects/{0}", projectId);

            IRestResponse resp = APIBase.GetResponse<IRestResponse>(configuration, methodName, null, RestSharp.Method.DELETE);

            if (resp.StatusCode != System.Net.HttpStatusCode.OK) {
                throw new Exception("Failed to delete Project", new Exception(string.Format("Status: {0}", (int)resp.StatusCode)));
            }

            ProjectDeleteResponse respData = new ProjectDeleteResponse() {
                Meta = new Metadata() { Status = (int)resp.StatusCode }
            };

            return respData;
        }
コード例 #34
0
ファイル: File.cs プロジェクト: everydayiplay/OneSkyAppSharp
        /// <summary>
        /// List - list uploaded files (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/file.md#list---list-uploaded-files"/>)
        /// </summary>
        public static FileListResponse List(int projectId, int page = 1, int groupsPerPage = 50, APIConfiguration configuration = null)
        {
            string methodName = string.Format("projects/{0}/files", projectId);

            Dictionary<string, object> args = new Dictionary<string, object>();

            if (page != 1) {
                args["page"] = page;
            }

            if (groupsPerPage != 50) {
                args["per_page"] = groupsPerPage;
            }

            return APIBase.GetResponse<FileListResponse>(configuration, methodName, args);
        }
コード例 #35
0
        /// <summary>
        /// Create - create a new project (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md#create---create-a-new-project"/>)
        /// </summary>
        public static ProjectCreateResponse Create(int projectGroupId, string projectType, string name = "", string description = "", APIConfiguration configuration = null)
        {
            string methodName = string.Format("project-groups/{0}/projects", projectGroupId.ToString());

            Dictionary<string, object> args = new Dictionary<string, object>();

            args["project_type"] = projectType;

            if (!string.IsNullOrEmpty(name)) {
                args["name"] = name;
            }

            if (!string.IsNullOrEmpty(description)) {
                args["description"] = description;
            }

            ProjectCreateResponse resp = APIBase.GetResponse<ProjectCreateResponse>(configuration, methodName, args, Method.POST);

            if (resp.Meta.Status != (int)System.Net.HttpStatusCode.Created) {
                throw new Exception("Failed to create Project", new Exception(string.Format("Status: {0}", (int)resp.Meta.Status)));
            }

            return resp;
        }
コード例 #36
0
        /// <summary>
        /// Languages - list enabled languages of a project group (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project_group.md#languages---list-enabled-languages-of-a-project-group"/>)
        /// </summary>
        public static ProjectGroupListLanguagesResponse ListLanguages(int projectGroupId, APIConfiguration configuration = null)
        {
            string methodName = string.Format("project-groups/{0}/languages", projectGroupId);

            return APIBase.GetResponse<ProjectGroupListLanguagesResponse>(configuration, methodName);
        }
コード例 #37
0
 /// <summary>
 /// {@inheritDoc}
 /// </summary>
 public override ConnectorFacade NewInstance(APIConfiguration config)
 {
     ConnectorFacade facade = base.NewInstance(config);
     lock (CACHE)
     {
         Pair<DateTime, ConnectorFacade> cachedFacade = CollectionUtil.GetValue(CACHE, facade.ConnectorFacadeKey, null);
         if (null == cachedFacade)
         {
             CACHE[facade.ConnectorFacadeKey] = Pair<DateTime, ConnectorFacade>.Of(DateTime.Now, facade);
         }
         else
         {
             Trace.TraceInformation("ConnectorFacade found in cache");
             cachedFacade.First = DateTime.Now;
             facade = cachedFacade.Second;
         }
     }
     return facade;
 }
コード例 #38
0
 public override ConnectorFacade NewInstance(APIConfiguration config)
 {
     ConnectorFacade ret = null;
     APIConfigurationImpl impl = (APIConfigurationImpl)config;
     AbstractConnectorInfo connectorInfo = impl.ConnectorInfo;
     if (connectorInfo is LocalConnectorInfoImpl)
     {
         LocalConnectorInfoImpl localInfo =
             (LocalConnectorInfoImpl)connectorInfo;
         // create a new Provisioner..
         ret = new LocalConnectorFacadeImpl(localInfo, impl);
     }
     else
     {
         ret = new RemoteConnectorFacadeImpl(impl);
     }
     return ret;
 }
コード例 #39
0
 /// <summary>
 /// List - list all locales (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/locale.md#list---list-all-locales"/>)
 /// </summary>
 public static LocaleListResponse List(APIConfiguration configuration = null)
 {
     return APIBase.GetResponse<LocaleListResponse>(configuration, "locales");
 }
コード例 #40
0
 /// <summary>
 /// List - list all project types (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project_type.md#list---list-all-project-types"/>)
 /// </summary>
 public static ProjectTypeListResponse List(APIConfiguration configuration = null)
 {
     return APIBase.GetResponse<ProjectTypeListResponse>(configuration, "project-types");
 }
コード例 #41
0
        /// <summary>
        /// Show - retrieve details of a project (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md#show---retrieve-details-of-a-project"/>)
        /// </summary>
        public static ProjectShowResponse Show(int projectId, APIConfiguration configuration = null)
        {
            string methodName = string.Format("projects/{0}", projectId.ToString());

            return APIBase.GetResponse<ProjectShowResponse>(configuration, methodName);
        }
コード例 #42
0
 /// <summary>
 /// Get a new instance of <see cref="ConnectorFacade" />.
 /// </summary>
 /// <param name="config">all the configuration that the framework, connector, and
 /// pooling needs.</param>
 /// <returns>
 /// <see cref="ConnectorFacade" /> to call API operations against.</returns>
 /// <exception cref="ClassNotFoundException"></exception>
 public abstract ConnectorFacade NewInstance(APIConfiguration config);
コード例 #43
0
        /// <summary>
        /// Show - retrieve details of a project group (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project_group.md#show---retrieve-details-of-a-project-group"/>)
        /// </summary>
        public static ProjectGroupShowResponse Show(int projectGroupId, APIConfiguration configuration = null)
        {
            string methodName = string.Format("project-groups/{0}", projectGroupId);

            return APIBase.GetResponse<ProjectGroupShowResponse>(configuration, methodName, null);
        }
コード例 #44
0
        /// <summary>
        /// List - list projects of a project group (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md#list---list-projects-of-a-project-group"/>)
        /// </summary>
        public static ProjectListResponse List(int projectGroupId, APIConfiguration configuration = null)
        {
            string methodName = string.Format("project-groups/{0}/projects", projectGroupId.ToString());

            return APIBase.GetResponse<ProjectListResponse>(configuration, methodName);
        }
コード例 #45
0
ファイル: Api.cs プロジェクト: Tirasa/ConnId
 /// <summary>
 /// {@inheritDoc}
 /// </summary>
 public override ConnectorFacade NewInstance(APIConfiguration config)
 {
     ConnectorFacade facade = base.NewInstance(config);
     lock (CACHE)
     {
         ConnectorFacade cachedFacade = CollectionUtil.GetValue(CACHE, facade.ConnectorFacadeKey, null);
         if (null == cachedFacade)
         {
             CACHE[facade.ConnectorFacadeKey] = facade;
         }
         else
         {
             Trace.TraceInformation("ConnectorFacade found in cache");
             facade = cachedFacade;
         }
     }
     return facade;
 }
コード例 #46
0
        /// <summary>
        /// Update - update project (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md#update---update-project"/>)
        /// </summary>
        public static ProjectUpdateResponse Update(int projectId, string name = "", string description = "", APIConfiguration configuration = null)
        {
            string methodName = string.Format("projects/{0}", projectId);

            Dictionary<string, object> args = new Dictionary<string, object>();

            if (!string.IsNullOrEmpty(name)) {
                args["name"] = name;
            }

            if (!string.IsNullOrEmpty(description)) {
                args["description"] = description;
            }

            IRestResponse resp = APIBase.GetResponse<IRestResponse>(configuration, methodName, args, RestSharp.Method.PUT);

            if (resp.StatusCode != System.Net.HttpStatusCode.OK) {
                throw new Exception("Failed to update Project", new Exception(string.Format("Status: {0}", (int)resp.StatusCode)));
            }

            ProjectUpdateResponse respData = new ProjectUpdateResponse() {
                Meta = new Metadata() { Status = (int)resp.StatusCode }
            };

            return respData;
        }
コード例 #47
0
        /// <summary>
        /// Rename - update name of a project group (<see cref="https://github.com/onesky/api-documentation-platform/blob/master/resources/project_group.md#rename---update-name-of-a-project-group"/>)
        /// </summary>
        public static ProjectGroupRenameResponse Rename(int projectGroupId, string name, APIConfiguration configuration = null)
        {
            Dictionary<string, object> args = new Dictionary<string, object>();

            args["name"] = name;

            string methodName = string.Format("project-groups/{0}/rename", projectGroupId);

            IRestResponse resp = APIBase.GetResponse<IRestResponse>(configuration, methodName, args, RestSharp.Method.PUT);

            if (resp.StatusCode != System.Net.HttpStatusCode.OK) {
                throw new Exception("Failed to rename Project Group", new Exception(string.Format("Status: {0}", (int)resp.StatusCode)));
            }

            ProjectGroupRenameResponse respData = new ProjectGroupRenameResponse() {
                Meta = new Metadata() { Status = (int)resp.StatusCode }
            };

            return respData;
        }