Skip to content

Commit c927652

Browse files
committed
Clippy fixes
1 parent 4ce5d56 commit c927652

File tree

6 files changed

+30
-70
lines changed

6 files changed

+30
-70
lines changed

src/api/invoice.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Endpoint for GenerateInvoiceNumber {
4545

4646
type Response = InvoiceNumber;
4747

48-
fn relative_path(&self) -> Cow<str> {
48+
fn relative_path(&self) -> Cow<'_, str> {
4949
Cow::Borrowed("/v2/invoicing/generate-next-invoice-number")
5050
}
5151

@@ -80,7 +80,7 @@ impl Endpoint for CreateDraftInvoice {
8080

8181
type Response = Invoice;
8282

83-
fn relative_path(&self) -> Cow<str> {
83+
fn relative_path(&self) -> Cow<'_, str> {
8484
Cow::Borrowed("/v2/invoicing/invoices")
8585
}
8686

@@ -116,7 +116,7 @@ impl Endpoint for GetInvoice {
116116

117117
type Response = Invoice;
118118

119-
fn relative_path(&self) -> Cow<str> {
119+
fn relative_path(&self) -> Cow<'_, str> {
120120
Cow::Owned(format!("/v2/invoicing/invoices/{}", self.invoice_id))
121121
}
122122

@@ -147,7 +147,7 @@ impl Endpoint for ListInvoices {
147147

148148
type Response = InvoiceList;
149149

150-
fn relative_path(&self) -> Cow<str> {
150+
fn relative_path(&self) -> Cow<'_, str> {
151151
Cow::Borrowed("/v2/invoicing/invoices")
152152
}
153153

@@ -187,7 +187,7 @@ impl Endpoint for DeleteInvoice {
187187

188188
type Response = ();
189189

190-
fn relative_path(&self) -> Cow<str> {
190+
fn relative_path(&self) -> Cow<'_, str> {
191191
Cow::Owned(format!("/v2/invoicing/invoices/{}", self.invoice_id))
192192
}
193193

@@ -230,7 +230,7 @@ impl Endpoint for UpdateInvoice {
230230

231231
type Response = Invoice;
232232

233-
fn relative_path(&self) -> Cow<str> {
233+
fn relative_path(&self) -> Cow<'_, str> {
234234
Cow::Owned(format!("/v2/invoicing/invoices/{}", self.invoice.id))
235235
}
236236

@@ -273,7 +273,7 @@ impl Endpoint for CancelInvoice {
273273

274274
type Response = ();
275275

276-
fn relative_path(&self) -> Cow<str> {
276+
fn relative_path(&self) -> Cow<'_, str> {
277277
Cow::Owned(format!("/v2/invoicing/invoices/{}/cancel", self.invoice_id))
278278
}
279279

@@ -312,7 +312,7 @@ impl Endpoint for SendInvoice {
312312

313313
type Response = ();
314314

315-
fn relative_path(&self) -> Cow<str> {
315+
fn relative_path(&self) -> Cow<'_, str> {
316316
Cow::Owned(format!("/v2/invoicing/invoices/{}/send", self.invoice_id))
317317
}
318318

src/api/orders.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Endpoint for CreateOrder {
3333

3434
type Response = Order;
3535

36-
fn relative_path(&self) -> Cow<str> {
36+
fn relative_path(&self) -> Cow<'_, str> {
3737
Cow::Borrowed("/v2/checkout/orders")
3838
}
3939

@@ -69,7 +69,7 @@ impl Endpoint for ShowOrderDetails {
6969

7070
type Response = Order;
7171

72-
fn relative_path(&self) -> Cow<str> {
72+
fn relative_path(&self) -> Cow<'_, str> {
7373
Cow::Owned(format!("/v2/checkout/orders/{}", self.order_id))
7474
}
7575

@@ -132,7 +132,7 @@ impl Endpoint for CaptureOrder {
132132

133133
type Response = Order;
134134

135-
fn relative_path(&self) -> Cow<str> {
135+
fn relative_path(&self) -> Cow<'_, str> {
136136
Cow::Owned(format!("/v2/checkout/orders/{}/capture", self.order_id))
137137
}
138138

@@ -173,7 +173,7 @@ impl Endpoint for AuthorizeOrder {
173173

174174
type Response = Order;
175175

176-
fn relative_path(&self) -> Cow<str> {
176+
fn relative_path(&self) -> Cow<'_, str> {
177177
Cow::Owned(format!("/v2/checkout/orders/{}/authorize", self.order_id))
178178
}
179179

src/api/payments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Endpoint for GetAuthorizedPayment {
3535

3636
type Response = AuthorizedPaymentDetails;
3737

38-
fn relative_path(&self) -> Cow<str> {
38+
fn relative_path(&self) -> Cow<'_, str> {
3939
Cow::Owned(format!("/v2/payments/authorizations/{}", self.authorization_id))
4040
}
4141

src/data/invoice.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ pub enum PaymentType {
412412
}
413413

414414
/// The payment mode or method through which the invoicer can accept the payment.
415-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
415+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
416416
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
417417
pub enum PaymentMethod {
418418
/// Payments can be received through bank transfers.
@@ -426,19 +426,14 @@ pub enum PaymentMethod {
426426
/// Payments can be received through debit card payments.
427427
DebitCard,
428428
/// Payments can be received through paypal payments.
429+
#[default]
429430
Paypal,
430431
/// Payments can be received through wire transfer.
431432
WireTransfer,
432433
/// Payments can be received through other modes.
433434
Other,
434435
}
435436

436-
impl Default for PaymentMethod {
437-
fn default() -> Self {
438-
PaymentMethod::Paypal
439-
}
440-
}
441-
442437
/// Payment detail
443438
#[skip_serializing_none]
444439
#[derive(Debug, Serialize, Deserialize, Clone, Builder)]

src/data/orders.rs

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ use serde::{Deserialize, Serialize};
66
use serde_with::skip_serializing_none;
77

88
/// The intent to either capture payment immediately or authorize a payment for an order after order creation.
9-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
9+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
1010
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
1111
pub enum Intent {
1212
/// The merchant intends to capture payment immediately after the customer makes a payment.
13+
#[default]
1314
Capture,
1415
/// The merchant intends to authorize a payment and place funds on hold after the customer makes a payment.
1516
/// Authorized payments are guaranteed for up to three days but are available to capture for up to 29 days.
@@ -19,12 +20,6 @@ pub enum Intent {
1920
Authorize,
2021
}
2122

22-
impl Default for Intent {
23-
fn default() -> Self {
24-
Intent::Capture
25-
}
26-
}
27-
2823
/// Represents a payer name.
2924
///
3025
/// <https://developer.paypal.com/docs/api/orders/v2/#definition-payer.name>
@@ -197,22 +192,17 @@ pub struct PlatformFee {
197192
}
198193

199194
/// The funds that are held on behalf of the merchant
200-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
195+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Default)]
201196
pub enum DisbursementMode {
202197
/// The funds are released to the merchant immediately.
198+
#[default]
203199
Instant,
204200
/// The funds are held for a finite number of days. The actual duration depends on the region and type of integration.
205201
/// You can release the funds through a referenced payout.
206202
/// Otherwise, the funds disbursed automatically after the specified duration.
207203
Delayed,
208204
}
209205

210-
impl Default for DisbursementMode {
211-
fn default() -> Self {
212-
DisbursementMode::Instant
213-
}
214-
}
215-
216206
/// Any additional payment instructions for PayPal Commerce Platform customers.
217207
#[skip_serializing_none]
218208
#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
@@ -225,12 +215,13 @@ pub struct PaymentInstruction {
225215
}
226216

227217
/// The item category type.
228-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
218+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
229219
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
230220
pub enum ItemCategoryType {
231221
/// Goods that are stored, delivered, and used in their electronic format.
232222
/// This value is not currently supported for API callers that leverage
233223
/// the [PayPal for Commerce Platform](https://www.paypal.com/us/webapps/mpp/commerce-platform) product.
224+
#[default]
234225
DigitalGoods,
235226
/// A tangible item that can be shipped with proof of delivery.
236227
PhysicalGoods,
@@ -239,12 +230,6 @@ pub enum ItemCategoryType {
239230
Donation,
240231
}
241232

242-
impl Default for ItemCategoryType {
243-
fn default() -> Self {
244-
ItemCategoryType::DigitalGoods
245-
}
246-
}
247-
248233
/// The name of the person to whom to ship the items.
249234
#[skip_serializing_none]
250235
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
@@ -549,7 +534,7 @@ impl PurchaseUnit {
549534
}
550535

551536
/// The type of landing page to show on the PayPal site for customer checkout.
552-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
537+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
553538
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
554539
pub enum LandingPage {
555540
/// When the customer clicks PayPal Checkout, the customer is redirected to a page to log in to PayPal and approve the payment.
@@ -560,71 +545,51 @@ pub enum LandingPage {
560545
/// When the customer clicks PayPal Checkout, the customer is redirected to either a page to log in to PayPal and approve
561546
/// the payment or to a page to enter credit or debit card and other relevant billing information required to complete the purchase,
562547
/// depending on their previous interaction with PayPal.
548+
#[default]
563549
NoPreference,
564550
}
565551

566-
impl Default for LandingPage {
567-
fn default() -> Self {
568-
LandingPage::NoPreference
569-
}
570-
}
571-
572552
/// The shipping preference
573-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
553+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
574554
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
575555
pub enum ShippingPreference {
576556
/// Use the customer-provided shipping address on the PayPal site.
557+
#[default]
577558
GetFromFile,
578559
/// Redact the shipping address from the PayPal site. Recommended for digital goods.
579560
NoShipping,
580561
/// Use the merchant-provided address. The customer cannot change this address on the PayPal site.
581562
SetProvidedAddress,
582563
}
583564

584-
impl Default for ShippingPreference {
585-
fn default() -> Self {
586-
ShippingPreference::GetFromFile
587-
}
588-
}
589-
590565
/// Configures a Continue or Pay Now checkout flow.
591-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
566+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
592567
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
593568
pub enum UserAction {
594569
/// After you redirect the customer to the PayPal payment page, a Continue button appears. Use this option when
595570
/// the final amount is not known when the checkout flow is initiated and you want to redirect the customer
596571
/// to the merchant page without processing the payment.
572+
#[default]
597573
Continue,
598574
/// After you redirect the customer to the PayPal payment page, a Pay Now button appears.
599575
/// Use this option when the final amount is known when the checkout is initiated and you want to
600576
/// process the payment immediately when the customer clicks Pay Now.
601577
PayNow,
602578
}
603579

604-
impl Default for UserAction {
605-
fn default() -> Self {
606-
UserAction::Continue
607-
}
608-
}
609-
610580
/// The merchant-preferred payment sources.
611-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
581+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
612582
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
613583
pub enum PayeePreferred {
614584
/// Accepts any type of payment from the customer.
585+
#[default]
615586
Unrestricted,
616587
/// Accepts only immediate payment from the customer.
617588
/// For example, credit card, PayPal balance, or instant ACH.
618589
/// Ensures that at the time of capture, the payment does not have the `pending` status.
619590
ImmediatePaymentRequired,
620591
}
621592

622-
impl Default for PayeePreferred {
623-
fn default() -> Self {
624-
PayeePreferred::Unrestricted
625-
}
626-
}
627-
628593
/// A payment method.
629594
#[skip_serializing_none]
630595
#[derive(Debug, Default, Serialize, Deserialize, Clone)]

src/endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub trait Endpoint {
1313
type Response: DeserializeOwned;
1414

1515
/// The endpoint relative path. Must start with a `/`
16-
fn relative_path(&self) -> Cow<str>;
16+
fn relative_path(&self) -> Cow<'_, str>;
1717

1818
/// The request method of this endpoint.
1919
fn method(&self) -> reqwest::Method;

0 commit comments

Comments
 (0)