A Singer tap for extracting data from the Swell Rewards API.
Since package dependencies tend to conflict between various taps and targets, Singer recommends installing taps and targets into their own isolated virtual environments:
$ cd tap-swellrewards
$ python3 -m venv ~/.venvs/tap-swellrewards
$ source ~/.venvs/tap-swellrewards/bin/activate
$ pip3 install tap-swellrewards # or pip3 install .
$ deactivate
$ python3 -m venv ~/.venvs/target-stitch
$ source ~/.venvs/target-stitch/bin/activate
$ pip3 install target-stitch
$ deactivate
The tap accepts a JSON-formatted configuration file as arguments. This configuration file has three required fields:
api_key
: A valid Swell Rewards API Key (found in the Settings of your Swell account)api_guid
: A valid Swell Rewards API GUID (found in the Settings of your Swell account)start_date
Thestart_date
parameter determines the starting date for the last registered customer activity within the Yotpo loyalty and rewards system e.g. purchase, redemption, etc. For example, pass a value of2019-01-01
to fetch active customers since January 1st, 2019.
An bare-bones SwellRewards confirguration may file may look like the following:
{
"api_key": "abaoEFoiahwef12425",
"api_guid": "YAYAHbafoiafoH235",
"start_date": "2019-01-21"
}
The current version of the tap syncs one distinct Stream:
Customers
: (Endpoint)
Singer taps describe the data that a stream supports via a Discovery process. You can run the SwellRewards tap in Discovery mode by passing the --discover
flag at runtime:
$ ~/.venvs/tap-swellrewards/bin/tap-swellrewards --config=config/swellrewards.config.json --discover
The tap will generate a Catalog to stdout. To pass the Catalog to a file instead, simply redirect it to a file:
$ ~/.venvs/tap-swellrewards/bin/tap-swellrewards --config=config/swellrewards.config.json --discover > catalog.json
Running a tap in Sync mode will extract data from the various Streams. In order to run a tap in Sync mode, pass a configuration file and catalog file:
$ ~/.venvs/tap-swellrewards/bin/tap-swellrewards --config=config/swellrewards.config.json --catalog=catalog.json
The tap will emit occasional State messages. You can persist State between runs by redirecting State to a file:
$ ~/.venvs/tap-swellrewards/bin/tap-swellrewards --config=config/swellrewards.config.json --catalog=catalog.json >> state.json
$ tail -1 state.json > state.json.tmp
$ mv state.json.tmp state.json
To pick up from where the tap left off on subsequent runs, simply supply the State file at runtime:
$ ~/.venvs/tap-swellrewards/bin/tap-swellrewards --config=config/swellrewards.config.json --catalog=catalog.json --state=state.json >> state.json
$ tail -1 state.json > state.json.tmp
$ mv state.json.tmp state.json
You can also send the output of the tap to Stitch Data for loading into the data warehouse. To do this, first create a JSON-formatted configuration for Stitch. This configuration file has two required fields:
client_id
: The ID associated with the Stitch Data account you'll be sending data to.token
The token associated with the specific Import API integration within the Stitch Data account.
An example configuration file will look as follows:
{
"client_id": 1234,
"token": "foobarfoobar"
}
Once the configuration file is created, simply pipe the output of the tap to the Stitch Data target and supply the target with the newly created configuration file:
$ ~/.venvs/tap-swellrewards/bin/tap-swellrewards --config=config/swellrewards.config.json --catalog=catalog.json --state=state.json | ~/.venvs/target-stitch/bin/target-stitch --config=config/stitch.config.json >> state.json
$ tail -1 state.json > state.json.tmp
$ mv state.json.tmp state.json
Copyright © 2020 Stitch