Add safebuf attribute to goal
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
pub mod types;
|
||||
use crate::types::{CreateDatapoint, Datapoint, Goal, UserInfo, UserInfoDiff};
|
||||
use crate::types::{CreateDatapoint, Datapoint, GoalSummary, UserInfo, UserInfoDiff};
|
||||
use reqwest::Client;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
@@ -157,7 +157,7 @@ impl BeeminderClient {
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an error if the HTTP request fails or response cannot be parsed.
|
||||
pub async fn get_goals(&self, username: &str) -> Result<Vec<Goal>, Error> {
|
||||
pub async fn get_goals(&self, username: &str) -> Result<Vec<GoalSummary>, Error> {
|
||||
self.request(&format!("users/{username}/goals.json"), None)
|
||||
.await
|
||||
}
|
||||
@@ -166,7 +166,7 @@ impl BeeminderClient {
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an error if the HTTP request fails or response cannot be parsed.
|
||||
pub async fn get_archived_goals(&self, username: &str) -> Result<Vec<Goal>, Error> {
|
||||
pub async fn get_archived_goals(&self, username: &str) -> Result<Vec<GoalSummary>, Error> {
|
||||
self.request(&format!("users/{username}/goals/archived.json"), None)
|
||||
.await
|
||||
}
|
||||
|
||||
43
src/types.rs
43
src/types.rs
@@ -52,6 +52,49 @@ pub struct Goal {
|
||||
pub datapublic: bool,
|
||||
/// Amount pledged in USD on the goal
|
||||
pub pledge: f64,
|
||||
/// Number of days until derailment (0 if in beemergency)
|
||||
pub safebuf: i32,
|
||||
/// Unix timestamp of the last (explicitly entered) datapoint
|
||||
#[serde(with = "time::serde::timestamp")]
|
||||
pub lastday: OffsetDateTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct GoalSummary {
|
||||
/// Final part of goal URL, used as identifier (e.g., "weight" in beeminder.com/alice/weight)
|
||||
pub slug: String,
|
||||
/// User-specified title for the goal
|
||||
pub title: String,
|
||||
/// Type of goal (hustler/biker/fatloser/gainer/inboxer/drinker/custom)
|
||||
pub goal_type: String,
|
||||
/// Summary of what needs to be done by when, e.g., "+2 within 1 day".
|
||||
pub limsum: String,
|
||||
/// URL for the goal's graph SVG
|
||||
pub svg_url: String,
|
||||
/// URL for the goal's graph image
|
||||
pub graph_url: String,
|
||||
/// URL for the goal's graph thumbnail image
|
||||
pub thumb_url: String,
|
||||
/// Unix timestamp of derailment if nothing is reported
|
||||
#[serde(with = "time::serde::timestamp")]
|
||||
pub losedate: OffsetDateTime,
|
||||
/// Unix timestamp of the goal date
|
||||
#[serde(with = "time::serde::timestamp::option")]
|
||||
pub goaldate: Option<OffsetDateTime>,
|
||||
/// Goal value - the number the bright red line will eventually reach
|
||||
pub goalval: Option<f64>,
|
||||
/// Slope of the (final section of the) bright red line
|
||||
pub rate: Option<f64>,
|
||||
/// Unix timestamp of the last time this goal was updated
|
||||
#[serde(with = "time::serde::timestamp")]
|
||||
pub updated_at: OffsetDateTime,
|
||||
/// Whether the graph is currently being updated
|
||||
pub queued: bool,
|
||||
/// Number of days until derailment (0 if in beemergency)
|
||||
pub safebuf: i32,
|
||||
/// Unix timestamp of the last (explicitly entered) datapoint
|
||||
#[serde(with = "time::serde::timestamp")]
|
||||
pub lastday: OffsetDateTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user