DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

e9a1824b7ff75146f1e2c8a6a5e5658ee83a7064 — Jonni Liljamo 1 year, 5 months ago f9461f0
feat(client): update user requests to use macros
2 files changed, 11 insertions(+), 19 deletions(-)

M client/src/api/user/login.rs
M client/src/api/user/register.rs
M client/src/api/user/login.rs => client/src/api/user/login.rs +5 -9
@@ 8,7 8,7 @@

use serde::{Deserialize, Serialize};

use crate::NetworkingOptions;
use crate::{NetworkingOptions, post_request};

use super::User;



@@ 41,14 41,10 @@ struct LoginPost {
}

pub fn login(no: &mut NetworkingOptions, email: &str, password: &str) -> LoginResponse {
    let res = no.req
        .post(&format!("{}/user/token", &no.api_address))
        .json(&LoginPost {
            email: email.to_string(),
            password: password.to_string(),
        })
        .send()
        .unwrap();
    let res = post_request!(no, "/user/token", &LoginPost {
        email: email.to_string(),
        password: password.to_string(),
    });

    let tmp: LoginResponseJson = res.json().unwrap();


M client/src/api/user/register.rs => client/src/api/user/register.rs +6 -10
@@ 8,7 8,7 @@

use serde::Serialize;

use crate::NetworkingOptions;
use crate::{NetworkingOptions, post_request};

use super::User;



@@ 27,15 27,11 @@ pub fn register(
    email: &str,
    password: &str,
) -> RegisterResponse {
    let res = no.req
        .post(&format!("{}/user", &no.api_address))
        .json(&RegisterPost {
            username: username.to_string(),
            email: email.to_string(),
            password: password.to_string(),
        })
        .send()
        .unwrap();
    let res = post_request!(no, "/user", &RegisterPost {
        username: username.to_string(),
        email: email.to_string(),
        password: password.to_string(),
    });

    Ok(res.json().unwrap())
}