Skip to content

Commit

Permalink
Prune variant render and sender API requests (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
nealrichardson authored Jul 11, 2024
1 parent c6b49ef commit b0a87b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
16 changes: 5 additions & 11 deletions R/variant.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ Variant <- R6::R6Class(
url <- unversioned_url("variants", self$get_variant()$id, "sender")
self$get_connect()$POST(
path = url,
body = list(
email = arg_match(to)
query = list(
email = arg_match(to),
rendering_id = self$get_variant()$rendering_id
)
)
},
Expand Down Expand Up @@ -93,15 +94,8 @@ Variant <- R6::R6Class(
#' @description Render this variant.
render = function() {
warn_experimental("render")
# TODO: why both in query AND in body?
path <- unversioned_url("variants", self$get_variant()$id, "render?email=none&activate=true")
res <- self$get_connect()$POST(
path = path,
body = list(
email = "none",
activate = TRUE
)
)
path <- unversioned_url("variants", self$get_variant()$id, "render")
res <- self$get_connect()$POST(path)

# add the content guid and variant key
content_guid <- self$get_content()$guid
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/__api__/applications/f2f37341/variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[
{
"id": "12345",
"key": "12345"
"key": "12345",
"rendering_id": "12"
}
]
9 changes: 4 additions & 5 deletions tests/testthat/test-variant.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ with_mock_api({

expect_POST(
variant$send_mail(),
"https://connect.example/__api__/variants/12345/sender",
'{"email":"me"}'
"https://connect.example/__api__/variants/12345/sender?email=me&rendering_id=12",
"{}"
)

expect_GET(
Expand All @@ -37,11 +37,10 @@ with_mock_api({
# (but the API is not documented). Function does not look like it would
# send valid JSON in the POST body

# See code comment in this function: does it really need query params and body?
expect_POST(
variant$render(),
"https://connect.example/__api__/variants/12345/render?email=none&activate=true",
'{"email":"none","activate":true}'
"https://connect.example/__api__/variants/12345/render",
"{}"
)

expect_GET(
Expand Down

0 comments on commit b0a87b0

Please sign in to comment.