github.com/uvalib/orcid-access-ws@v0.0.0-20250612130209-7d062dbabf9d/orcidaccessws/api/activity.go (about)

     1  package api
     2  
     3  import (
     4  	"sort"
     5  )
     6  
     7  // ActivityUpdate -- the activity update request
     8  type ActivityUpdate struct {
     9  	UpdateCode string     `json:"update_code,omitempty"`
    10  	Work       WorkSchema `json:"work,omitempty"`
    11  }
    12  
    13  // WorkSchema -- the work schema
    14  type WorkSchema struct {
    15  	Title           string   `json:"title,omitempty"`
    16  	Abstract        string   `json:"abstract,omitempty"`
    17  	PublicationDate string   `json:"publication_date,omitempty"`
    18  	URL             string   `json:"url,omitempty"`
    19  	Authors         []Person `json:"authors,omitempty"`
    20  	ResourceType    string   `json:"resource_type,omitempty"`
    21  }
    22  
    23  // Person -- the basic person details used for authors
    24  type Person struct {
    25  	Index     int    `json:"index"`
    26  	FirstName string `json:"first_name,omitempty"`
    27  	LastName  string `json:"last_name,omitempty"`
    28  }
    29  
    30  // SortPeople -- helpers to sort the people lists
    31  func SortPeople(people []Person) []Person {
    32  	sortedPeople := make([]Person, len(people))
    33  	copy(sortedPeople, people)
    34  	sort.Sort(PeopleSorter(sortedPeople))
    35  	return sortedPeople
    36  }
    37  
    38  // PeopleSorter sorts people by index
    39  type PeopleSorter []Person
    40  
    41  func (people PeopleSorter) Len() int           { return len(people) }
    42  func (people PeopleSorter) Swap(i, j int)      { people[i], people[j] = people[j], people[i] }
    43  func (people PeopleSorter) Less(i, j int) bool { return people[i].Index < people[j].Index }
    44  
    45  //
    46  // end of file
    47  //