diff --git a/tap_veeqo/client.py b/tap_veeqo/client.py index 44a0c98..baef61e 100644 --- a/tap_veeqo/client.py +++ b/tap_veeqo/client.py @@ -13,7 +13,7 @@ class VeeqoStream(RESTStream): """Veeqo stream class.""" url_base = "https://api.veeqo.com" - primary_keys = ("id",) + primary_keys: tuple[str, ...] = ("id",) page_size = 1000 @property diff --git a/tap_veeqo/schemas/product_property.py b/tap_veeqo/schemas/product_property.py new file mode 100644 index 0000000..e70abce --- /dev/null +++ b/tap_veeqo/schemas/product_property.py @@ -0,0 +1,8 @@ +"""Schema definitions for product property objects.""" + +from singer_sdk import typing as th + +ProductPropertyObject = th.PropertiesList( + th.Property("id", th.IntegerType), + th.Property("name", th.StringType), +) diff --git a/tap_veeqo/schemas/product_property_specific.py b/tap_veeqo/schemas/product_property_specific.py new file mode 100644 index 0000000..8b58e9b --- /dev/null +++ b/tap_veeqo/schemas/product_property_specific.py @@ -0,0 +1,10 @@ +"""Schema definitions for product property specific objects.""" + +from singer_sdk import typing as th + +ProductPropertySpecificObject = th.PropertiesList( + th.Property("id", th.IntegerType), + th.Property("product_property_id", th.IntegerType), + th.Property("product_property_name", th.StringType), + th.Property("value", th.StringType), +) diff --git a/tap_veeqo/schemas/variant_property_specific.py b/tap_veeqo/schemas/variant_property_specific.py new file mode 100644 index 0000000..ba71925 --- /dev/null +++ b/tap_veeqo/schemas/variant_property_specific.py @@ -0,0 +1,11 @@ +"""Schema definitions for variant property specific objects.""" + +from singer_sdk import typing as th + +VariantPropertySpecificObject = th.PropertiesList( + th.Property("id", th.IntegerType), + th.Property("product_specific_id", th.IntegerType), + th.Property("product_property_id", th.IntegerType), + th.Property("product_property_name", th.StringType), + th.Property("value", th.StringType), +) diff --git a/tap_veeqo/streams.py b/tap_veeqo/streams.py index cf2857f..c07e9db 100644 --- a/tap_veeqo/streams.py +++ b/tap_veeqo/streams.py @@ -11,11 +11,14 @@ from tap_veeqo.schemas.order import OrderObject from tap_veeqo.schemas.product import ProductObject from tap_veeqo.schemas.product_brand import ProductBrandObject +from tap_veeqo.schemas.product_property import ProductPropertyObject +from tap_veeqo.schemas.product_property_specific import ProductPropertySpecificObject from tap_veeqo.schemas.purchase_order import PurchaseOrderObject from tap_veeqo.schemas.sellable import SellableObject from tap_veeqo.schemas.store import StoreObject from tap_veeqo.schemas.supplier import SupplierObject from tap_veeqo.schemas.tag import TagObject +from tap_veeqo.schemas.variant_property_specific import VariantPropertySpecificObject from tap_veeqo.schemas.warehouse import WarehouseObject @@ -60,6 +63,10 @@ class ProductsStream(VeeqoStream): replication_key = "updated_at" schema = ProductObject.to_dict() + @override + def get_child_context(self, record, context): + return {"id": record["id"]} + class ProductBrandsStream(VeeqoStream): """Define product brands stream.""" @@ -69,6 +76,31 @@ class ProductBrandsStream(VeeqoStream): schema = ProductBrandObject.to_dict() +class ProductPropertiesStream(VeeqoStream): + """Define product properties stream.""" + + name = "product_properties" + path = "/product_properties" + schema = ProductPropertyObject.to_dict() + + +class ProductPropertySpecificsStream(VeeqoStream): + """Define product property specifics stream.""" + + name = "product_property_specifics" + parent_stream_type = ProductsStream + path = "/products/{id}/product_property_specifics" + schema = ProductPropertySpecificObject.to_dict() + primary_keys = ("id", "product_property_id") + + +class ProductOptionSpecificsStream(ProductPropertySpecificsStream): + """Define product option specifics stream.""" + + name = "product_option_specifics" + path = "/products/{id}/product_option_specifics" + + class ProductTagsStream(VeeqoStream): """Define product tags stream.""" @@ -102,6 +134,20 @@ class SellablesStream(VeeqoStream): path = "/sellables" schema = SellableObject.to_dict() + @override + def get_child_context(self, record, context): + return {"id": record["id"]} + + +class VariantPropertySpecificsStream(VeeqoStream): + """Define variant property specifics stream.""" + + name = "variant_property_specifics" + parent_stream_type = SellablesStream + path = "/product_variants/{id}/variant_property_specifics" + schema = VariantPropertySpecificObject.to_dict() + primary_keys = ("id", "product_specific_id", "product_property_id") + class StoresStream(VeeqoStream): """Define stores stream.""" diff --git a/tap_veeqo/tap.py b/tap_veeqo/tap.py index ab33f78..27fe747 100644 --- a/tap_veeqo/tap.py +++ b/tap_veeqo/tap.py @@ -15,9 +15,13 @@ streams.OrdersStream, streams.ProductsStream, streams.ProductBrandsStream, + streams.ProductPropertiesStream, + streams.ProductPropertySpecificsStream, + streams.ProductOptionSpecificsStream, streams.ProductTagsStream, streams.PurchaseOrdersStream, streams.SellablesStream, + streams.VariantPropertySpecificsStream, streams.StoresStream, streams.SuppliersStream, streams.TagsStream,