closes #30
This commit is contained in:
@ -403,10 +403,26 @@ pub struct VMPatchRequest {
|
||||
|
||||
#[derive(Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AccountPatchRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub email: Option<String>,
|
||||
pub contact_nip17: bool,
|
||||
pub contact_email: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub country_code: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub address_1: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub address_2: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub state: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub city: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub postcode: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub tax_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, JsonSchema)]
|
||||
|
@ -133,6 +133,13 @@ async fn v1_patch_account(
|
||||
.as_ref()
|
||||
.and_then(|c| CountryCode::for_alpha3(c).ok())
|
||||
.map(|c| c.alpha3().to_string());
|
||||
user.billing_name = req.name.clone();
|
||||
user.billing_address_1 = req.address_1.clone();
|
||||
user.billing_address_2 = req.address_2.clone();
|
||||
user.billing_city = req.city.clone();
|
||||
user.billing_state = req.state.clone();
|
||||
user.billing_postcode = req.postcode.clone();
|
||||
user.billing_tax_id = req.tax_id.clone();
|
||||
|
||||
db.update_user(&user).await?;
|
||||
ApiData::ok(())
|
||||
@ -154,6 +161,13 @@ async fn v1_get_account(
|
||||
contact_nip17: user.contact_nip17,
|
||||
contact_email: user.contact_email,
|
||||
country_code: user.country_code,
|
||||
name: user.billing_name,
|
||||
address_1: user.billing_address_1,
|
||||
address_2: user.billing_address_2,
|
||||
state: user.billing_state,
|
||||
city: user.billing_city,
|
||||
postcode: user.billing_postcode,
|
||||
tax_id: user.billing_tax_id,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -275,10 +275,8 @@ impl LNVpsDb for MockDb {
|
||||
id: max + 1,
|
||||
pubkey: pubkey.to_vec(),
|
||||
created: Utc::now(),
|
||||
email: None,
|
||||
contact_nip17: false,
|
||||
contact_email: false,
|
||||
country_code: Some("USA".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
Ok(max + 1)
|
||||
|
@ -394,11 +394,8 @@ mod tests {
|
||||
User {
|
||||
id: 1,
|
||||
pubkey: vec![],
|
||||
created: Default::default(),
|
||||
email: None,
|
||||
contact_nip17: false,
|
||||
contact_email: false,
|
||||
country_code: Some("USA".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
u.insert(
|
||||
@ -406,11 +403,8 @@ mod tests {
|
||||
User {
|
||||
id: 2,
|
||||
pubkey: vec![],
|
||||
created: Default::default(),
|
||||
email: None,
|
||||
contact_nip17: false,
|
||||
contact_email: false,
|
||||
country_code: Some("IRL".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user