cleanup
This commit is contained in:
parent
3f783a824f
commit
d38ef6f80e
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
use paypal_rs::{common::*, errors::*, invoice::*, Client, HeaderParams};
|
use paypal_rs::{common::*, errors::*, invoice::*, Client, HeaderParams};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -73,4 +73,4 @@ async fn main() -> Result<(), ResponseError> {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{
|
data::{
|
||||||
invoice::{Invoice, InvoiceList, InvoicePayload, CancelReason},
|
invoice::{CancelReason, Invoice, InvoiceList, InvoicePayload},
|
||||||
orders::InvoiceNumber,
|
orders::InvoiceNumber,
|
||||||
},
|
},
|
||||||
endpoint::Endpoint,
|
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.
|
/// 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.
|
/// 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.
|
/// 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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DeleteInvoice {
|
pub struct DeleteInvoice {
|
||||||
|
@ -202,7 +202,7 @@ pub struct UpdateInvoiceQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update an invoice.
|
/// 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.
|
/// 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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct UpdateInvoice {
|
pub struct UpdateInvoice {
|
||||||
|
@ -215,10 +215,7 @@ pub struct UpdateInvoice {
|
||||||
impl UpdateInvoice {
|
impl UpdateInvoice {
|
||||||
/// New constructor.
|
/// New constructor.
|
||||||
pub fn new(invoice: Invoice, query: UpdateInvoiceQuery) -> Self {
|
pub fn new(invoice: Invoice, query: UpdateInvoiceQuery) -> Self {
|
||||||
Self {
|
Self { invoice, query }
|
||||||
invoice,
|
|
||||||
query
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,16 +249,13 @@ pub struct CancelInvoice {
|
||||||
/// The invoice id.
|
/// The invoice id.
|
||||||
pub invoice_id: String,
|
pub invoice_id: String,
|
||||||
/// The reason of the cancelation.
|
/// The reason of the cancelation.
|
||||||
pub reason: CancelReason
|
pub reason: CancelReason,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CancelInvoice {
|
impl CancelInvoice {
|
||||||
/// New constructor.
|
/// New constructor.
|
||||||
pub fn new(invoice_id: String, reason: CancelReason) -> Self {
|
pub fn new(invoice_id: String, reason: CancelReason) -> Self {
|
||||||
Self {
|
Self { invoice_id, reason }
|
||||||
invoice_id,
|
|
||||||
reason
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! This module contains the api endpoints.
|
//! This module contains the api endpoints.
|
||||||
|
|
||||||
|
pub mod invoice;
|
||||||
pub mod orders;
|
pub mod orders;
|
||||||
pub mod invoice;
|
|
|
@ -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.
|
//! 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/
|
//! https://developer.paypal.com/docs/api/orders/v2/
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::json;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::orders::{Order, OrderPayload, PaymentSourceResponse},
|
data::orders::{Order, OrderPayload},
|
||||||
endpoint::Endpoint,
|
endpoint::Endpoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ pub struct PaymentSourceToken {
|
||||||
/// The PayPal-generated ID for the token.
|
/// The PayPal-generated ID for the token.
|
||||||
pub id: String,
|
pub id: String,
|
||||||
/// The tokenization method that generated the ID.
|
/// The tokenization method that generated the ID.
|
||||||
///
|
///
|
||||||
/// Can only be BILLING_AGREEMENT.
|
/// Can only be BILLING_AGREEMENT.
|
||||||
pub r#type: String,
|
pub r#type: String,
|
||||||
}
|
}
|
||||||
|
@ -106,15 +105,15 @@ pub struct PaymentSourceBody {
|
||||||
pub payment_source: PaymentSource,
|
pub payment_source: PaymentSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Captures payment for an order. To successfully capture payment for an order,
|
/// 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.
|
/// 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.
|
/// 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)]
|
#[derive(Debug, Clone, Builder)]
|
||||||
pub struct CaptureOrder {
|
pub struct CaptureOrder {
|
||||||
/// The id of the order.
|
/// The id of the order.
|
||||||
pub order_id: String,
|
pub order_id: String,
|
||||||
/// The endpoint body.
|
/// The endpoint body.
|
||||||
pub body: Option<PaymentSourceBody>
|
pub body: Option<PaymentSourceBody>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CaptureOrder {
|
impl CaptureOrder {
|
||||||
|
@ -147,15 +146,15 @@ impl Endpoint for CaptureOrder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Authorizes payment for an order. To successfully authorize payment for an order,
|
/// 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.
|
/// 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.
|
/// 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)]
|
#[derive(Debug)]
|
||||||
pub struct AuthorizeOrder {
|
pub struct AuthorizeOrder {
|
||||||
/// The order id.
|
/// The order id.
|
||||||
order_id: String,
|
order_id: String,
|
||||||
/// The endpoint body.
|
/// The endpoint body.
|
||||||
pub body: Option<PaymentSourceBody>
|
pub body: Option<PaymentSourceBody>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AuthorizeOrder {
|
impl AuthorizeOrder {
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes the given endpoints with the default headers.
|
/// 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.
|
/// You must remember to call `get_access_token` first or this may fail due to not being authed.
|
||||||
pub async fn execute<E>(&self, endpoint: E) -> Result<E::Response, ResponseError>
|
pub async fn execute<E>(&self, endpoint: E) -> Result<E::Response, ResponseError>
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Paypal object definitions used in the invoice api.
|
//! 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 derive_builder::Builder;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_with::skip_serializing_none;
|
use serde_with::skip_serializing_none;
|
||||||
|
@ -632,4 +632,4 @@ pub struct RecordPaymentPayload {
|
||||||
amount: Amount,
|
amount: Amount,
|
||||||
|
|
||||||
shipping_info: Option<ContactInformation>,
|
shipping_info: Option<ContactInformation>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//! This module contains the data structures used in the api endpoints.
|
//! This module contains the data structures used in the api endpoints.
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
pub mod invoice;
|
||||||
pub mod orders;
|
pub mod orders;
|
||||||
pub mod invoice;
|
|
|
@ -1,8 +1,6 @@
|
||||||
//! Paypal object definitions used by the orders api.
|
//! Paypal object definitions used by the orders api.
|
||||||
|
|
||||||
use super::common::*;
|
use super::common::*;
|
||||||
use crate::errors::{PaypalError, ResponseError};
|
|
||||||
use crate::HeaderParams;
|
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_with::skip_serializing_none;
|
use serde_with::skip_serializing_none;
|
||||||
|
@ -726,4 +724,4 @@ pub struct Order {
|
||||||
pub struct InvoiceNumber {
|
pub struct InvoiceNumber {
|
||||||
/// The invoice number.
|
/// The invoice number.
|
||||||
pub invoice_number: String,
|
pub invoice_number: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//! This module contains the endpoint trait used to implemented api endpoints.
|
//! 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 std::borrow::Cow;
|
||||||
use serde::{Serialize, de::DeserializeOwned};
|
|
||||||
use crate::{SANDBOX_ENDPOINT, LIVE_ENDPOINT};
|
|
||||||
|
|
||||||
/// A trait implemented by api endpoints.
|
/// A trait implemented by api endpoints.
|
||||||
pub trait Endpoint {
|
pub trait Endpoint {
|
||||||
|
@ -30,7 +30,7 @@ pub trait Endpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The full path of this endpoint.
|
/// The full path of this endpoint.
|
||||||
///
|
///
|
||||||
/// Automatically implemented.
|
/// Automatically implemented.
|
||||||
fn full_path(&self, is_sandbox: bool) -> String {
|
fn full_path(&self, is_sandbox: bool) -> String {
|
||||||
if is_sandbox {
|
if is_sandbox {
|
||||||
|
@ -39,4 +39,4 @@ pub trait Endpoint {
|
||||||
format!("{}{}", LIVE_ENDPOINT, self.relative_path())
|
format!("{}{}", LIVE_ENDPOINT, self.relative_path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,14 @@
|
||||||
//! - [ ] Payment Experience Web Profiles API - 1.0.0
|
//! - [ ] Payment Experience Web Profiles API - 1.0.0
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod client;
|
||||||
pub mod countries;
|
pub mod countries;
|
||||||
pub mod data;
|
pub mod data;
|
||||||
pub mod endpoint;
|
pub mod endpoint;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod client;
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
|
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
|
@ -160,9 +161,9 @@ struct AuthAssertionClaims {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{countries::Country};
|
use crate::countries::Country;
|
||||||
use crate::data::common::Currency;
|
use crate::data::common::Currency;
|
||||||
use crate::{Client};
|
use crate::Client;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue