| 1 | mod channels; |
| 2 | mod chats; |
| 3 | mod folders; |
| 4 | mod state; |
| 5 | mod teams; |
| 6 | mod transport; |
| 7 | |
| 8 | use session::Session; |
| 9 | |
| 10 | pub use folders::{Folder, FolderKind, Folders}; |
| 11 | pub use state::{PinnedChannels, PinnedChats}; |
| 12 | pub use teams::{ChannelLayout, TeamLayout}; |
| 13 | pub use transport::{CSA_RESOURCE, CSA_SCOPE, CsaTransport, SessionTransport}; |
| 14 | |
| 15 | pub const DEFAULT_REGION: &str = "emea"; |
| 16 | |
| 17 | pub struct Pins<T: CsaTransport = SessionTransport> { |
| 18 | transport: T, |
| 19 | base_url: String, |
| 20 | } |
| 21 | |
| 22 | impl Pins<SessionTransport> { |
| 23 | pub fn new(session: &Session) -> Self { |
| 24 | Self::with_region(session, DEFAULT_REGION) |
| 25 | } |
| 26 | |
| 27 | pub fn with_region(session: &Session, region: &str) -> Self { |
| 28 | Pins::with_transport(SessionTransport::new(session), region) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | impl<T: CsaTransport> Pins<T> { |
| 33 | pub fn with_transport(transport: T, region: &str) -> Self { |
| 34 | Pins { |
| 35 | transport, |
| 36 | base_url: format!( |
| 37 | "https://teams.cloud.microsoft/api/csa/{region}/api/v1/teams/users/me" |
| 38 | ), |
| 39 | } |
| 40 | } |
| 41 | } |