Skip to content

Commit

Permalink
🎉 Source Cart.com: add order_items stream (#5582)
Browse files Browse the repository at this point in the history
* add order_items stream

* run format

* add order_items in integration_tests
  • Loading branch information
marcosmarxm authored Aug 24, 2021
1 parent 9dd05d4 commit 93032a8
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 7 deletions.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-cart/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.name=airbyte/source-cart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"customers_cart": { "updated_at": "2051-07-01T08:59:28.457-05:00" },
"orders": { "updated_at": "2051-07-01T08:59:28.457-05:00" },
"order_payments": { "updated_at": "2051-07-01T08:59:28.457-05:00" },
"order_items": { "updated_at": "2051-07-01T08:59:28.457-05:00" },
"products": { "updated_at": "2051-07-01T08:59:28.457-05:00" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
"cursor_field": ["updated_at"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "order_items",
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"],
"source_defined_cursor": true,
"default_cursor_field": ["updated_at"]
},
"sync_mode": "incremental",
"cursor_field": ["updated_at"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "products",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"order_id": {
"type": ["integer", "null"]
},
"product_id": {
"type": ["integer", "null"]
},
"item_number": {
"type": ["string", "null"]
},
"item_name": {
"type": ["string", "null"]
},
"price": {
"type": ["number", "null"]
},
"cost": {
"type": ["number", "null"]
},
"quantity": {
"type": ["integer", "null"]
},
"is_discount_item": {
"type": ["boolean", "null"]
},
"weight": {
"type": ["number", "null"]
},
"is_taxable": {
"type": ["boolean", "null"]
},
"weigh_unit": {
"type": ["string", "null"]
},
"parent_order_item_id": {
"type": ["integer", "null"]
},
"is_quantity_bound_to_parent": {
"type": ["boolean", "null"]
},
"updated_at": {
"type": ["string", "null"]
},
"created_at": {
"type": ["string", "null"]
},
"height": {
"type": ["number", "null"]
},
"length": {
"type": ["number", "null"]
},
"width": {
"type": ["number", "null"]
},
"size_unit": {
"type": ["string", "null"]
},
"admin_comments": {
"type": ["string", "null"]
},
"do_not_discount": {
"type": ["boolean", "null"]
},
"line_item_note": {
"type": ["string", "null"]
},
"gift_message": {
"type": ["string", "null"]
},
"delivery_date": {
"type": ["string", "null"]
},
"is_subscription_product": {
"type": ["boolean", "null"]
},
"warehouse_id": {
"type": ["integer", "null"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.http.auth import HttpAuthenticator

from .streams import CustomersCart, OrderPayments, Orders, Products
from .streams import CustomersCart, OrderItems, OrderPayments, Orders, Products


class CustomHeaderAuthenticator(HttpAuthenticator):
Expand Down Expand Up @@ -63,4 +63,4 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
authenticator = CustomHeaderAuthenticator(access_token=config["access_token"])
args = {"authenticator": authenticator, "start_date": config["start_date"], "store_name": config["store_name"]}
return [CustomersCart(**args), Orders(**args), OrderPayments(**args), Products(**args)]
return [CustomersCart(**args), Orders(**args), OrderPayments(**args), OrderItems(**args), Products(**args)]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"title": "Cart Spec",
"type": "object",
"required": ["access_token", "start_date", "store_name"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"access_token": {
"type": "string",
Expand All @@ -17,7 +17,7 @@
"type": "string",
"description": "The date from which you'd like to replicate the data",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
"examples": "2021-01-01T00:00:00Z"
"examples": ["2021-01-01T00:00:00Z"]
},
"store_name": {
"type": "string",
Expand Down
11 changes: 11 additions & 0 deletions airbyte-integrations/connectors/source-cart/source_cart/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ def path(self, **kwargs) -> str:
return "order_payments"


class OrderItems(IncrementalCartStream):
"""
Docs: https://developers.cart.com/docs/rest-api/restapi.json/paths/~1order_items/get
"""

data_field = "items"

def path(self, **kwargs) -> str:
return "order_items"


class Products(IncrementalCartStream):
"""
Docs: https://developers.cart.com/docs/rest-api/restapi.json/paths/~1products/get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
Contacts,
{
"data": [],
"pages": {"next": {"starting_after": "1HaSB+xrOyyMXAkS/c1RteCL7BzOzTvYjmjakgTergIH31eoe2v4/sbLsJWP"
"\nIncfQLD3ouPkZlCwJ86F\n"}},
"pages": {
"next": {"starting_after": "1HaSB+xrOyyMXAkS/c1RteCL7BzOzTvYjmjakgTergIH31eoe2v4/sbLsJWP" "\nIncfQLD3ouPkZlCwJ86F\n"}
},
},
{"starting_after": "1HaSB+xrOyyMXAkS/c1RteCL7BzOzTvYjmjakgTergIH31eoe2v4/sbLsJWP\nIncfQLD3ouPkZlCwJ86F\n"},
),
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/cart.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ Please follow these [steps](https://developers.cart.com/docs/rest-api/docs/READM

| Version | Date | Pull Request | Subject |
| :------ | :-------- | :----- | :------ |
| 0.1.2 | 2021-08-23 | [1111](https://github.com/airbytehq/airbyte/pull/1111) | Add `order_items` stream |
| 0.1.0 | 2021-06-08 | [4574](https://github.com/airbytehq/airbyte/pull/4574) | Initial Release |

0 comments on commit 93032a8

Please sign in to comment.