Skip to content

Commit adc28c7

Browse files
committed
Clippy fixes
1 parent 4ce5d56 commit adc28c7

File tree

6 files changed

+30
-64
lines changed

6 files changed

+30
-64
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 & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ use serde_with::skip_serializing_none;
88
/// The intent to either capture payment immediately or authorize a payment for an order after order creation.
99
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
1010
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
11+
#[derive(Default)]
1112
pub enum Intent {
1213
/// The merchant intends to capture payment immediately after the customer makes a payment.
14+
#[default]
1315
Capture,
1416
/// The merchant intends to authorize a payment and place funds on hold after the customer makes a payment.
1517
/// Authorized payments are guaranteed for up to three days but are available to capture for up to 29 days.
@@ -19,12 +21,6 @@ pub enum Intent {
1921
Authorize,
2022
}
2123

22-
impl Default for Intent {
23-
fn default() -> Self {
24-
Intent::Capture
25-
}
26-
}
27-
2824
/// Represents a payer name.
2925
///
3026
/// <https://developer.paypal.com/docs/api/orders/v2/#definition-payer.name>
@@ -197,22 +193,17 @@ pub struct PlatformFee {
197193
}
198194

199195
/// The funds that are held on behalf of the merchant
200-
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
196+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Default)]
201197
pub enum DisbursementMode {
202198
/// The funds are released to the merchant immediately.
199+
#[default]
203200
Instant,
204201
/// The funds are held for a finite number of days. The actual duration depends on the region and type of integration.
205202
/// You can release the funds through a referenced payout.
206203
/// Otherwise, the funds disbursed automatically after the specified duration.
207204
Delayed,
208205
}
209206

210-
impl Default for DisbursementMode {
211-
fn default() -> Self {
212-
DisbursementMode::Instant
213-
}
214-
}
215-
216207
/// Any additional payment instructions for PayPal Commerce Platform customers.
217208
#[skip_serializing_none]
218209
#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
@@ -227,10 +218,12 @@ pub struct PaymentInstruction {
227218
/// The item category type.
228219
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
229220
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
221+
#[derive(Default)]
230222
pub enum ItemCategoryType {
231223
/// Goods that are stored, delivered, and used in their electronic format.
232224
/// This value is not currently supported for API callers that leverage
233225
/// the [PayPal for Commerce Platform](https://www.paypal.com/us/webapps/mpp/commerce-platform) product.
226+
#[default]
234227
DigitalGoods,
235228
/// A tangible item that can be shipped with proof of delivery.
236229
PhysicalGoods,
@@ -239,12 +232,6 @@ pub enum ItemCategoryType {
239232
Donation,
240233
}
241234

242-
impl Default for ItemCategoryType {
243-
fn default() -> Self {
244-
ItemCategoryType::DigitalGoods
245-
}
246-
}
247-
248235
/// The name of the person to whom to ship the items.
249236
#[skip_serializing_none]
250237
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
@@ -551,6 +538,7 @@ impl PurchaseUnit {
551538
/// The type of landing page to show on the PayPal site for customer checkout.
552539
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
553540
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
541+
#[derive(Default)]
554542
pub enum LandingPage {
555543
/// When the customer clicks PayPal Checkout, the customer is redirected to a page to log in to PayPal and approve the payment.
556544
Login,
@@ -560,71 +548,54 @@ pub enum LandingPage {
560548
/// When the customer clicks PayPal Checkout, the customer is redirected to either a page to log in to PayPal and approve
561549
/// the payment or to a page to enter credit or debit card and other relevant billing information required to complete the purchase,
562550
/// depending on their previous interaction with PayPal.
551+
#[default]
563552
NoPreference,
564553
}
565554

566-
impl Default for LandingPage {
567-
fn default() -> Self {
568-
LandingPage::NoPreference
569-
}
570-
}
571-
572555
/// The shipping preference
573556
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
574557
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
558+
#[derive(Default)]
575559
pub enum ShippingPreference {
576560
/// Use the customer-provided shipping address on the PayPal site.
561+
#[default]
577562
GetFromFile,
578563
/// Redact the shipping address from the PayPal site. Recommended for digital goods.
579564
NoShipping,
580565
/// Use the merchant-provided address. The customer cannot change this address on the PayPal site.
581566
SetProvidedAddress,
582567
}
583568

584-
impl Default for ShippingPreference {
585-
fn default() -> Self {
586-
ShippingPreference::GetFromFile
587-
}
588-
}
589-
590569
/// Configures a Continue or Pay Now checkout flow.
591570
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
592571
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
572+
#[derive(Default)]
593573
pub enum UserAction {
594574
/// After you redirect the customer to the PayPal payment page, a Continue button appears. Use this option when
595575
/// the final amount is not known when the checkout flow is initiated and you want to redirect the customer
596576
/// to the merchant page without processing the payment.
577+
#[default]
597578
Continue,
598579
/// After you redirect the customer to the PayPal payment page, a Pay Now button appears.
599580
/// Use this option when the final amount is known when the checkout is initiated and you want to
600581
/// process the payment immediately when the customer clicks Pay Now.
601582
PayNow,
602583
}
603584

604-
impl Default for UserAction {
605-
fn default() -> Self {
606-
UserAction::Continue
607-
}
608-
}
609-
610585
/// The merchant-preferred payment sources.
611586
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
612587
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
588+
#[derive(Default)]
613589
pub enum PayeePreferred {
614590
/// Accepts any type of payment from the customer.
591+
#[default]
615592
Unrestricted,
616593
/// Accepts only immediate payment from the customer.
617594
/// For example, credit card, PayPal balance, or instant ACH.
618595
/// Ensures that at the time of capture, the payment does not have the `pending` status.
619596
ImmediatePaymentRequired,
620597
}
621598

622-
impl Default for PayeePreferred {
623-
fn default() -> Self {
624-
PayeePreferred::Unrestricted
625-
}
626-
}
627-
628599
/// A payment method.
629600
#[skip_serializing_none]
630601
#[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)