Skip to content

Instantly share code, notes, and snippets.

image: redis:5.0.3
ports:
- "6379:6379"
container-juggler generate auth
@zupzup
zupzup / Cargo.toml
Created October 29, 2020 13:19
Timeular Public API Cargo.toml
[dependencies]
reqwest = { version = "0.10", features = ["json"] }
tokio = { version = "0.2", features = ["macros", "fs"] }
serde = {version = "1.0", features = ["derive"] }
serde_json = "1.0"
once_cell = "1.4"
@zupzup
zupzup / main.rs
Created October 29, 2020 13:22
Timeular Public API Deps and Constants
use once_cell::sync::Lazy;
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::env;
use tokio::fs;
type Error = Box<dyn std::error::Error>;
static CLIENT: Lazy<Client> = Lazy::new(|| Client::new());
@zupzup
zupzup / main.rs
Created October 29, 2020 13:28
Timeular Public API sign_in 1
#[tokio::main]
async fn main() -> Result<(), Error> {
let api_key = env::var("TMLR_API_KEY").expect("TMLR_API_KEY needs to be set");
let api_secret = env::var("TMLR_API_SECRET").expect("TMLR_API_SECRET needs to be set");
println!("signing in..");
let token = sign_in(api_key, api_secret).await?;
@zupzup
zupzup / main.rs
Created October 29, 2020 13:29
Timeular Public API sign_in 2
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
struct SignInRequest {
api_key: String,
api_secret: String,
}
#[derive(Deserialize, Debug)]
struct SignInResponse {
token: String,
@zupzup
zupzup / main.rs
Created October 29, 2020 13:30
Timeular Public API url
fn url(path: &str) -> String {
format!("{}{}", BASE_URL, path)
}
@zupzup
zupzup / main.rs
Created October 29, 2020 13:35
Timeular Public API me1
println!("fetching me and spaces...");
let me = fetch_me(&token).await?;
let spaces = fetch_spaces(&token).await?;
println!("fetched spaces: {:?} for {:?}", spaces, me);
@zupzup
zupzup / main.rs
Created October 29, 2020 13:35
Timeular Public API me2
#[derive(Deserialize, Debug)]
struct MeResponse {
data: Me,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Me {
user_id: String,
name: String,
@zupzup
zupzup / main.rs
Created October 29, 2020 13:35
Timeular Public API spaces1
#[derive(Deserialize, Debug)]
struct SpacesResponse {
data: Vec<Space>,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Space {
id: String,
name: String,