-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcept.rs
62 lines (56 loc) · 1.77 KB
/
concept.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use serde_derive::{Deserialize, Serialize};
use crate::{
api_entities::{
common_types::{CountByYear, DehydratedConcept, International, Meta, SummaryStats},
APIEntity,
},
impl_try_from_for_entity_response, impl_try_from_for_single_entity,
utils::deserialize_opt_string_from_uint_null_missing,
};
#[derive(Deserialize, Serialize, Debug)]
pub struct ConceptIds {
#[serde(
default,
deserialize_with = "deserialize_opt_string_from_uint_null_missing"
)]
pub mag: Option<String>,
pub openalex: String,
#[serde(default)]
pub umls_cui: Vec<String>,
#[serde(default)]
pub umls_aui: Vec<String>,
pub wikidata: String,
pub wikipedia: Option<String>,
}
/// Note from OpenAlex: https://docs.openalex.org/api-entities/concepts
#[derive(Deserialize, Serialize, Debug)]
pub struct Concept {
pub ancestors: Vec<DehydratedConcept>,
pub cited_by_count: u32,
pub counts_by_year: Vec<CountByYear>,
pub created_date: String,
pub description: Option<String>,
pub display_name: String,
pub id: String,
pub ids: ConceptIds,
pub image_thumbnail_url: Option<String>,
pub image_url: Option<String>,
pub international: International,
pub level: u32,
pub related_concepts: Vec<DehydratedConcept>,
pub summary_stats: SummaryStats,
pub updated_date: String,
pub wikidata: String,
pub works_api_url: String,
pub works_count: u32,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct ConceptResponse {
pub meta: Meta,
pub results: Vec<Concept>,
}
impl_try_from_for_single_entity!(Concept);
impl_try_from_for_entity_response!(ConceptResponse);
impl APIEntity<Concept, ConceptResponse> for Concept {
const API_URL: &'static str = "https://api.openalex.org/concepts";
}