fix error
This commit is contained in:
parent
32b9f74994
commit
f526eec695
|
@ -1,11 +1,4 @@
|
||||||
use paypal_rs::{
|
use paypal_rs::{common::*, errors::*, invoice::*, Client, HeaderParams, Prefer};
|
||||||
Client,
|
|
||||||
HeaderParams,
|
|
||||||
Prefer,
|
|
||||||
invoice::*,
|
|
||||||
common::*,
|
|
||||||
errors::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), ResponseError> {
|
async fn main() -> Result<(), ResponseError> {
|
||||||
|
@ -41,35 +34,33 @@ async fn main() -> Result<(), ResponseError> {
|
||||||
email_address: Some("merchant@example.com".to_owned()),
|
email_address: Some("merchant@example.com".to_owned()),
|
||||||
additional_notes: None,
|
additional_notes: None,
|
||||||
}),
|
}),
|
||||||
items: vec![
|
items: vec![Item {
|
||||||
Item {
|
id: None,
|
||||||
id: None,
|
name: "My item".to_owned(),
|
||||||
name: "My item".to_owned(),
|
unit_amount: Money {
|
||||||
unit_amount: Money {
|
currency_code: Currency::EUR,
|
||||||
currency_code: Currency::EUR,
|
value: "10.0".to_owned(),
|
||||||
value: "10.0".to_owned()
|
},
|
||||||
},
|
quantity: "1".to_owned(),
|
||||||
quantity: "1".to_owned(),
|
discount: None,
|
||||||
discount: None,
|
item_date: None,
|
||||||
item_date: None,
|
description: Some("A random item".to_owned()),
|
||||||
description: Some("A random item".to_owned()),
|
tax: Some(Tax {
|
||||||
tax: Some(Tax {
|
name: "Sales tax".to_owned(),
|
||||||
name: "Sales tax".to_owned(),
|
percent: "7".to_owned(),
|
||||||
percent: "7".to_owned(),
|
amount: None,
|
||||||
amount: None,
|
}),
|
||||||
}),
|
unit_of_measure: Some(UnitOfMeasure::Quantity),
|
||||||
unit_of_measure: Some(UnitOfMeasure::Quantity),
|
}],
|
||||||
}
|
|
||||||
],
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
match client.create_draft_invoice(payload, HeaderParams::default()).await {
|
match client.create_draft_invoice(payload, HeaderParams::default()).await {
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
println!("{:#?}", r);
|
println!("{:#?}", r);
|
||||||
},
|
}
|
||||||
Err(ResponseError::HttpError(e)) => {
|
Err(ResponseError::HttpError(e)) => {
|
||||||
println!("{}", e);
|
println!("{}", e);
|
||||||
},
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{:#?}", e);
|
println!("{:#?}", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,9 +690,9 @@ impl super::Client {
|
||||||
let res = build.json(&invoice).send().await?;
|
let res = build.json(&invoice).send().await?;
|
||||||
|
|
||||||
if res.status().is_success() {
|
if res.status().is_success() {
|
||||||
println!("{:#?}", res.text().await?);
|
//println!("{:#?}", res.text().await?);
|
||||||
//let x = res.json::<Invoice>().await?;
|
let inv = res.json::<Invoice>().await?;
|
||||||
Ok(())
|
Ok(inv)
|
||||||
} else {
|
} else {
|
||||||
Err(res.json::<PaypalError>().await?.into())
|
Err(res.json::<PaypalError>().await?.into())
|
||||||
}
|
}
|
||||||
|
@ -913,4 +913,3 @@ mod tests {
|
||||||
println!("{:?}", list);
|
println!("{:?}", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue