Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harshith/test pr 7063 #7382

Merged
merged 18 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sourceDefinitionId": "9da77001-af33-4bcd-be46-6252bf9342b9",
"name": "Shopify",
"dockerRepository": "airbyte/source-shopify",
"dockerImageTag": "0.1.19",
"dockerImageTag": "0.1.21",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/shopify"
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
- name: Shopify
sourceDefinitionId: 9da77001-af33-4bcd-be46-6252bf9342b9
dockerRepository: airbyte/source-shopify
dockerImageTag: 0.1.19
dockerImageTag: 0.1.21
documentationUrl: https://docs.airbyte.io/integrations/sources/shopify
sourceType: api
- name: Short.io
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-shopify/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ COPY source_shopify ./source_shopify
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.19
LABEL io.airbyte.version=0.1.21
LABEL io.airbyte.name=airbyte/source-shopify
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@
},
"discount_codes": {
"updated_at": "2024-07-08T05:40:38-07:00"
},
"locations": {
"updated_at": "2024-07-08T05:40:38-07:00"
},
"inventory_levels": {
"updated_at": "2024-07-08T05:40:38-07:00"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@
"sync_mode": "incremental",
"cursor_field": ["updated_at"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "locations",
"json_schema": {},
"supported_sync_modes": ["full_refresh"],
"source_defined_cursor": true,
"default_cursor_field": ["id"]
},
"sync_mode": "full_refresh",
"cursor_field": ["id"],
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "inventory_levels",
"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"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@
},
"discount_codes": {
"updated_at": "2021-09-10T06:48:10-07:00"
},
"locations": {
"updated_at": "2021-09-10T06:48:10-07:00"
},
"inventory_levels": {
"updated_at": "2021-09-10T06:48:10-07:00"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "object",
"properties": {
"available": {
"type": ["null", "integer"]
},
"inventory_item_id": {
"type": ["null", "integer"]
},
"location_id": {
"type": ["null", "integer"]
},
"updated_at": {
"type": ["null", "string"],
"format": "date-time"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"type": "object",
"properties": {
"active": {
"type": ["null", "boolean"]
},
"address1": {
"type": ["null", "string"]
},
"address2": {
"type": ["null", "string"]
},
"city": {
"type": ["null", "string"]
},
"country": {
"type": ["null", "string"]
},
"country_code": {
"type": ["null", "string"]
},
"created_at": {
"type": ["null", "string"],
"format": "date-time"
},
"id": {
"type": ["null", "integer"]
},
"legacy": {
"type": ["null", "boolean"]
},
"name": {
"type": ["null", "string"]
},
"phone": {
"type": ["null", "string"]
},
"province": {
"type": ["null", "string"]
},
"updated_at": {
"type": ["null", "string"],
"format": "date-time"
},
"zip": {
"type": ["null", "string"]
},
"localized_country_name": {
"type": ["null", "string"]
},
"localized_province_name": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,46 @@ def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
return f"price_rules/{price_rule_id}/{self.data_field}.json"


class Locations(ShopifyStream):

"""
The location API does not support any form of filtering.
https://shopify.dev/api/admin-rest/2021-07/resources/location
Therefore, only FULL_REFRESH mode is supported.
"""

data_field = "locations"

def path(self, **kwargs):
return f"{self.data_field}.json"


class InventoryLevels(ChildSubstream):
parent_stream_class: object = Locations
slice_key = "location_id"
cursor_field = "updated_at"

data_field = "inventory_levels"

def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
location_id = stream_slice["location_id"]
return f"locations/{location_id}/{self.data_field}.json"

def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
records_stream = super().parse_response(response, **kwargs)

def generate_key(record):
record.update({"id": "|".join((str(record.get("location_id", "")), str(record.get("inventory_item_id", ""))))})
return record

# associate the surrogate key
yield from map(
generate_key,
records_stream,
)


class SourceShopify(AbstractSource):
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:

Expand Down Expand Up @@ -365,4 +405,6 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
Pages(config),
PriceRules(config),
DiscountCodes(config),
Locations(config),
InventoryLevels(config),
]
4 changes: 4 additions & 0 deletions docs/integrations/sources/shopify.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ This Source is capable of syncing the following core Streams:
* [Transactions](https://help.shopify.com/en/api/reference/orders/transaction)
* [Pages](https://help.shopify.com/en/api/reference/online-store/page)
* [Price Rules](https://help.shopify.com/en/api/reference/discounts/pricerule)
* [Locations](https://shopify.dev/api/admin-rest/2021-10/resources/location)
* [InventoryLevels](https://shopify.dev/api/admin-rest/2021-10/resources/inventorylevel)

#### NOTE:

Expand Down Expand Up @@ -95,6 +97,8 @@ This connector support both: `OAuth 2.0` and `API PASSWORD` (for private applica

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.21 | 2021-10-14 | [7382](https://github.com/airbytehq/airbyte/pull/7382) | Fixed `InventoryLevels` primary key |
| 0.1.20 | 2021-10-14 | [7063](https://github.com/airbytehq/airbyte/pull/7063) | Added `Location` and `InventoryLevels` as streams |
| 0.1.19 | 2021-10-11 | [6951](https://github.com/airbytehq/airbyte/pull/6951) | Added support of `OAuth 2.0` authorisation option |
| 0.1.18 | 2021-09-21 | [6056](https://github.com/airbytehq/airbyte/pull/6056) | Added `pre_tax_price` to the `orders/line_items` schema |
| 0.1.17 | 2021-09-17 | [5244](https://github.com/airbytehq/airbyte/pull/5244) | Created data type enforcer for converting prices into numbers |
Expand Down