diff --git a/examples/invoice.rs b/examples/invoice.rs index 159eea1..47b1c73 100644 --- a/examples/invoice.rs +++ b/examples/invoice.rs @@ -1,4 +1,4 @@ -/* +/* use paypal_rs::{common::*, errors::*, invoice::*, Client, HeaderParams}; #[tokio::main] @@ -73,4 +73,4 @@ async fn main() -> Result<(), ResponseError> { } */ -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/api/invoice.rs b/src/api/invoice.rs index 611a5a6..f15db9c 100644 --- a/src/api/invoice.rs +++ b/src/api/invoice.rs @@ -13,7 +13,7 @@ use serde::Serialize; use crate::{ data::{ - invoice::{Invoice, InvoiceList, InvoicePayload, CancelReason}, + invoice::{CancelReason, Invoice, InvoiceList, InvoicePayload}, orders::InvoiceNumber, }, endpoint::Endpoint, @@ -158,10 +158,10 @@ impl Endpoint for ListInvoices { } } -/// Deletes a draft or scheduled invoice, by ID. Deletes invoices in the draft or scheduled state only. -/// -/// For invoices that have already been sent, you can cancel the invoice. -/// +/// Deletes a draft or scheduled invoice, by ID. Deletes invoices in the draft or scheduled state only. +/// +/// For invoices that have already been sent, you can cancel the invoice. +/// /// After you delete a draft or scheduled invoice, you can no longer use it or show its details. However, you can reuse its invoice number. #[derive(Debug, Clone)] pub struct DeleteInvoice { @@ -202,7 +202,7 @@ pub struct UpdateInvoiceQuery { } /// Update an invoice. -/// +/// /// Fully updates an invoice, by ID. In the JSON request body, include a complete invoice object. This call does not support partial updates. #[derive(Debug, Clone)] pub struct UpdateInvoice { @@ -215,10 +215,7 @@ pub struct UpdateInvoice { impl UpdateInvoice { /// New constructor. pub fn new(invoice: Invoice, query: UpdateInvoiceQuery) -> Self { - Self { - invoice, - query - } + Self { invoice, query } } } @@ -252,16 +249,13 @@ pub struct CancelInvoice { /// The invoice id. pub invoice_id: String, /// The reason of the cancelation. - pub reason: CancelReason + pub reason: CancelReason, } impl CancelInvoice { /// New constructor. pub fn new(invoice_id: String, reason: CancelReason) -> Self { - Self { - invoice_id, - reason - } + Self { invoice_id, reason } } } diff --git a/src/api/mod.rs b/src/api/mod.rs index 778d0a3..28c803f 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,4 +1,4 @@ //! This module contains the api endpoints. +pub mod invoice; pub mod orders; -pub mod invoice; \ No newline at end of file diff --git a/src/api/orders.rs b/src/api/orders.rs index ece2ee6..1eb80cb 100644 --- a/src/api/orders.rs +++ b/src/api/orders.rs @@ -1,15 +1,14 @@ //! An order represents a payment between two or more parties. Use the Orders API to create, update, retrieve, authorize, and capture orders. -//! +//! //! https://developer.paypal.com/docs/api/orders/v2/ use std::borrow::Cow; use derive_builder::Builder; use serde::Serialize; -use serde_json::json; use crate::{ - data::orders::{Order, OrderPayload, PaymentSourceResponse}, + data::orders::{Order, OrderPayload}, endpoint::Endpoint, }; @@ -87,7 +86,7 @@ pub struct PaymentSourceToken { /// The PayPal-generated ID for the token. pub id: String, /// The tokenization method that generated the ID. - /// + /// /// Can only be BILLING_AGREEMENT. pub r#type: String, } @@ -106,15 +105,15 @@ pub struct PaymentSourceBody { pub payment_source: PaymentSource, } -/// Captures payment for an order. To successfully capture payment for an order, -/// the buyer must first approve the order or a valid payment_source must be provided in the request. +/// Captures payment for an order. To successfully capture payment for an order, +/// the buyer must first approve the order or a valid payment_source must be provided in the request. /// A buyer can approve the order upon being redirected to the rel:approve URL that was returned in the HATEOAS links in the create order response. #[derive(Debug, Clone, Builder)] pub struct CaptureOrder { /// The id of the order. pub order_id: String, /// The endpoint body. - pub body: Option + pub body: Option, } impl CaptureOrder { @@ -147,15 +146,15 @@ impl Endpoint for CaptureOrder { } } -/// Authorizes payment for an order. To successfully authorize payment for an order, -/// the buyer must first approve the order or a valid payment_source must be provided in the request. +/// Authorizes payment for an order. To successfully authorize payment for an order, +/// the buyer must first approve the order or a valid payment_source must be provided in the request. /// A buyer can approve the order upon being redirected to the rel:approve URL that was returned in the HATEOAS links in the create order response. #[derive(Debug)] pub struct AuthorizeOrder { /// The order id. order_id: String, /// The endpoint body. - pub body: Option + pub body: Option, } impl AuthorizeOrder { diff --git a/src/client.rs b/src/client.rs index 97abf72..8fcf82c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -218,7 +218,7 @@ impl Client { } /// Executes the given endpoints with the default headers. - /// + /// /// You must remember to call `get_access_token` first or this may fail due to not being authed. pub async fn execute(&self, endpoint: E) -> Result where diff --git a/src/data/invoice.rs b/src/data/invoice.rs index e58992e..26624f8 100644 --- a/src/data/invoice.rs +++ b/src/data/invoice.rs @@ -1,6 +1,6 @@ //! Paypal object definitions used in the invoice api. -use crate::{data::common::*, data::common::LinkDescription}; +use crate::{data::common::LinkDescription, data::common::*}; use derive_builder::Builder; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; @@ -632,4 +632,4 @@ pub struct RecordPaymentPayload { amount: Amount, shipping_info: Option, -} \ No newline at end of file +} diff --git a/src/data/mod.rs b/src/data/mod.rs index ecc762c..bd1df39 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -1,5 +1,5 @@ //! This module contains the data structures used in the api endpoints. pub mod common; +pub mod invoice; pub mod orders; -pub mod invoice; \ No newline at end of file diff --git a/src/data/orders.rs b/src/data/orders.rs index 0beb13a..151205e 100644 --- a/src/data/orders.rs +++ b/src/data/orders.rs @@ -1,8 +1,6 @@ //! Paypal object definitions used by the orders api. use super::common::*; -use crate::errors::{PaypalError, ResponseError}; -use crate::HeaderParams; use derive_builder::Builder; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; @@ -726,4 +724,4 @@ pub struct Order { pub struct InvoiceNumber { /// The invoice number. pub invoice_number: String, -} \ No newline at end of file +} diff --git a/src/endpoint.rs b/src/endpoint.rs index 4600678..c6b8f1c 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -1,8 +1,8 @@ //! This module contains the endpoint trait used to implemented api endpoints. +use crate::{LIVE_ENDPOINT, SANDBOX_ENDPOINT}; +use serde::{de::DeserializeOwned, Serialize}; use std::borrow::Cow; -use serde::{Serialize, de::DeserializeOwned}; -use crate::{SANDBOX_ENDPOINT, LIVE_ENDPOINT}; /// A trait implemented by api endpoints. pub trait Endpoint { @@ -30,7 +30,7 @@ pub trait Endpoint { } /// The full path of this endpoint. - /// + /// /// Automatically implemented. fn full_path(&self, is_sandbox: bool) -> String { if is_sandbox { @@ -39,4 +39,4 @@ pub trait Endpoint { format!("{}{}", LIVE_ENDPOINT, self.relative_path()) } } -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index d7ee75e..405c76e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,13 +75,14 @@ //! - [ ] Payment Experience Web Profiles API - 1.0.0 #![deny(missing_docs)] +#![forbid(unsafe_code)] pub mod api; +pub mod client; pub mod countries; pub mod data; pub mod endpoint; pub mod errors; -pub mod client; pub use client::*; use derive_builder::Builder; @@ -160,9 +161,9 @@ struct AuthAssertionClaims { #[cfg(test)] mod tests { - use crate::{countries::Country}; + use crate::countries::Country; use crate::data::common::Currency; - use crate::{Client}; + use crate::Client; use std::env; use std::str::FromStr;