コード例 #1
0
ファイル: Tasks.cs プロジェクト: patel-pragnesh/fr8core-dev
        public async Task <IEnumerable <AsanaTask> > GetAsync(AsanaTaskQuery query)
        {
            var baseUrl = _asanaParams.TasksUrl + "?";
            var url     = baseUrl;

            url = query.Workspace != null ? url + $"workspace={query.Workspace}&": url;
            url = query.Assignee != null  ? url + $"assignee={query.Assignee}&" : url + $"assignee=me&";
            url = query.Project != null ? baseUrl + $"project={query.Project}&" : url;
            url = query.Tag != null ? baseUrl + $"tag={query.Tag}" : url;
            url = query.CompletedSince != null  ? url + $"completed_since={query.CompletedSince}&" : url;
            url = query.ModifiedSince != null ? url + $"modified_since={query.ModifiedSince}&" : url;


            var uri = new Uri(url);

            try
            {
                var response = await _restClient.GetAsync <JObject>(uri);

                var result = response.GetValue("data").ToObject <IEnumerable <AsanaTask> >();
                return(result);
            }
            catch (Exception exp)
            {
                Logger.GetLogger().Error($"terminalAsana error = {exp.Message}");
                throw;
            }
        }
コード例 #2
0
ファイル: Users.cs プロジェクト: patel-pragnesh/fr8core-dev
        public async Task <AsanaUser> MeAsync()
        {
            var uri = new Uri(_asanaParams.UsersMeUrl);

            try
            {
                var response = await _restfulClient.GetAsync <JObject>(uri);

                var result = response.GetValue("data").ToObject <AsanaUser>();
                return(result);
            }
            catch (Exception exp)
            {
                Logger.GetLogger().Error($"terminalAsana error = {exp.Message}");
                throw;
            }
        }
コード例 #3
0
        public async Task <IEnumerable <AsanaWorkspace> > GetAsync()
        {
            var uri = new Uri(_asanaParams.WorkspacesUrl);

            try
            {
                var response = await _restClient.GetAsync <JObject>(uri).ConfigureAwait(false);

                var result = response.GetValue("data").ToObject <IEnumerable <AsanaWorkspace> >();
                return(result);
            }
            catch (Exception exp)
            {
                Logger.GetLogger().Error($"terminalAsana error = {exp.Message}");
                throw;
            }
        }
コード例 #4
0
        public async Task <IEnumerable <AsanaProject> > Get(AsanaProjectQuery query)
        {
            var uri = new Uri(_asanaParams.ProjectsUrl);

            try
            {
                var response = await _restClient.GetAsync <JObject>(uri);

                var result = response.GetValue("data").ToObject <IEnumerable <AsanaProject> >();
                return(result);
            }
            catch (Exception exp)
            {
                Logger.GetLogger().Error($"terminalAsana error = {exp.Message}");
                throw;
            }
        }
コード例 #5
0
        public async Task ShouldGetWithHeader()
        {
            Dictionary <string, string> actual = null;

            _restClientMock.Setup(x => x.GetAsync <JObject>(It.IsAny <Uri>(),
                                                            null,
                                                            It.IsAny <Dictionary <string, string> >()))
            .Callback <Uri, string, Dictionary <string, string> >((x, z, d) =>
            {
                actual = d;
            })
            .ReturnsAsync(JObject.Parse(Fixtures.FixtureData.SampleAsanaOauthTokenResponse()));

            this._communicator = new AsanaCommunicatorService(_asanaOAuth, _restClient);

            var result = _communicator.GetAsync <JObject>(new Uri("http://any"), null, null);

            Assert.IsNotNull(result);
            Assert.IsTrue(actual.ContainsKey("Authorization"));
        }