///|
pub fn canonical_body(request : WebhookRequest) -> String {
request.body
}
///|
pub fn canonical_timestamp(
request : WebhookRequest,
profile : ProviderProfile,
) -> String {
provider_timestamp_text(request, profile)
}
///|
pub fn canonical_event(
request : WebhookRequest,
profile : ProviderProfile,
) -> String {
provider_event_type(request, profile)
}
///|
pub fn canonical_id(
request : WebhookRequest,
profile : ProviderProfile,
) -> String {
provider_event_id(request, profile)
}
///|
pub fn canonical_base(
request : WebhookRequest,
profile : ProviderProfile,
) -> String {
let builder = StringBuilder::new()
builder.write_string(profile.name)
builder.write_string("\n")
builder.write_string(method_name(request.http_method))
builder.write_string("\n")
builder.write_string(request.path)
builder.write_string("\n")
builder.write_string(canonical_timestamp(request, profile))
builder.write_string("\n")
builder.write_string(canonical_event(request, profile))
builder.write_string("\n")
builder.write_string(canonical_id(request, profile))
builder.write_string("\n")
builder.write_string(canonical_body(request))
builder.to_string()
}
///|
pub fn canonical_debug_lines(
request : WebhookRequest,
profile : ProviderProfile,
) -> Array[String] {
[
"provider=" + profile.name,
"method=" + method_name(request.http_method),
"path=" + request.path,
"timestamp=" + canonical_timestamp(request, profile),
"event=" + canonical_event(request, profile),
"id=" + canonical_id(request, profile),
"body=" + request.body,
]
}
///|
pub fn canonical_debug_text(
request : WebhookRequest,
profile : ProviderProfile,
) -> String {
join_lines(canonical_debug_lines(request, profile))
}