/// <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));
        }
        /// <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)));
        }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 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"));
        }
        public async Task <IActionResult> Index()
        {
            var list = JsonConvert.DeserializeObject <List <TodoItem> >((string)await _api.Get());

            if (list == null)
            {
                return(View());
            }
            return(View(list));
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
        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> >()));
            }
        }
 /// <inheritdoc />
 public async Task <HttpResponse <Annotation> > GetAnnotation(string annotationId, TextFormat textFormat)
 {
     return(await _apiConnection.Get <Annotation>(textFormat, annotationId));
 }
Exemplo n.º 9
0
 /// <inheritdoc />
 public async Task <HttpResponse <Song> > GetSong(TextFormat textFormat, string songId)
 {
     return(await _apiConnection.Get <Song>(textFormat, songId));
 }
Exemplo n.º 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));
        }
Exemplo n.º 11
0
 /// <inheritdoc />
 public async Task <HttpResponse <Artist> > GetArtist(TextFormat textFormat, string artistId)
 {
     return(await _apiConnection.Get <Artist>(textFormat, artistId));
 }
Exemplo n.º 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"));
        }