forked from singer-io/tap-shopify
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from hotgluexyz/fix/retries
improve and mute backoff
- Loading branch information
Showing
4 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
import shopify | ||
|
||
from tap_shopify.streams.base import Stream | ||
from singer import utils | ||
from tap_shopify.streams.base import (Stream, shopify_error_handling) | ||
from tap_shopify.context import Context | ||
|
||
|
||
class Shop(Stream): | ||
name = 'shop' | ||
replication_object = shopify.Shop | ||
|
||
@shopify_error_handling | ||
def api_call_for_shop_data(self): | ||
return self.replication_object.current() | ||
|
||
def get_shop_data(self): | ||
shop_page = [self.api_call_for_shop_data()] | ||
yield from shop_page | ||
|
||
def sync(self): | ||
response = shopify.Shop.current() | ||
return [response.to_dict()] | ||
bookmark = self.get_bookmark() | ||
max_bookmark = bookmark | ||
|
||
for shop in self.get_shop_data(): | ||
|
||
shop_dict = shop.to_dict() | ||
replication_value = utils.strptime_to_utc(shop_dict[self.replication_key]) | ||
|
||
if replication_value >= bookmark: | ||
yield shop_dict | ||
|
||
# update max bookmark if "replication_value" of current shop is greater | ||
if replication_value > max_bookmark: | ||
max_bookmark = replication_value | ||
|
||
self.update_bookmark(utils.strftime(max_bookmark)) | ||
|
||
Context.stream_objects['shop'] = Shop | ||
Context.stream_objects['shop'] = Shop |