Skip to content

Commit

Permalink
Add options.json() for deepgram::manage::projects::options::Options
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdyer committed Jul 23, 2024
1 parent 08561a1 commit 5974294
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/manage/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Projects<'_> {
/// ```no_run
/// # use std::env;
/// #
/// # use deepgram::{manage::projects::options::Options, Deepgram, DeepgramError};
/// # use deepgram::{/*manage::projects::options::Options, */Deepgram, DeepgramError};
/// #
/// # #[tokio::main]
/// # async fn main() -> Result<(), DeepgramError> {
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Projects<'_> {
/// ```no_run
/// # use std::env;
/// #
/// # use deepgram::{manage::projects::options::Options, Deepgram, DeepgramError};
/// # use deepgram::{/*manage::projects::options::Options, */Deepgram, DeepgramError};
/// #
/// # #[tokio::main]
/// # async fn main() -> Result<(), DeepgramError> {
Expand Down
20 changes: 20 additions & 0 deletions src/manage/projects/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ impl Options {
pub fn builder() -> OptionsBuilder {
OptionsBuilder::new()
}

/// Return the Options in json format. If serialization would
/// fail, this will also return an error.
///
/// This is intended primarily to help with debugging API requests.
///
/// ```
/// use deepgram::manage::projects::options::Options;
/// let options = Options::builder()
/// .company("Deepgram")
/// .name("DG Project")
/// .build();
/// assert_eq!(
/// &options.json().unwrap(),
/// r#"{"name":"DG Project","company":"Deepgram"}"#)
/// ```
///
pub fn json(&self) -> Result<String, serde_json::Error> {
serde_json::to_string(&SerializableOptions::from(self))
}
}

impl OptionsBuilder {
Expand Down

0 comments on commit 5974294

Please sign in to comment.