Skip to content

Commit

Permalink
add metafields streams (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyn4 authored Sep 27, 2024
1 parent ee59e26 commit 7eb5d20
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions tap_lightspeed/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ class OrderLinesStream(LightspeedStream):
).to_dict()


class OrderMetafieldsStream(LightspeedStream):
"""Define custom stream."""

name = "order_metafields"
path = "/orders/{order_id}/metafields.json"
parent_stream_type = OrdersStream
records_jsonpath = "$.orderMetafields[*]"

schema = th.PropertiesList(
th.Property("id", th.IntegerType),
th.Property("createdAt", th.DateTimeType),
th.Property("updatedAt", th.DateTimeType),
th.Property("key", th.StringType),
th.Property("value", th.StringType),
th.Property("order_id", th.IntegerType),
).to_dict()


class ShipmentsLinesStream(LightspeedStream):
"""Define custom stream."""

Expand Down Expand Up @@ -418,6 +436,24 @@ class ProductsImagesStream(LightspeedStream):
).to_dict()


class ProductsMetafieldsStream(LightspeedStream):
"""Define custom stream."""

name = "products_metafields"
path = "/products/{product_id}/metafields.json"
parent_stream_type = ProductsStream
records_jsonpath = "$.productMetafields[*]"

schema = th.PropertiesList(
th.Property("id", th.IntegerType),
th.Property("createdAt", th.DateTimeType),
th.Property("updatedAt", th.DateTimeType),
th.Property("key", th.StringType),
th.Property("value", th.StringType),
th.Property("product_id", th.IntegerType),
).to_dict()


class CategoriesStream(LightspeedStream):
"""Define custom stream."""

Expand Down
2 changes: 1 addition & 1 deletion tap_lightspeed/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def discover_streams(self) -> List[Stream]:
return [
cls(self)
for _, cls in inspect.getmembers(streams, inspect.isclass)
if cls.__module__ == "tap_lightspeed.streams"
if cls.__module__ == "tap_lightspeed.streams" and hasattr(cls, "name")
]


Expand Down

0 comments on commit 7eb5d20

Please sign in to comment.