Settings reference

Settings are created for each connected data source. These can be seen under Access credentials in Connector Builder. It is stored in JSON format and includes all needed information to keep the connection alive - depends on selected authentication provider:

  • Basic - username, password and any other custom field from Auth parameters
  • OAuth1 & OAuth2 will have the needed tokens (access token, refresh token etc.)

Settings could also be used as a cache to store vital information that you might need for running Tasks and Transformations (such as last_synced_time to pass as a Task parameter, total_followers to calculate difference from previous in Transformation etc).

Please note: fields in settings are case sensitive!

Example

Manifest usage

You can use multi-authentication to get user input before starting OAuth2 flow. In example below, we first need to get shopname from user before starting OAuth2 flow. When user enters shop name, it is first stored to settings.

// Settings before OAuth2 flow
{
  "shopname": "databox"
}

In next step, a new popup will be opened for OAuth2 flow. {shopname} in manifest will be replaced from field stored in settings https://{shopname}.myshopify.com/admin/oauth/authorize.

Info:
    name: Shopify
    ...

Auth:
    - provider: basic
      parameters:
       - name: shopname
         label: Shop name
         note: Enter your Shop name e.g. 'MyShopName' and hit Activate, then enter your Account Email and Password.
    - provider: oauth2
      parameters:
        client_id: '<YOUR CLIENT ID>'
        client_secret: '<YOUR CLIENT SECRET>'
        grant_type: 'authorization_code'
        authorization_endpoint: 'https://{shopname}.myshopify.com/admin/oauth/authorize'
        access_token_endpoint: 'https://{shopname}.myshopify.com/admin/oauth/access_token'
        scope:
            - read_customers,read_products,read_orders
        customHeader: X-Shopify-Access-Token
        querystring_for_state: true

API:
    baseUrl: 'https://{shopname}.myshopify.com/'
    operations:
        ...
// Settings after successful authorization
{
  "shopname": "databox",
  "access_token": "035x...e4a34",
  "scope": "read_customers,read_products,read_orders"
}

You can also use settings for replacing parameters in Tasks section.

Note: If the settings field is not set, it will not be replaced!

Transformations usage

Below is an example of how to handle new Twitter followers since last fetch (since official API does not provide us with that info).

...

    private $settings;
    private $storage;

    public function __construct($settings, $storage)
    {
        $this->settings = $settings;
        $this->storage  = $storage;
    }

    private function saveToSettings($field, $value)
    {
        $this->settings[$field] = $value;
        $this->storage->saveSettings($this->settings, true);
    }

    private function getFromSettings($field)
    {
        return isset($this->settings[$field]) ? $this->settings[$field] : null;
    }

    public function followersDifferenceFromPrevious($response)
    {
        $followers = $response['followers'];
        $newFollowers = 0;

        // Retrieve last stored followers value & store current one
        $followersPrev = $this->getFromSettings('followers');
        $this->saveToSettings('followers', $followers);

        if (null !== $followersPrev) {
            $newFollowers = $followers - $followersPrev;
        }

        $push = [[
            'date'       => date('c'),
            '$followers' => $newFollowers
        ]];

        return $push;
    }

...