コード例 #1
0
        /// <inheritdoc />
        public async Task <HttpResponse <Referent> > GetReferentBySongId(TextFormat textFormat, string songId,
                                                                         string createdById = "", string perPage = "",
                                                                         string page        = "")
        {
            var uri = UriHelper.CreateUri <Referent>(textFormat.ToString().ToLower(), songId: songId,
                                                     createdById: createdById, perPage: perPage, page: page);

            return(await _apiConnection.Get <Referent>(textFormat, uri : uri));
        }
コード例 #2
0
        /// <summary>
        /// Compare two references in a repository
        /// </summary>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="base">The reference to use as the base commit</param>
        /// <param name="head">The reference to use as the head commit</param>
        /// <returns></returns>
        public Task <CompareResult> Compare(string owner, string name, string @base, string head)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(@base, "base");
            Ensure.ArgumentNotNullOrEmptyString(head, "head");

            return(_apiConnection.Get <CompareResult>(ApiUrls.RepoCompare(owner, name, @base, head)));
        }
コード例 #3
0
ファイル: ApiExtensions.cs プロジェクト: artfuldev/Tookan.NET
        /// <summary>
        /// Gets the API resource at the specified URI.
        /// </summary>
        /// <typeparam name="T">Type of the API resource to get.</typeparam>
        /// <param name="connection">The connection to use</param>
        /// <param name="uri">URI of the API resource to get</param>
        /// <returns>The API resource.</returns>
        /// <exception cref="ApiException">Thrown when an API error occurs.</exception>
        public static Task <T> Get <T>(this IApiConnection connection, Uri uri)
        {
            Ensure.ArgumentIsNotNull(connection, "connection");
            Ensure.ArgumentIsNotNull(uri, "uri");

            return(connection.Get <T>(uri, null));
        }
コード例 #4
0
        /// <inheritdoc />
        public async Task <HttpResponse <WebPage> > GetWebPage(TextFormat textFormat, string rawAnnotatableUrl = "",
                                                               string canonicalUrl = "", string ogUrl = "")
        {
            var uri = UriHelper.CreateUri <WebPage>(textFormat.ToString().ToLower(),
                                                    rawAnnotatableUrl: rawAnnotatableUrl, canonicalUrl: canonicalUrl, ogUrl: ogUrl);

            return(await _apiConnection.Get <WebPage>(textFormat, uri : uri, jsonArrayName : "web_page"));
        }
コード例 #5
0
        public async Task <IActionResult> Index()
        {
            var list = JsonConvert.DeserializeObject <List <TodoItem> >((string)await _api.Get());

            if (list == null)
            {
                return(View());
            }
            return(View(list));
        }
コード例 #6
0
        /// <summary>
        /// Gets specific collection of entities
        /// </summary>
        /// <param name="query">oData query</param>
        /// <returns>List of entity Objects</returns>
        public List <T> Get(string query)
        {
            // Get the response and convert it to a list of entities of the specific type
            var response = _conn.Get(query);

            response = ApiResponseCleaner.GetJsonArray(response);

            var rc       = new EntityConverter();
            var entities = rc.ConvertJsonArrayToObjectList <T>(response);

            // If the entity isn't managed already, register to managed entity collection
            foreach (var entity in entities)
            {
                AddEntityToManagedEntitiesCollection(entity);
            }

            // Convert list
            var returnList = entities.ConvertAll(x => x);

            return(returnList);
        }
コード例 #7
0
ファイル: HomeController.cs プロジェクト: BurakOZN/todoApp
        public async Task <IActionResult> Index()
        {
            if (IsAuth())
            {
                _apiConnection.AddHeader(new Dictionary <string, string>()
                {
                    { "Authorization", "bearer " + GetToken() }
                });
                var response = await _apiConnection.Get <BaseResponse <List <GetJobResponse> > >(baseUrl + "Job/GetAll");

                if (response.IsSuccess)
                {
                    if (response.Result.State == State.Success)
                    {
                        return(View(new BaseResponse <List <GetJobResponse> >()
                        {
                            Result = response.Result.Result
                        }));
                    }
                    else
                    {
                        return(View(new BaseResponse <List <GetJobResponse> >()
                        {
                            Message = response.Result.Message
                        }));
                    }
                }
                else
                {
                    return(View(new BaseResponse <List <GetJobResponse> >()
                    {
                        Message = response.ErrorMessage
                    }));
                }
            }
            else
            {
                return(View(new BaseResponse <List <GetJobResponse> >()));
            }
        }
コード例 #8
0
 /// <inheritdoc />
 public async Task <HttpResponse <Annotation> > GetAnnotation(string annotationId, TextFormat textFormat)
 {
     return(await _apiConnection.Get <Annotation>(textFormat, annotationId));
 }
コード例 #9
0
 /// <inheritdoc />
 public async Task <HttpResponse <Song> > GetSong(TextFormat textFormat, string songId)
 {
     return(await _apiConnection.Get <Song>(textFormat, songId));
 }
コード例 #10
0
        /// <inheritdoc />
        public async Task <HttpResponse <User> > GetAccountInfo(TextFormat textFormat)
        {
            var uri = new Uri("https://api.genius.com/account");

            return(await _apiConnection.Get <User>(textFormat, uri : uri));
        }
コード例 #11
0
 /// <inheritdoc />
 public async Task <HttpResponse <Artist> > GetArtist(TextFormat textFormat, string artistId)
 {
     return(await _apiConnection.Get <Artist>(textFormat, artistId));
 }
コード例 #12
0
        /// <inheritdoc />
        public async Task <HttpResponse <List <Hit> > > Search(TextFormat textFormat, string searchTerm)
        {
            var uri = new Uri($"https://api.genius.com/search?q={searchTerm}");

            return(await _apiConnection.Get <List <Hit> >(textFormat, uri : uri, jsonArrayName : "hits"));
        }