From b0a87b0ef27284af762c318e8e9c757d56350352 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 11 Jul 2024 16:48:03 -0400 Subject: [PATCH] Prune variant render and sender API requests (#277) --- R/variant.R | 16 +++++----------- .../__api__/applications/f2f37341/variants.json | 3 ++- tests/testthat/test-variant.R | 9 ++++----- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/R/variant.R b/R/variant.R index dd39d593..bf976002 100644 --- a/R/variant.R +++ b/R/variant.R @@ -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 ) ) }, @@ -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 diff --git a/tests/testthat/__api__/applications/f2f37341/variants.json b/tests/testthat/__api__/applications/f2f37341/variants.json index 739c796e..b3150904 100644 --- a/tests/testthat/__api__/applications/f2f37341/variants.json +++ b/tests/testthat/__api__/applications/f2f37341/variants.json @@ -3,6 +3,7 @@ [ { "id": "12345", - "key": "12345" + "key": "12345", + "rendering_id": "12" } ] \ No newline at end of file diff --git a/tests/testthat/test-variant.R b/tests/testthat/test-variant.R index b3ee7e3f..6dadca17 100644 --- a/tests/testthat/test-variant.R +++ b/tests/testthat/test-variant.R @@ -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( @@ -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(