Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit 95f1ddd

Browse files
committed
Adding Localized name for Shipping Method
1 parent 8865f6e commit 95f1ddd

File tree

9 files changed

+41
-15
lines changed

9 files changed

+41
-15
lines changed

commercetools.Sdk/IntegrationTests/commercetools.Sdk.IntegrationTests/Carts/CartsIntegrationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ await WithUpdateableCart(client,
610610
var updatedCart = await client
611611
.ExecuteAsync(cart.UpdateById(actions => actions.AddUpdate(action)));
612612

613-
Assert.Equal(shippingMethod.Name, updatedCart.ShippingInfo.ShippingMethodName);
613+
Assert.Equal(shippingMethod.LocalizedName["en"], updatedCart.ShippingInfo.ShippingMethodName);
614614
return updatedCart;
615615
});
616616
});
@@ -886,7 +886,7 @@ await WithUpdateableCart(client,
886886
{
887887
Assert.Equal(TaxMode.ExternalAmount, cart.TaxMode);
888888
Assert.Equal(shippingAddress.ToString(), cart.ShippingAddress.ToString());
889-
Assert.Equal(shippingMethod.Name, cart.ShippingInfo.ShippingMethodName);
889+
Assert.Equal(shippingMethod.LocalizedName["en"], cart.ShippingInfo.ShippingMethodName);
890890

891891
var externalTaxAmountDraft = TestingUtility.GetExternalTaxAmountDraft();
892892

@@ -931,7 +931,7 @@ await WithUpdateableCart(client,
931931
{
932932
Assert.Equal(TaxMode.External, cart.TaxMode);
933933
Assert.Equal(shippingAddress.ToString(), cart.ShippingAddress.ToString());
934-
Assert.Equal(shippingMethod.Name, cart.ShippingInfo.ShippingMethodName);
934+
Assert.Equal(shippingMethod.LocalizedName["en"], cart.ShippingInfo.ShippingMethodName);
935935

936936
var externalTaxRateDraft = TestingUtility.GetExternalTaxRateDraft();
937937

commercetools.Sdk/IntegrationTests/commercetools.Sdk.IntegrationTests/OrdersImport/OrdersImportFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static OrderImportDraft DefaultOrderImportDraftWithLineItemWithShippingIn
114114
{
115115
Price = amountEuro10,
116116
ShippingRate = shippingRate,
117-
ShippingMethodName = shippingMethod.Name,
117+
ShippingMethodName = shippingMethod.LocalizedName["en"],
118118
ShippingMethod = shippingMethod.ToKeyResourceIdentifier(),
119119
TaxCategory = taxCategory.ToKeyResourceIdentifier()
120120
};

commercetools.Sdk/IntegrationTests/commercetools.Sdk.IntegrationTests/ShippingMethods/ShippingMethodIntegrationTests.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ await WithShippingMethod(
4343
client,
4444
shippingMethodDraft =>
4545
DefaultShippingMethodDraftWithKeyWithTaxCategory(shippingMethodDraft, taxCategory.ToKeyResourceIdentifier(), key),
46-
shippingMethod =>
46+
(shippingMethod, draft) =>
4747
{
4848
Assert.Equal(key, shippingMethod.Key);
49+
Assert.Equal(draft.LocalizedName["en"], shippingMethod.LocalizedName["en"]);
50+
Assert.Equal(draft.LocalizedDescription["en"], shippingMethod.LocalizedDescription["en"]);
4951
});
5052
});
5153
}
@@ -295,13 +297,16 @@ await WithUpdateableShippingMethod(client, async shippingMethod =>
295297
{
296298
var newName = TestingUtility.RandomString();
297299
var updateActions = new List<UpdateAction<ShippingMethod>>();
298-
var action = new ChangeNameUpdateAction { Name = newName };
300+
var action = new SetLocalizedNameUpdateAction
301+
{
302+
LocalizedName= new LocalizedString {{"en", newName}}
303+
};
299304
updateActions.Add(action);
300305

301306
var updatedShippingMethod = await client
302307
.ExecuteAsync(new UpdateByIdCommand<ShippingMethod>(shippingMethod, updateActions));
303308

304-
Assert.Equal(newName, updatedShippingMethod.Name);
309+
Assert.Equal(newName, updatedShippingMethod.LocalizedName["en"]);
305310
return updatedShippingMethod;
306311
});
307312
}

commercetools.Sdk/IntegrationTests/commercetools.Sdk.IntegrationTests/ShippingMethods/ShippingMethodsFixture.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public static ShippingMethodDraft DefaultShippingMethodDraft(ShippingMethodDraft
2323
var random = TestingUtility.RandomInt();
2424
shippingMethodDraft.Key = $"Key_{random}";
2525
shippingMethodDraft.Name = $"ShippingMethod_{random}";
26+
shippingMethodDraft.LocalizedName = new LocalizedString {{"en", $"ShippingMethod_{random}"}};
27+
shippingMethodDraft.LocalizedDescription = new LocalizedString {{"en", $"ShippingMethodDes_{random}"}};
2628
return shippingMethodDraft;
2729
}
2830

@@ -84,7 +86,12 @@ await WithTaxCategory(client, async taxCategory =>
8486
public static async Task WithShippingMethod(IClient client,
8587
Func<ShippingMethodDraft, ShippingMethodDraft> draftAction, Action<ShippingMethod> func)
8688
{
87-
await With(client, new ShippingMethodDraft(), draftAction, func);
89+
await With(client, DefaultShippingMethodDraft(new ShippingMethodDraft()), draftAction, func);
90+
}
91+
public static async Task WithShippingMethod(IClient client,
92+
Func<ShippingMethodDraft, ShippingMethodDraft> draftAction, Action<ShippingMethod,ShippingMethodDraft> func)
93+
{
94+
await With(client, DefaultShippingMethodDraft(new ShippingMethodDraft()), draftAction, func);
8895
}
8996

9097
public static async Task WithShippingMethod(IClient client, Func<ShippingMethod, Task> func)

commercetools.Sdk/commercetools.Sdk.Client/CheckByQueryCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public CheckByQueryCommand()
1111
Where = new List<string>();
1212
}
1313

14-
public List<string> Where { get; set; }
14+
public List<string> Where { get; private set; }
1515
}
1616
}

commercetools.Sdk/commercetools.Sdk.Domain/ShippingMethods/ShippingMethod.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ namespace commercetools.Sdk.Domain.ShippingMethods
1010
public class ShippingMethod : Resource<ShippingMethod>, IKeyReferencable<ShippingMethod>
1111
{
1212
public string Key { get; set; }
13-
public string Name { get; set; }
13+
public LocalizedString LocalizedName { get; set; }
14+
public LocalizedString LocalizedDescription { get; set; }
1415

16+
[Obsolete("Use LocalizedName instead")]
17+
public string Name { get; set; }
1518
[Obsolete("Use LocalizedDescription instead")]
1619
public string Description { get; set; }
1720
public Reference<TaxCategory> TaxCategory { get; set; }
1821
public List<ZoneRate> ZoneRates { get; set; }
1922
public bool IsDefault { get; set; }
2023
public string Predicate { get; set; }
21-
public LocalizedString LocalizedDescription { get; set; }
2224
public CustomFields Custom { get; set; }
2325
}
24-
}
26+
}

commercetools.Sdk/commercetools.Sdk.Domain/ShippingMethods/ShippingMethodDraft.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ namespace commercetools.Sdk.Domain.ShippingMethods
1212
public class ShippingMethodDraft : IDraft<ShippingMethod>
1313
{
1414
public string Key { get; set; }
15-
public string Name { get; set; }
15+
public LocalizedString LocalizedName { get; set; }
16+
public LocalizedString LocalizedDescription { get; set; }
1617

18+
[Obsolete("Use LocalizedName instead")]
19+
public string Name { get; set; }
1720
[Obsolete("Use LocalizedDescription instead")]
1821
public string Description { get; set; }
1922
public IReference<TaxCategory> TaxCategory { get; set; }
2023
public List<ZoneRateDraft> ZoneRates { get; set; }
2124
public bool IsDefault { get; set; }
2225
public string Predicate { get; set; }
23-
public LocalizedString LocalizedDescription { get; set; }
2426
public CustomFieldsDraft Custom { get; set; }
2527
}
2628
}

commercetools.Sdk/commercetools.Sdk.Domain/ShippingMethods/UpdateActions/ChangeNameUpdateAction.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
23

34
namespace commercetools.Sdk.Domain.ShippingMethods.UpdateActions
45
{
6+
[Obsolete("Use SetLocalizedNameUpdateAction instead")]
57
public class ChangeNameUpdateAction : UpdateAction<ShippingMethod>
68
{
79
public string Action => "changeName";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace commercetools.Sdk.Domain.ShippingMethods.UpdateActions
2+
{
3+
public class SetLocalizedNameUpdateAction : UpdateAction<ShippingMethod>
4+
{
5+
public string Action => "setLocalizedName";
6+
public LocalizedString LocalizedName { get; set; }
7+
}
8+
}

0 commit comments

Comments
 (0)