diff --git a/src/download/helpers.rs b/src/download/helpers.rs index b70797b..a4e0c79 100644 --- a/src/download/helpers.rs +++ b/src/download/helpers.rs @@ -93,57 +93,6 @@ pub struct DQTimeSeriesResponse { instruments: Vec, } -/// Response from the DataQuery API for a catalogue request. -#[allow(dead_code)] -#[derive(Deserialize, Debug)] -pub struct DQCatalogueResponse { - pub items: u32, - pub catalogue_responses: Vec, - pub all_instruments: Vec, -} - -/// Methods for DQCatalogueResponse -impl DQCatalogueResponse { - /// Create a new DQCatalogueResponse from a list of DQCatalogueSingleResponse objects. - pub fn new(catalogue_responses: Vec) -> Self { - let all_instruments: Vec = catalogue_responses - .iter() - .flat_map(|response| { - response - .instruments - .iter() - .map(|instrument| instrument.instrument_name.clone()) - }) - .collect(); - - DQCatalogueResponse { - items: all_instruments.len() as u32, - catalogue_responses: catalogue_responses, - all_instruments: all_instruments, - } - } -} - -/// Response from the DataQuery API for a single catalogue request (one page). -#[allow(dead_code)] -#[derive(Deserialize, Debug)] -pub struct DQCatalogueSingleResponse { - pub links: Vec>>, - pub items: u32, - pub instruments: Vec, -} - -/// Representation of DQCatalogueSingleResponse.Instrument -#[allow(dead_code)] -#[derive(Deserialize, Debug)] -pub struct DQCatalogueInstrument { - #[serde(rename = "instrument-id")] - pub instrument_id: String, - #[serde(rename = "instrument-name")] - pub instrument_name: String, - pub item: u32, -} - /// Representation of DQResponse.Instrument #[derive(Deserialize, Debug)] struct Instrument { @@ -196,6 +145,56 @@ pub struct DQTimeSeries { expression: String, time_series: Vec<(String, Option)>, } +/// Response from the DataQuery API for a catalogue request. +#[allow(dead_code)] +#[derive(Deserialize, Debug)] +pub struct DQCatalogueResponse { + pub items: u32, + pub catalogue_responses: Vec, + pub all_instruments: Vec, +} + +/// Methods for DQCatalogueResponse +impl DQCatalogueResponse { + /// Create a new DQCatalogueResponse from a list of DQCatalogueSingleResponse objects. + pub fn new(catalogue_responses: Vec) -> Self { + let all_instruments: Vec = catalogue_responses + .iter() + .flat_map(|response| { + response + .instruments + .iter() + .map(|instrument| instrument.instrument_name.clone()) + }) + .collect(); + + DQCatalogueResponse { + items: all_instruments.len() as u32, + catalogue_responses: catalogue_responses, + all_instruments: all_instruments, + } + } +} + +/// Response from the DataQuery API for a single catalogue request (one page). +#[allow(dead_code)] +#[derive(Deserialize, Debug)] +pub struct DQCatalogueSingleResponse { + pub links: Vec>>, + pub items: u32, + pub instruments: Vec, +} + +/// Representation of DQCatalogueSingleResponse.Instrument +#[allow(dead_code)] +#[derive(Deserialize, Debug)] +pub struct DQCatalogueInstrument { + #[serde(rename = "instrument-id")] + pub instrument_id: String, + #[serde(rename = "instrument-name")] + pub instrument_name: String, + pub item: u32, +} /// Representation of a JPMaQS indicator (1 or more time series for a single JPMaQS ticker) #[derive(Debug)]