Skip to content

Commit

Permalink
Use collection expression (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
trejjam authored Oct 9, 2024
1 parent 652b156 commit ee9abe1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
18 changes: 9 additions & 9 deletions samples/PayPal.Sdk.Checkout.Samples/CreateOrderSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using PayPal.Sdk.Checkout.Extensions;
using PayPal.Sdk.Checkout.Orders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -70,9 +69,9 @@ private static OrderRequest BuildRequestBody()
},
},
},
Items = new List<Item>
{
new()
Items =
[
new Item
{
Name = "T-shirt",
Description = "Green XL",
Expand All @@ -90,6 +89,7 @@ private static OrderRequest BuildRequestBody()
Quantity = "1",
Category = EItemCategory.PhysicalGoods,
},

new()
{
Name = "Shoes",
Expand All @@ -108,7 +108,7 @@ private static OrderRequest BuildRequestBody()
Quantity = "2",
Category = EItemCategory.PhysicalGoods,
},
},
],
ShippingDetail = new ShippingDetail
{
Name = new ShippingName
Expand Down Expand Up @@ -176,17 +176,17 @@ private static OrderRequest BuildRequestBodyWithMinimumFields()
CancelUrl = "https://www.example.com",
ReturnUrl = "https://www.example.com",
},
PurchaseUnits = new List<PurchaseUnitRequest>
{
new()
PurchaseUnits =
[
new PurchaseUnitRequest
{
AmountWithBreakdown = new AmountWithBreakdown
{
CurrencyCode = "USD",
Value = "220.00",
},
},
},
],
};

return orderRequest;
Expand Down
8 changes: 5 additions & 3 deletions samples/PayPal.Sdk.Checkout.Samples/PatchOrderSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ This method can be used to build the patch request body.
*/
private static IReadOnlyCollection<StringPatch> BuildPatches()
{
var patches = new List<StringPatch>
{
IReadOnlyCollection<StringPatch> patches =
[
new()
{
Op = "replace",
Path = "/intent",
Value = "CAPTURE",
},

new()
{
Op = "replace",
Path = "/purchase_units/@reference_id=='PUHF'/description",
Value = "Physical Goods",
},
};

];
return patches;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void Add(this IDictionary<string, ICollection<string>> collection,
{
if (!collection.ContainsKey(key))
{
collection.Add(key, new List<string>());
collection.Add(key, []);
}

collection[key].Add(value);
Expand Down

0 comments on commit ee9abe1

Please sign in to comment.