Documentation
¶
Index ¶
- Constants
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func JsonDecode(src []byte, obj interface{}) error
- func MarshalObject(obj interface{}, prefix string, indent string) ([]byte, error)
- type Assertion
- type AwardFilter
- type BoolParameter
- type ClinicalTrailNumber
- type ContentDomain
- type CrossRefClient
- func (c *CrossRefClient) QueryWorks(query WorksQuery) (*WorksQueryResponse, error)
- func (c *CrossRefClient) Types() (Object, error)
- func (c *CrossRefClient) TypesJSON() ([]byte, error)
- func (c *CrossRefClient) Works(doi string) (*Works, error)
- func (c *CrossRefClient) WorksJSON(doi string) ([]byte, error)
- type DateObject
- type DateParameter
- type DateRange
- type FullTextFilter
- type Funder
- type Group
- type Identifier
- type JournalIssue
- type License
- type LicenseFilter
- type Link
- type Message
- type Object
- type Organization
- type Pagination
- type Person
- type Property
- type QuerySortOptions
- type Reference
- type RelationFilter
- type Review
- type SortKey
- type SortOrder
- type Updated
- type Works
- type WorksFilter
- type WorksQuery
- type WorksQueryFields
- type WorksQueryMessage
- type WorksQueryResponse
- type WorksResponse
Constants ¶
const ( // Version number of release Version = "1.0.9" // ReleaseDate, the date version.go was generated ReleaseDate = "2025-01-16" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "dcaaa94" LicenseText = `` /* 1524-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func FmtHelp ¶ added in v1.0.3
func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string
FmtHelp lets you process a text block with simple curly brace markup.
func JsonDecode ¶ added in v1.0.6
Custom JSON decoder so we can treat numbers easier
Types ¶
type Assertion ¶ added in v1.0.1
type AwardFilter ¶ added in v1.0.8
type BoolParameter ¶ added in v1.0.8
type BoolParameter bool
BoolParameter overrides boolean text marshalling to comply with CrossRef API spec
func (BoolParameter) MarshalText ¶ added in v1.0.8
func (b BoolParameter) MarshalText() ([]byte, error)
type ClinicalTrailNumber ¶ added in v1.0.1
type ClinicalTrailNumber struct { ClinicalTrailNumber string `json:"clinical-trail-number,omitempty"` Registry string `json:"registry,omitempty"` Type string `json:"type,omitempty"` }
func (*ClinicalTrailNumber) IsSame ¶ added in v1.0.1
func (ctn *ClinicalTrailNumber) IsSame(t *ClinicalTrailNumber) bool
type ContentDomain ¶ added in v1.0.1
type ContentDomain struct { Domain []string `json:"domain,omitempty"` CrossmarkRestriction bool `json:"crossmark-restriction,omitempty"` }
func (*ContentDomain) IsSame ¶ added in v1.0.1
func (c *ContentDomain) IsSame(t *ContentDomain) bool
type CrossRefClient ¶
type CrossRefClient struct { AppName string MailTo string `json:"mailto"` API string `json:"api"` RateLimitLimit int `json:"limit"` RateLimitInterval int `json:"interval"` LimitCount int `json:"limit_count"` Status string StatusCode int LastRequest time.Time `json:"last_request"` }
func NewCrossRefClient ¶
func NewCrossRefClient(appName string, mailTo string) (*CrossRefClient, error)
NewCrossRefClient creates a client and makes a request and returns the JSON source as a []byte or error if their is a problem.
func (*CrossRefClient) QueryWorks ¶ added in v1.0.8
func (c *CrossRefClient) QueryWorks(query WorksQuery) (*WorksQueryResponse, error)
func (*CrossRefClient) Types ¶
func (c *CrossRefClient) Types() (Object, error)
Types returns the list of supported types as a Object
func (*CrossRefClient) TypesJSON ¶
func (c *CrossRefClient) TypesJSON() ([]byte, error)
TypesJSON return a list of types in JSON source
type DateObject ¶ added in v1.0.1
type DateObject struct { // DateParts holds a date an an array of Year, Month and Day integer values DateParts [][]int `json:"date-parts,omitempty"` // DateTime holds a date/time stamp, e.g. 2023-03-28T18:43:06.364Z DateTime string `json:"date-time,omitempty"` // Olds an integer representation of a timestamp, Unix epoch? Timestamp int64 `json:"timestamp,omitempty"` }
DateObject is a date/timestamp/action timestamp of when something happened. It is used repeated in the message object
func (*DateObject) IsSame ¶ added in v1.0.1
func (do *DateObject) IsSame(t *DateObject) bool
IsSame checks if the date objects represent the same date. NOTE: if both objects are nil, they are considered the same.
type DateParameter ¶ added in v1.0.8
func (DateParameter) MarshalText ¶ added in v1.0.8
func (d DateParameter) MarshalText() ([]byte, error)
func (DateParameter) String ¶ added in v1.0.8
func (d DateParameter) String() string
type DateRange ¶ added in v1.0.1
type DateRange struct { StartDate *DateObject `json:"start-date,omitempty"` EndDate *DateObject `json:"end-date,omitempty"` }
type FullTextFilter ¶ added in v1.0.8
type Funder ¶ added in v1.0.1
type Identifier ¶ added in v1.0.1
type Identifier struct { Label string `json:"label,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` IdType string `json:"id-type,omitempty"` Id string `json:"id,omitempty"` AssertedBy string `json:"asserted-by,omitempty"` }
func (*Identifier) IsSame ¶ added in v1.0.1
func (i *Identifier) IsSame(t *Identifier) bool
IsSame checks if two works object are the same. NOTE: if both objects are nil, they are considered the same.
type JournalIssue ¶ added in v1.0.1
type JournalIssue struct {
Issue string `json:"issue,omitempty"`
}
func (*JournalIssue) IsSame ¶ added in v1.0.1
func (i *JournalIssue) IsSame(t *JournalIssue) bool
type License ¶ added in v1.0.1
type License struct { URL string `json:"URL,omitempty"` Start *DateObject `json:"start,omitempty"` DelayInDays int `json:"delay-in-days,omitempty"` ContentVersion string `json:"content-version,omitempty"` }
type LicenseFilter ¶ added in v1.0.8
type LicenseFilter struct { URL []string `key:"url,omitempty"` Version []string `key:"version,omitempty"` Delay []int `key:"delay,omitempty"` }
License represents license-specific filter parameters
type Link ¶ added in v1.0.1
type Message ¶ added in v1.0.1
type Message struct { // Institutional information Institution []*Organization `json:"institution,omitempty"` // Indexed described when the work was last indexed Indexed *DateObject `json:"indexed,omitempty"` // Posted is when the work was posted to the API?? Posted *DateObject `json:"posted,omitempty"` // PublisherLocation, where they are located as a string PublisherLocation string `json:"publisher-location,omitempty"` // UpdateTo ???? UpdateTo []*Updated `json:"updated-to,omitempty"` // StandardsBody, ??? StandardsBody []*Organization `json:"standards-body,omitempty"` EditionNumber string `json:"edition-number,omitempty"` GroupTitle string `json:"group-title,omitempty"` Publisher string `json:"publisher,omitempty"` Issue string `json:"issue,omitempty"` IsbnType []*Identifier `json:"isbn-type,omitempty"` License []*License `json:"license,omitempty"` Funder []*Funder `json:"funder,omitempty"` ContentDomain *ContentDomain `json:"content-domain,omitempty"` Chair []*Person `json:"chair,omitempty"` ShortContainerTitle []string `json:"short-container-title,omitempty"` Accepted *DateObject `json:"accepted,omitempty"` ContentUpdated *DateObject `json:"content-updated,omitempty"` PublishedPrint *DateObject `json:"published-print,omitempty"` Abstract string `json:"abstract,omitempty"` DOI string `json:"doi,omitempty"` Type string `json:"type,omitempty"` Created *DateObject `json:"created,omitempty"` Approved *DateObject `json:"approved,omitempty"` Page string `json:"page,omitempty"` UpdatePolicy string `json:"update-policy,omitempty"` Source string `json:"source,omitempty"` Title []string `json:"title,omitempty"` Prefix string `json:"prefix,omitempty"` Volume string `json:"volume,omitempty"` ClinicalTrailNumber *ClinicalTrailNumber `json:"clinical-trail-number,omitempty"` Author []*Person `json:"author,omitempty"` Member string `json:"member,omitempty"` ContentCreated *DateObject `json:"content-created,omitempty"` PublishedOnline *DateObject `json:"published-online,omitempty"` Reference []*Reference `json:"reference,omitempty"` ContainerTitle []string `json:"container-title,omitempty"` Review *Review `json:"review,omitempty"` OriginalTitle []string `json:"original-title,omitempty"` Language string `json:"language,omitempty"` Link []*Link `json:"link,omitempty"` Deposited *DateObject `json:"deposited,omitempty"` Score float32 `json:"score,omitempty"` Degree string `json:"degree,omitempty"` SubTitle []string `json:"subtitle,omitempty"` Translator []*Person `json:"translator,omitempty"` FreeToRead *DateRange `json:"free-to-read,omitempty"` Editor []*Person `json:"editor,omitempty"` ComponentNumber string `json:"component-number,omitempty"` ShortTitle []string `json:"short-title,omitempty"` Issued *DateObject `json:"issued,omitempty"` ISBN []string `json:"isbn,omitempty"` ReferenceCount int `json:"reference-count,omitempty"` PartNumber string `json:"part-number,omitempty"` JournalIssue *JournalIssue `json:"journal-issue,omitempty"` ArticleNumber string `json:"article-number,omitempty"` AlternativeId []string `json:"alternative-id,omitempty"` URL string `json:"URL,omitempty"` Archive []string `json:"archive,omitempty"` Relation map[string][]*Property `json:"relation,omitempty"` ISSN []string `json:"issn,omitempty"` IssnType []*Identifier `json:"issn-type,omitempty"` Subject []string `json:"subject,omitempty"` PublishedOther *DateObject `json:"published-other,omitempty"` Published *DateObject `json:"published,omitempty"` Assertion []*Assertion `json:"assertion,omitempty"` }
func (*Message) Changes ¶ added in v1.0.1
Changes takes the current Message, a new version of the Message and returns a Message object with the new Message object containing only the new elements.
func (*Message) Diff ¶ added in v1.0.1
Diff takes the current Message, a new version of the Message and two Message objects one holding the old values and another holding the new values.
func (*Message) DiffAsJSON ¶ added in v1.0.1
DiffAsJSON performs a Diff and returns the results as a JSON array where the first element (index 0) is the old object's values and the second (index 1) is the updated values
type Object ¶
type Object = map[string]interface{}
Object is the general holder of what get back after unmarshaling json
type Organization ¶ added in v1.0.1
type Organization struct { IDs []*Identifier `json:"id,omitempty"` Name string `json:"name,omitempty"` Place []string `json:"place,omitempty"` Department []string `json:"department,omitempty"` Acronym []string `json:"acronym,omitempty"` }
func (*Organization) IsSame ¶ added in v1.0.1
func (org *Organization) IsSame(t *Organization) bool
IsSame checks if two works object are the same. NOTE: if both objects are nil, they are considered the same.
type Pagination ¶ added in v1.0.8
type Pagination struct { //The number of items returned in a single response (default is 20, and maximum is 1,000). Rows int64 `url:"rows,omitempty"` // offset parameter can be used to retrieve items starting from a specific index of the result list Offset int64 `url:"offset,omitempty"` // see "Deep-paging" section of CrossRef works API doc Cursor string `url:"cursor,omitempty"` }
type Person ¶ added in v1.0.1
type Person struct { ORCID string `json:"ORCID,omitempty"` Suffix string `json:"suffix,omitempty"` Given string `json:"given,omitempty"` Family string `json:"family,omitempty"` Affiliation []*Organization `json:"affiliation,omitempty"` Name string `json:"name,omitempty"` AuthenticatedOrcid bool `json:"authenticated-orcid,omitempty"` Prefix string `json:"prefix,omitempty"` Sequence string `json:"sequence,omitempty"` }
type Property ¶ added in v1.0.1
type QuerySortOptions ¶ added in v1.0.8
type Reference ¶ added in v1.0.1
type Reference struct { ISSN string `json:"issn,omitempty"` StandardsBody string `json:"standards-body,omitempty"` Issue string `json:"issue,omitempty"` Key string `json:"key,omitempty"` SeriesTitle string `json:"series-title,omitempty"` IsbnType string `json:"isbn-type,omitempty"` DoiAssertedBy string `json:"doi-asserted-by,omitempty"` FirstPage string `json:"first-page,omitempty"` ISBN string `json:"isbn,omitempty"` DOI string `json:"doi,omitempty"` Component string `json:"component,omitempty"` ArticleTitle string `json:"article-title,omitempty"` VolumeTitle string `json:"volume-title,omitempty"` Volume string `json:"volume,omitempty"` Author string `json:"author,omitempty"` StandardDesignator string `json:"standard-designator,omitempty"` Year string `json:"year,omitempty"` Unstructured string `json:"unstructured,omitempty"` Edition string `json:"edition,omitempty"` JournalTitle string `json:"journal-title,omitempty"` IssnType string `json:"issn-type,omitempty"` }
type RelationFilter ¶ added in v1.0.8
type RelationFilter struct { Type []string `key:"type,omitempty"` ObjectType []string `key:"object-type,omitempty"` Object []string `key:"object,omitempty"` }
Relation represents relation-specific filter parameters
type Review ¶ added in v1.0.1
type Review struct { Type string `json:"type,omitempty"` RunningNumber string `json:"running-number,omitempty"` RevisionRound string `json:"revision-round,omitempty"` Stage string `json:"stage,omitempty"` CompetingInterestStatement string `json:"competing-interest-statement,omitempty"` Recommendation string `json:"recommendation,omitempty"` Language string `json:"language,omitempty"` }
type SortKey ¶ added in v1.0.8
type SortKey string
const ( Created SortKey = "created" Deposited SortKey = "deposited" Indexed SortKey = "indexed" IsReferencedByCount SortKey = "is-referenced-by-count" Issued SortKey = "issued" Published SortKey = "published" PublishedOnline SortKey = "published-online" PublishedPrint SortKey = "published-print" ReferencesCount SortKey = "references-count" Relevance SortKey = "relevance" Score SortKey = "score" LastUpdate SortKey = "updated" // renamed from `Updated` to avoid name collision )
type Updated ¶ added in v1.0.1
type Updated struct { Label string `json:"label,omitempty"` DOI string `json:"doi,omitempty"` Type string `json:"type,omitempty"` Updated *DateObject `json:"updated,omitempty"` }
type Works ¶ added in v1.0.1
type Works WorksResponse[Message]
Works is a representation retrieved the CrossRef REST API using the Works path and a DOI. This is based on documentaiton at https://api.crossref.org/swagger-ui/index.html#/Works/get_works__doi_ Captured on 2023-03-28, RSD
NOTE: structure in documentation appears wrong, my test records indicate that some things listed as array of string are really just strings and visa versa.
func (*Works) DiffAsJSON ¶ added in v1.0.1
DiffAsJSON performs a Diff and returns the results as a JSON array where the first element (index 0) is the old object's values and the second (index 1) is the updated values
type WorksFilter ¶ added in v1.0.8
type WorksFilter struct { AlternativeID []string `key:"alternative-id,omitempty"` Archive []string `key:"archive,omitempty"` ArticleNumber []string `key:"article-number,omitempty"` Assertion []string `key:"assertion,omitempty"` AssertionGroup []string `key:"assertion-group,omitempty"` // Award related fields Award *AwardFilter `key:"award,omitempty"` CategoryName []string `key:"category-name,omitempty"` CitationID []string `key:"citation-id,omitempty"` ClinicalTrialNumber []string `key:"clinical-trial-number,omitempty"` ContainerTitle []string `key:"container-title,omitempty"` ContentDomain []string `key:"content-domain,omitempty"` DOI []string `key:"doi,omitempty"` // From date fields FromAcceptedDate []DateParameter `key:"from-accepted-date,omitempty"` FromApprovedDate []DateParameter `key:"from-approved-date,omitempty"` FromAwardedDate []DateParameter `key:"from-awarded-date,omitempty"` FromCreatedDate []DateParameter `key:"from-created-date,omitempty"` FromDepositDate []DateParameter `key:"from-deposit-date,omitempty"` FromEventEndDate []DateParameter `key:"from-event-end-date,omitempty"` FromEventStartDate []DateParameter `key:"from-event-start-date,omitempty"` FromIndexDate []DateParameter `key:"from-index-date,omitempty"` FromIssuedDate []DateParameter `key:"from-issued-date,omitempty"` FromOnlinePubDate []DateParameter `key:"from-online-pub-date,omitempty"` FromPostedDate []DateParameter `key:"from-posted-date,omitempty"` FromPrintPubDate []DateParameter `key:"from-print-pub-date,omitempty"` FromPubDate []DateParameter `key:"from-pub-date,omitempty"` FromUpdateDate []DateParameter `key:"from-update-date,omitempty"` // Full text related fields FullText *FullTextFilter `key:"full-text,omitempty"` // Other fields Funder []string `key:"funder,omitempty"` FunderDoiAssertedBy []string `key:"funder-doi-asserted-by,omitempty"` GroupTitle []string `key:"group-title,omitempty"` // Boolean flags // No point supporting multiple filter values as array here HasAbstract *BoolParameter `key:"has-abstract"` HasAffiliation *BoolParameter `key:"has-affiliation"` HasArchive *BoolParameter `key:"has-archive"` HasAssertion *BoolParameter `key:"has-assertion"` HasAuthenticatedOrcid *BoolParameter `key:"has-authenticated-orcid"` HasAward *BoolParameter `key:"has-award"` HasClinicalTrialNumber *BoolParameter `key:"has-clinical-trial-number"` HasContentDomain *BoolParameter `key:"has-content-domain"` HasDescription *BoolParameter `key:"has-description"` HasDomainRestriction *BoolParameter `key:"has-domain-restriction"` HasEvent *BoolParameter `key:"has-event"` HasFullText *BoolParameter `key:"has-full-text"` HasFunder *BoolParameter `key:"has-funder"` HasFunderDoi *BoolParameter `key:"has-funder-doi"` HasLicense *BoolParameter `key:"has-license"` HasOrcid *BoolParameter `key:"has-orcid"` HasReferences *BoolParameter `key:"has-references"` HasRelation *BoolParameter `key:"has-relation"` HasRorID *BoolParameter `key:"has-ror-id"` HasUpdate *BoolParameter `key:"has-update"` HasUpdatePolicy *BoolParameter `key:"has-update-policy"` IsUpdate *BoolParameter `key:"is-update"` // ISBN/ISSN ISBN []string `key:"isbn,omitempty"` ISSN []string `key:"issn,omitempty"` // License fields License *LicenseFilter `key:"license,omitempty"` // Award amount GteAwardAmount int `key:"gte-award-amount,omitempty"` LteAwardAmount int `key:"lte-award-amount,omitempty"` // Member and identifiers Member []string `key:"member,omitempty"` ORCID []string `key:"orcid,omitempty"` Prefix []string `key:"prefix,omitempty"` // Relation fields Relation *RelationFilter `key:"relation,omitempty"` // Type fields RorID []string `key:"ror-id,omitempty"` Type []string `key:"type,omitempty"` TypeName []string `key:"type-name,omitempty"` // Until date fields UntilAcceptedDate []DateParameter `key:"until-accepted-date,omitempty"` UntilApprovedDate []DateParameter `key:"until-approved-date,omitempty"` UntilAwardedDate []DateParameter `key:"until-awarded-date,omitempty"` UntilCreatedDate []DateParameter `key:"until-created-date,omitempty"` UntilDepositDate []DateParameter `key:"until-deposit-date,omitempty"` UntilEventEndDate []DateParameter `key:"until-event-end-date,omitempty"` UntilEventStartDate []DateParameter `key:"until-event-start-date,omitempty"` UntilIndexDate []DateParameter `key:"until-index-date,omitempty"` UntilIssuedDate []DateParameter `key:"until-issued-date,omitempty"` UntilOnlinePubDate []DateParameter `key:"until-online-pub-date,omitempty"` UntilPostedDate []DateParameter `key:"until-posted-date,omitempty"` UntilPrintPubDate []DateParameter `key:"until-print-pub-date,omitempty"` UntilPubDate []DateParameter `key:"until-pub-date,omitempty"` UntilUpdateDate []DateParameter `key:"until-update-date,omitempty"` // Update fields UpdateType []string `key:"update-type,omitempty"` Updates []string `key:"updates,omitempty"` }
WorksFilter represents the available filter parameters for the /works endpoint
func (WorksFilter) Encode ¶ added in v1.0.8
func (f WorksFilter) Encode() string
type WorksQuery ¶ added in v1.0.8
type WorksQuery struct { // General query string // Note: as stated in CrossRef API docs, // Fields.Bibliographic SHOULD be preferred // whenever the search query is a partial or full reference // (e.g. including authors, date, title, ...) FreeFormQuery string // Structured query on specific metadata Fields *WorksQueryFields // Results pagination Pagination *Pagination // Results filtering // Filters on different keys are applied with AND semantic. // Filters on the same key are applied with OR semantic. Filters *WorksFilter // Results projection. // Restrict the API results to a subset of fields. // See API docs for available fields Elements []string }
WorksQuery represents a query for works in the CrossRef API. See https://api.crossref.org/swagger-ui/index.html#/Works/get_works.
type WorksQueryFields ¶ added in v1.0.8
type WorksQueryFields struct { Affiliation string `url:"query.affiliation,omitempty"` Author string `url:"query.author,omitempty"` Bibliographic string `url:"query.bibliographic,omitempty"` Chair string `url:"query.chair,omitempty"` ContainerTitle string `url:"query.container-title,omitempty"` Contributor string `url:"query.contributor,omitempty"` Degree string `url:"query.degree,omitempty"` Description string `url:"query.description,omitempty"` Editor string `url:"query.editor,omitempty"` EventAcronym string `url:"query.event-acronym,omitempty"` EventLocation string `url:"query.event-location,omitempty"` EventName string `url:"query.event-name,omitempty"` EventTheme string `url:"query.event-theme,omitempty"` FunderName string `url:"query.funder-name,omitempty"` PublisherLocation string `url:"query.publisher-location,omitempty"` PublisherName string `url:"query.publisher-name,omitempty"` StandardsBodyAcronym string `url:"query.standards-body-acronym,omitempty"` StandardsBodyName string `url:"query.standards-body-name,omitempty"` Title string `url:"query.title,omitempty"` Translator string `url:"query.translator,omitempty"` }
WorksQueryFields represents the fields that can be queried in the CrossRef API
type WorksQueryMessage ¶ added in v1.0.8
type WorksQueryMessage struct { ItemsPerPage int64 `json:"items-per-page"` Query struct { StartIndex int64 `json:"start-index"` SearchTerms string `json:"search-terms"` } `json:"query"` TotalResults int64 `json:"total-results"` NextCursor string `json:"next-cursor,omitempty"` Items []Message `json:"items,omitempty"` }
type WorksQueryResponse ¶ added in v1.0.8
type WorksQueryResponse WorksResponse[WorksQueryMessage]
type WorksResponse ¶ added in v1.0.8
type WorksResponse[Message any] struct { Status string `json:"status,omitempty"` MessageType string `json:"message-type,omitempty"` MessageVersion string `json:"message-version,omitempty"` Message *Message `json:"message,omitempty"` }
WorksResponse is a generic type to represent responsed from the /works endpoint
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
crossrefapi
crossrefapi.go is a command line tool for access the CrossRef API given a specific DOI.
|
crossrefapi.go is a command line tool for access the CrossRef API given a specific DOI. |