Skip to content

Commit

Permalink
Merge pull request #1 from juijeong8324/main
Browse files Browse the repository at this point in the history
Add reactoring BuildRequestUrl()
  • Loading branch information
wnsgml7267 committed Sep 8, 2022
2 parents 8f3bd18 + 4449496 commit f5d4fbd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/nt-sms/Triggers/GetMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Toast.Common.Models;
using Toast.Common.Validators;
using Toast.Sms.Configurations;
using Toast.Sms.Examples;
using Toast.Sms.Models;
using Toast.Sms.Validators;
using Toast.Sms.Workflows;
Expand Down Expand Up @@ -65,7 +66,7 @@ public async Task<IActionResult> Run(

var workflow = new HttpTriggerWorkflow();
await workflow.ValidateHeaderAsync(req)
.ValidateQueriesAsync(req, this._validator)
.ValidateQueriesAsync<GetMessageRequestQueries>(req, this._validator)
.ConfigureAwait(false);

var headers = default(RequestHeaderModel);
Expand Down
25 changes: 24 additions & 1 deletion src/nt-sms/Workflows/HttpTriggerWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using Toast.Common.Builders;
using Toast.Common.Configurations;
using Toast.Common.Extensions;
using Toast.Common.Models;
using Toast.Common.Validators;
using Toast.Sms.Configurations;
using Toast.Sms.Validators;

namespace Toast.Sms.Workflows
Expand All @@ -30,6 +32,8 @@ public interface IHttpTriggerWorkflow
Task<IHttpTriggerWorkflow> ValidateHeaderAsync(HttpRequest req);

Task<IHttpTriggerWorkflow> ValidateQueriesAsync<T>(HttpRequest req, IValidator<T> validator) where T : BaseRequestQueries;

Task<IHttpTriggerWorkflow> BuildRequestUrl<Tresult>(ToastSettings<SmsEndpointSettings> settings, BaseRequestPaths paths = null);
}

/// <summary>
Expand All @@ -40,6 +44,8 @@ public class HttpTriggerWorkflow : IHttpTriggerWorkflow
private RequestHeaderModel _headers;
private BaseRequestQueries _queries;

private string _requestUrl;

/// <inheritdoc />
public async Task<IHttpTriggerWorkflow> ValidateHeaderAsync(HttpRequest req)
{
Expand All @@ -61,5 +67,22 @@ public async Task<IHttpTriggerWorkflow> ValidateQueriesAsync<T>(HttpRequest req,

return await Task.FromResult(this).ConfigureAwait(false);
}

public async Task<IHttpTriggerWorkflow> BuildRequestUrl<Tresult>(ToastSettings<SmsEndpointSettings> settings, BaseRequestPaths paths = null) {
// var paths = new GetMessageRequestPaths() { RequestId = requestId };

var _endpoint = nameof(Tresult);

var requestUrl = new RequestUrlBuilder()
.WithSettings(settings, _endpoint)
.WithHeaders(_headers)
.WithQueries(_queries)
.WithPaths(paths).Build();

this._requestUrl = requestUrl;

return await Task.FromResult(this).ConfigureAwait(false);
}

}
}

0 comments on commit f5d4fbd

Please sign in to comment.