@@ -12,15 +12,16 @@ use reqwest;
1212
1313use super :: { configuration, Error } ;
1414use crate :: apis:: ResponseContent ;
15- use crate :: models:: reports:: {
16- FetchReportQuery , OrgReport , OrgReportType , UserReportPage , UserReportType ,
15+ use crate :: models:: user_insights:: {
16+ ChartData , ChartMetric , FetchChartDataQuery , FetchReportQuery , OrgReport , OrgReportType ,
17+ UserReportPage , UserReportType ,
1718} ;
1819use crate :: propelauth:: auth:: AUTH_HOSTNAME_HEADER ;
1920
2021/// struct for typed errors of methods [`fetch_user_report`] or [`fetch_org_report`]
2122#[ derive( Debug , Clone , Serialize , Deserialize ) ]
2223#[ serde( untagged) ]
23- pub enum FetchReportRequestError {
24+ pub enum FetchUserInsightsDataRequestError {
2425 Status401 ( serde_json:: Value ) ,
2526 Status400 ( serde_json:: Value ) ,
2627 Status429 ( serde_json:: Value ) ,
@@ -31,7 +32,7 @@ pub(crate) async fn fetch_user_report(
3132 configuration : & configuration:: Configuration ,
3233 report_key : UserReportType ,
3334 params : FetchReportQuery ,
34- ) -> Result < UserReportPage , Error < FetchReportRequestError > > {
35+ ) -> Result < UserReportPage , Error < FetchUserInsightsDataRequestError > > {
3536 let local_var_configuration = configuration;
3637
3738 let local_var_client = & local_var_configuration. client ;
@@ -67,9 +68,9 @@ pub(crate) async fn fetch_user_report(
6768 if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
6869 serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
6970 } else {
70- let local_var_entity: Option < FetchReportRequestError > =
71+ let local_var_entity: Option < FetchUserInsightsDataRequestError > =
7172 serde_json:: from_str ( & local_var_content) . ok ( ) ;
72- let local_var_error: crate :: apis:: ResponseContent < FetchReportRequestError > =
73+ let local_var_error: crate :: apis:: ResponseContent < FetchUserInsightsDataRequestError > =
7374 ResponseContent {
7475 status : local_var_status,
7576 content : local_var_content,
@@ -83,7 +84,7 @@ pub(crate) async fn fetch_org_report(
8384 configuration : & configuration:: Configuration ,
8485 report_key : OrgReportType ,
8586 params : FetchReportQuery ,
86- ) -> Result < OrgReport , Error < FetchReportRequestError > > {
87+ ) -> Result < OrgReport , Error < FetchUserInsightsDataRequestError > > {
8788 let local_var_configuration = configuration;
8889
8990 let local_var_client = & local_var_configuration. client ;
@@ -119,9 +120,61 @@ pub(crate) async fn fetch_org_report(
119120 if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
120121 serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
121122 } else {
122- let local_var_entity: Option < FetchReportRequestError > =
123+ let local_var_entity: Option < FetchUserInsightsDataRequestError > =
123124 serde_json:: from_str ( & local_var_content) . ok ( ) ;
124- let local_var_error: crate :: apis:: ResponseContent < FetchReportRequestError > =
125+ let local_var_error: crate :: apis:: ResponseContent < FetchUserInsightsDataRequestError > =
126+ ResponseContent {
127+ status : local_var_status,
128+ content : local_var_content,
129+ entity : local_var_entity,
130+ } ;
131+ Err ( Error :: ResponseError ( local_var_error) )
132+ }
133+ }
134+
135+ pub ( crate ) async fn fetch_chart_metric_data (
136+ configuration : & configuration:: Configuration ,
137+ chart_metric : ChartMetric ,
138+ params : FetchChartDataQuery ,
139+ ) -> Result < ChartData , Error < FetchUserInsightsDataRequestError > > {
140+ let local_var_configuration = configuration;
141+
142+ let local_var_client = & local_var_configuration. client ;
143+
144+ let local_var_uri_str = format ! (
145+ "{}/api/backend/v1/chart_metrics/{chart_metric}" ,
146+ local_var_configuration. base_path,
147+ chart_metric = chart_metric. as_str( ) ,
148+ ) ;
149+ let mut local_var_req_builder =
150+ local_var_client. request ( reqwest:: Method :: GET , local_var_uri_str. as_str ( ) ) ;
151+
152+ local_var_req_builder = local_var_req_builder. query ( & params) ;
153+
154+ if let Some ( ref local_var_user_agent) = local_var_configuration. user_agent {
155+ local_var_req_builder =
156+ local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
157+ }
158+ if let Some ( ref local_var_token) = local_var_configuration. bearer_access_token {
159+ local_var_req_builder = local_var_req_builder. bearer_auth ( local_var_token. to_owned ( ) ) ;
160+ } ;
161+ local_var_req_builder = local_var_req_builder. header (
162+ AUTH_HOSTNAME_HEADER ,
163+ local_var_configuration. auth_hostname . to_owned ( ) ,
164+ ) ;
165+
166+ let local_var_req = local_var_req_builder. build ( ) ?;
167+ let local_var_resp = local_var_client. execute ( local_var_req) . await ?;
168+
169+ let local_var_status = local_var_resp. status ( ) ;
170+ let local_var_content = local_var_resp. text ( ) . await ?;
171+
172+ if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
173+ serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
174+ } else {
175+ let local_var_entity: Option < FetchUserInsightsDataRequestError > =
176+ serde_json:: from_str ( & local_var_content) . ok ( ) ;
177+ let local_var_error: crate :: apis:: ResponseContent < FetchUserInsightsDataRequestError > =
125178 ResponseContent {
126179 status : local_var_status,
127180 content : local_var_content,
0 commit comments