Skip to content

Commit

Permalink
build(codegen): updating SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
ct-sdks[bot] committed Feb 7, 2024
1 parent 69ad8b6 commit 95aab47
Show file tree
Hide file tree
Showing 43 changed files with 1,377 additions and 3 deletions.
26 changes: 26 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
**Api changes**

<details>
<summary>Added Method(s)</summary>

- added method `apiRoot.withProjectKey().discountCodes().withKey().get()`
- added method `apiRoot.withProjectKey().discountCodes().withKey().head()`
- added method `apiRoot.withProjectKey().discountCodes().withKey().post()`
- added method `apiRoot.withProjectKey().discountCodes().withKey().delete()`
</details>


<details>
<summary>Added Property(s)</summary>

- added property `perMethodExternalTaxRate` to type `CartAddLineItemAction`
- added property `key` to type `DiscountCode`
- added property `key` to type `DiscountCodeDraft`
- added property `shippingMode` to type `MyCartDraft`
</details>


<details>
<summary>Added Resource(s)</summary>

- added resource `/{projectKey}/discount-codes/key={key}`
</details>


<details>
<summary>Added Type(s)</summary>

- added type `DiscountCodeSetKeyAction`
- added type `CartDiscountCreatedMessage`
- added type `CartDiscountDeletedMessage`
- added type `CartDiscountStoreAddedMessage`
- added type `CartDiscountStoreRemovedMessage`
- added type `CartDiscountStoresSetMessage`
- added type `DiscountCodeCreatedMessage`
- added type `DiscountCodeDeletedMessage`
- added type `DiscountCodeKeySetMessage`
- added type `CartDiscountCreatedMessagePayload`
- added type `CartDiscountDeletedMessagePayload`
- added type `CartDiscountStoreAddedMessagePayload`
- added type `CartDiscountStoreRemovedMessagePayload`
- added type `CartDiscountStoresSetMessagePayload`
- added type `DiscountCodeCreatedMessagePayload`
- added type `DiscountCodeDeletedMessagePayload`
- added type `DiscountCodeKeySetMessagePayload`
</details>

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using Xunit;

// ReSharper disable CheckNamespace
namespace commercetools.Sdk.Api.Tests.Client.RequestBuilders.DiscountCodes
{
public class ByProjectKeyDiscountCodesKeyByKeyTest : RequestBuilderParentTests
{
[Theory]
[MemberData(nameof(GetData))]
public void WithMethods(HttpRequestMessage request, string httpMethod, string uri)
{
Assert.Equal(httpMethod.ToLower(), request.Method.Method.ToLower());
Assert.Equal(uri.ToLower(), request.RequestUri.ToString().ToLower());
}

public static IEnumerable<object[]> GetData()
{
return new List<object[]> {
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Get()
.WithExpand("expand")
.Build(),
"Get",
"/test_projectKey/discount-codes/key=test_key?expand=expand",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Get()
.Build(),
"Get",
"/test_projectKey/discount-codes/key=test_key",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Head()
.Build(),
"Head",
"/test_projectKey/discount-codes/key=test_key",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Post(null)
.WithExpand("expand")
.Build(),
"Post",
"/test_projectKey/discount-codes/key=test_key?expand=expand",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Post(null)
.Build(),
"Post",
"/test_projectKey/discount-codes/key=test_key",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Delete()
.WithDataErasure(true)
.Build(),
"Delete",
"/test_projectKey/discount-codes/key=test_key?dataErasure=true",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Delete()
.WithVersion(2)
.Build(),
"Delete",
"/test_projectKey/discount-codes/key=test_key?version=2",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Delete()
.WithExpand("expand")
.Build(),
"Delete",
"/test_projectKey/discount-codes/key=test_key?expand=expand",
},
new Object[] {
ApiRoot
.WithProjectKey("test_projectKey")
.DiscountCodes()
.WithKey("test_key")
.Delete()
.Build(),
"Delete",
"/test_projectKey/discount-codes/key=test_key",
}
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System.Globalization;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using commercetools.Base.Client;


// ReSharper disable CheckNamespace
namespace commercetools.Sdk.Api.Client.RequestBuilders.DiscountCodes
{

public partial class ByProjectKeyDiscountCodesKeyByKeyDelete : ApiMethod<ByProjectKeyDiscountCodesKeyByKeyDelete>, IApiMethod<ByProjectKeyDiscountCodesKeyByKeyDelete, commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>, commercetools.Sdk.Api.Client.IDataerasureTrait<ByProjectKeyDiscountCodesKeyByKeyDelete>, commercetools.Sdk.Api.Client.IVersionedTrait<ByProjectKeyDiscountCodesKeyByKeyDelete>, commercetools.Sdk.Api.Client.IConflictingTrait<ByProjectKeyDiscountCodesKeyByKeyDelete>, commercetools.Sdk.Api.Client.IExpandableTrait<ByProjectKeyDiscountCodesKeyByKeyDelete>, commercetools.Sdk.Api.Client.IErrorableTrait<ByProjectKeyDiscountCodesKeyByKeyDelete>, commercetools.Sdk.Api.Client.IDeprecatable200Trait<ByProjectKeyDiscountCodesKeyByKeyDelete>
{


private IClient ApiHttpClient { get; }

public override HttpMethod Method => HttpMethod.Delete;

private string ProjectKey { get; }

private string Key { get; }


public ByProjectKeyDiscountCodesKeyByKeyDelete(IClient apiHttpClient, string projectKey, string key)
{
this.ApiHttpClient = apiHttpClient;
this.ProjectKey = projectKey;
this.Key = key;
this.RequestUrl = $"/{ProjectKey}/discount-codes/key={Key}";
}

public List<string> GetDataErasure()
{
return this.GetQueryParam("dataErasure");
}

public List<string> GetVersion()
{
return this.GetQueryParam("version");
}

public List<string> GetExpand()
{
return this.GetQueryParam("expand");
}

public ByProjectKeyDiscountCodesKeyByKeyDelete WithDataErasure(bool dataErasure)
{
return this.AddQueryParam("dataErasure", dataErasure.ToString());
}

public ByProjectKeyDiscountCodesKeyByKeyDelete WithVersion(long version)
{
return this.AddQueryParam("version", version.ToString(CultureInfo.InvariantCulture));
}

public ByProjectKeyDiscountCodesKeyByKeyDelete WithExpand(string expand)
{
return this.AddQueryParam("expand", expand);
}


public async Task<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode> ExecuteAsync(CancellationToken cancellationToken = default)
{

var requestMessage = Build();
return await ApiHttpClient.ExecuteAsync<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>(requestMessage, cancellationToken);

}

public async Task<string> ExecuteAsJsonAsync(CancellationToken cancellationToken = default)
{
var requestMessage = Build();
return await ApiHttpClient.ExecuteAsJsonAsync(requestMessage, cancellationToken);
}

public async Task<IApiResponse<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>> SendAsync(CancellationToken cancellationToken = default)
{

var requestMessage = Build();
return await ApiHttpClient.SendAsync<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>(requestMessage, cancellationToken);

}

public async Task<IApiResponse<string>> SendAsJsonAsync(CancellationToken cancellationToken = default)
{
var requestMessage = Build();
return await ApiHttpClient.SendAsJsonAsync(requestMessage, cancellationToken);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using commercetools.Base.Client;


// ReSharper disable CheckNamespace
namespace commercetools.Sdk.Api.Client.RequestBuilders.DiscountCodes
{

public partial class ByProjectKeyDiscountCodesKeyByKeyGet : ApiMethod<ByProjectKeyDiscountCodesKeyByKeyGet>, IApiMethod<ByProjectKeyDiscountCodesKeyByKeyGet, commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>, commercetools.Sdk.Api.Client.IExpandableTrait<ByProjectKeyDiscountCodesKeyByKeyGet>, commercetools.Sdk.Api.Client.IErrorableTrait<ByProjectKeyDiscountCodesKeyByKeyGet>, commercetools.Sdk.Api.Client.IDeprecatable200Trait<ByProjectKeyDiscountCodesKeyByKeyGet>
{


private IClient ApiHttpClient { get; }

public override HttpMethod Method => HttpMethod.Get;

private string ProjectKey { get; }

private string Key { get; }


public ByProjectKeyDiscountCodesKeyByKeyGet(IClient apiHttpClient, string projectKey, string key)
{
this.ApiHttpClient = apiHttpClient;
this.ProjectKey = projectKey;
this.Key = key;
this.RequestUrl = $"/{ProjectKey}/discount-codes/key={Key}";
}

public List<string> GetExpand()
{
return this.GetQueryParam("expand");
}

public ByProjectKeyDiscountCodesKeyByKeyGet WithExpand(string expand)
{
return this.AddQueryParam("expand", expand);
}


public async Task<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode> ExecuteAsync(CancellationToken cancellationToken = default)
{

var requestMessage = Build();
return await ApiHttpClient.ExecuteAsync<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>(requestMessage, cancellationToken);

}

public async Task<string> ExecuteAsJsonAsync(CancellationToken cancellationToken = default)
{
var requestMessage = Build();
return await ApiHttpClient.ExecuteAsJsonAsync(requestMessage, cancellationToken);
}

public async Task<IApiResponse<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>> SendAsync(CancellationToken cancellationToken = default)
{

var requestMessage = Build();
return await ApiHttpClient.SendAsync<commercetools.Sdk.Api.Models.DiscountCodes.IDiscountCode>(requestMessage, cancellationToken);

}

public async Task<IApiResponse<string>> SendAsJsonAsync(CancellationToken cancellationToken = default)
{
var requestMessage = Build();
return await ApiHttpClient.SendAsJsonAsync(requestMessage, cancellationToken);
}

}
}
Loading

0 comments on commit 95aab47

Please sign in to comment.