Repository: planetlabs/planet-client-python

Issue:
Add time_range_type parameter to subscription source params
The new parameter is a string and one of "acquired", or "published". This is a new API feature. Previously, "published" was the only option.

Discussion:

Patch:
diff --git a/CHANGES.txt b/CHANGES.txt
index 105eff2..2c6d297 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,8 +1,8 @@
 2.1.0 (TBD)
 
 Added:
-- Support for catalog source publishing stages has been added to
-  subscription_request.catalog_source (#977).
+- Support for catalog source publishing stages (#977) and time range types
+  (#978) have been added to subscription_request.catalog_source.
 - Add the option to get Planetary Variable subscription results as a CSV file
   (#981).
 - A subscription_request.planetary_variable_source function has been added
diff --git a/planet/subscription_request.py b/planet/subscription_request.py
index 4d494ec..75db02a 100644
--- a/planet/subscription_request.py
+++ b/planet/subscription_request.py
@@ -154,6 +154,7 @@ def catalog_source(
     publishing_stages: Optional[Sequence[Literal["preview",
                                                  "standard",
                                                  "finalized"]]] = None,
+    time_range_type: Optional[Literal["acquired", "published"]] = None,
 ) -> dict:
     """Construct a Catalog subscription source.
 
@@ -201,6 +202,7 @@ def catalog_source(
         ...     },
         ...     start_time=datetime(2021, 3, 1),
         ...     publishing_stages=["standard"],
+        ...     time_range_type="acquired",
         ... )
         >>> request = build_request(
         ...     "Standard PSScene Ortho Analytic",
@@ -247,6 +249,9 @@ def catalog_source(
     if publishing_stages:
         parameters['publishing_stages'] = list(set(publishing_stages))
 
+    if time_range_type:
+        parameters['time_range_type'] = time_range_type
+
     return {"type": "catalog", "parameters": parameters}
 
 


Test patch:
diff --git a/tests/unit/test_subscription_request.py b/tests/unit/test_subscription_request.py
index 34cd5fa..1b09afa 100644
--- a/tests/unit/test_subscription_request.py
+++ b/tests/unit/test_subscription_request.py
@@ -394,3 +394,16 @@ def test_catalog_source_publishing_stages(publishing_stages, geom_geojson):
 
     assert source["parameters"]["publishing_stages"] == list(
         set(publishing_stages))
+
+
+def test_catalog_source_time_range_type_acquired(geom_geojson):
+    """Configure 'acquired' time range type for a catalog source."""
+    source = subscription_request.catalog_source(
+        item_types=["PSScene"],
+        asset_types=["ortho_analytic_4b"],
+        geometry=geom_geojson,
+        start_time=datetime(2021, 3, 1),
+        time_range_type="acquired",
+    )
+
+    assert source["parameters"]["time_range_type"] == "acquired"