/// <summary> /// Validate the authorizatation token (Api Key) /// </summary> /// <param name="requestAuthToken"></param> /// <param name="clientIP"></param> /// <param name="requestUri"></param> /// <returns></returns> private static bool ValidAuthorization(string requestAuthToken) { Api2 api2 = new Api2(5); // 5 = "BHL API v3" bool authorized = api2.ValidateApiUser(requestAuthToken); return(authorized); }
public Models.Title GetTitle(int id) { Api2 apiProvider = new Api2(); BHLApiData.Title bhlTitle = apiProvider.GetTitleMetadata(id.ToString(), "f"); Models.Title title = null; if (bhlTitle != null) { title = new Models.Title(); title.TitleId = bhlTitle.TitleID; title.FullTitle = bhlTitle.FullTitle; title.PartNumber = bhlTitle.PartNumber; title.PartName = bhlTitle.PartName; title.CallNumber = bhlTitle.CallNumber; title.Edition = bhlTitle.Edition; title.PublisherPlace = bhlTitle.PublisherPlace; title.PublisherName = bhlTitle.PublisherName; title.PublicationDate = bhlTitle.PublicationDate; title.PublicationFrequency = bhlTitle.PublicationFrequency; title.BibliographicLevel = bhlTitle.BibliographicLevel; List <Models.Subject> subjects = null; foreach (BHLApiData.Subject keyword in bhlTitle.Subjects) { subjects = (subjects ?? new List <Models.Subject>()); Models.Subject subject = new Models.Subject(); subject.SubjectText = keyword.SubjectText; subjects.Add(subject); } title.Subjects = subjects; List <Models.Author> authors = null; foreach (BHLApiData.Creator bhlAuthor in bhlTitle.Authors) { authors = (authors ?? new List <Models.Author>()); Models.Author author = new Models.Author(); author.CreatorID = bhlAuthor.CreatorID; author.Type = bhlAuthor.Role; author.Name = bhlAuthor.Name; author.Dates = bhlAuthor.Dates; author.Numeration = bhlAuthor.Numeration; author.Unit = bhlAuthor.Unit; author.Title = bhlAuthor.Title; author.Location = bhlAuthor.Location; author.FullerForm = bhlAuthor.FullerForm; authors.Add(author); } title.Authors = authors; List <Models.Identifier> identifiers = null; foreach (BHLApiData.TitleIdentifier bhlIdentifier in bhlTitle.Identifiers) { identifiers = (identifiers ?? new List <Models.Identifier>()); Models.Identifier identifier = new Models.Identifier(); identifier.IdentifierName = bhlIdentifier.IdentifierName; identifier.IdentifierValue = bhlIdentifier.IdentifierValue; identifier.RelationshipType = "same as"; identifiers.Add(identifier); } title.Identifiers = identifiers; } return(title); }
public IdentityService(Api2 api) { _api = api; }