Skip to content

singer-io/tap-swellrewards

Repository files navigation

tap-swellrewards

License: GPL v3 Python Versions

A Singer tap for extracting data from the Swell Rewards API.

Installation

Since package dependencies tend to conflict between various taps and targets, Singer recommends installing taps and targets into their own isolated virtual environments:

Install SwellRewards Tap

$ cd tap-swellrewards
$ python3 -m venv ~/.venvs/tap-swellrewards
$ source ~/.venvs/tap-swellrewards/bin/activate
$ pip3 install tap-swellrewards # or pip3 install .
$ deactivate

Install Singer Target

$ python3 -m venv ~/.venvs/target-stitch
$ source ~/.venvs/target-stitch/bin/activate
$ pip3 install target-stitch
$ deactivate

Configuration

The tap accepts a JSON-formatted configuration file as arguments. This configuration file has three required fields:

  1. api_key: A valid Swell Rewards API Key (found in the Settings of your Swell account)
  2. api_guid: A valid Swell Rewards API GUID (found in the Settings of your Swell account)
  3. start_date The start_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 of 2019-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"
}

Streams

The current version of the tap syncs one distinct Stream:

  1. Customers: (Endpoint)

Discovery

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

Sync Locally

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

Sync to Stitch

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:

  1. client_id: The ID associated with the Stitch Data account you'll be sending data to.
  2. 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

About

A Singer tap for extracting Swell Rewards data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages