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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright (c) 2025 Craig Hamilton and Contributors.
* Licensed under either of
* - Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> OR
* - MIT license <http://opensource.org/licenses/MIT>
* at your option.
*/
//! # SmugMug
//!
//! This SmugMug library was created for working with the SmugMug APIv2 interface.
//!
//! For further details on the Rest API refer to the [SmugMug API Docs](https://api.smugmug.com/api/v2/doc/index.html)
//!
//! ## Features
//!
//! - Retrieve Basic user information (Read only).
//! - Retrieve Node information.
//! - Can create an Album off the node.
//! - List children of a Node.
//! - Retrieve Album information.
//! - Can set the upload key.
//! - Can list the images contained in an Album.
//! - Retrieve Image information.
//! - Download of archive image supported.
//! - Lower level interface for handling more direct communication.
//! - Exposes the SmugMug API Rate Limit information.
//!
//! *The SmugMug API uses OAuth1. This library handles the request signing.
//! Getting the Access Token/Secret is left up to the consumer of this library*
//!
//! *The [`v2::Client`] currently provides direct GET/PATCH/POST functionality to allow library usage
//! for features that may not be implemented yet in the higher level interfaces*
//!
//! ## Usage
//!
//! **You will need to acquire an API key/secret from SmugMug prior to using the API**
//!
//! ```rust
//! use smugmug::v2::{Album, Client, Creds, NodeTypeFilters, SortDirection, SortMethod, User, SmugMugError};
//! use futures::{pin_mut, StreamExt};
//!
//!async fn iterate_albums<Fut>(
//! api_key: &str,
//! api_secret: &str,
//! access_token: &str,
//! access_token_secret: &str,
//! album_op: impl Fn(Album) -> Fut,
//!) -> anyhow::Result<()>
//!where
//! Fut: Future<Output=anyhow::Result<bool>>,
//!{
//! // The API key/secret is obtained from your SmugMug account
//! // The API key is the only required field for accessing public accounts
//! // The Access Token/Secret is obtained via the OAuth1 authentication process
//! let client = Client::new(Creds::from_tokens(
//! api_key,
//! Some(api_secret),
//! Some(access_token),
//! Some(access_token_secret),
//! ));
//!
//! // Get information for the authenticated user
//! let user_info = User::authenticated_user_info(client.clone()).await?;
//!
//! // Get information on the root node for this user
//! let node_info = user_info.node().await?;
//!
//! // Retrieve the Albums under the root node
//! let node_children = node_info.children(
//! NodeTypeFilters::Album,
//! SortDirection::Descending,
//! SortMethod::Organizer,
//! )?;
//! // Iterate over the node children
//! pin_mut!(node_children);
//! while let Some(Ok(child_album_node)) = node_children.next().await {
//! // Retrieve album specific information about this child node
//! let album_info = child_album_node.album().await?;
//!
//! // Do operation on album and stop stream if returns false
//! if !album_op(album_info).await? {
//! break;
//! }
//! }
//! Ok(())
//!}
//! ```
//!