Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

Configuration - OneStock [internal]

To correctly use the connector you’ll have to configure your OneStock instance with few things:

ACLs - mandatory

The connector needs the bellow ACLs to run correctly.

You will have to add those rules in your Configuration > Security > ACL rules

Code Block
{
  "policies": [
    {
      "actions": [
        "GET",
        "POST",
        "PATCH",
        "DELETE"
      ],
      "description": "allow *",
      "effect": "allow",
      "resources": [
        "orders<.*>",
        "line_items<.*>",
        "parcels<.*>",
        "pieces<.*>",
        "check",
        "configurations<.*>",
        "delivery_configs",
        "delivery_promises",
        "items",
        "translators",
        "requests<.*>",
        "sales_channels",
        "webhooks<.*>",
        "rulesets",
        "ruleset_chainings<.*>",
        "endpoints",
        "stock_export"
      ],
      "subjects": [
        "api_user"
      ]
    }
  ]
}

You then have to create an API user for the client an transfer him the username and password.

Stock export - optional

If you are using the connector to synchronise stock you will need to configure :

  • an SFTP server on OneStock for stock export.

  • a translator

  • webhook topic

  • a stock export full and diff key request

SFTP

You can set this up from the Configuration > Data Exchange page.

Exemple of configuration:

Code Block
{
  "sftp": {
    "shopify_sftp": {
      "address": "sftp4-preprod.onestock-retail.com:22",
      "public_key": "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKEoi/03XRG7kcd3yVd+thSczTVw7n5dDtxCD30E3eFKC+4reSp1S1JnJr3GQeknGXtqym6L7d5g962pJWe5dBY=",
      "user": "shopify-sftp",
      "working_directory": "/qualif/shopify"
    }
  },
  "default_sftp_name": "shopify_sftp"
}

If the SFTP is hosted by OneStock, you’ll have to ask IT for the different values to input here

Note

Don’t forget the port :22 at the end of your address parameter

Translator

The translator for stock export to the shopify connector needs to be similar to this one : the connector will only read stock files in csv with semi colon separator and with item_id and quantity headers

Example:

Code Block
{
    "name": "export_stock_unified",
    "headers": [
        "item_id",
        "quantity"
    ],
    "omit_headers": false,
    "separator": ";",
    "qualifier": "\"",
    "end_line": "\n",
    "transformators": {
        "item_id": "item_id",
        "quantity": {
            "type": "max_int",
            "fields": [
                {
                    "type": "to_int",
                    "fields": [
                        "raw:0"
                    ]
                },
                "quantity"
            ]
        }
    }
}

Webhook topics

A stock_export_completed webhook topic needs to be created.

To do so, you have to create a notification on the Configuration > Outbound Messages > Notifications page

Code Block
"stock_export_completed": {
    "media": {
      "webhook_topic": [
        "stock_export_completed"
      ]
    },
    "time_type": "duration",
    "time_value": "0s"
  }

Then you have to create the webhook topic

POST /webhook_topics

Code Block
{
  "site_id": "{{site_id}}",
  "token": "{{token}}",
  "webhook_topic": {
    "ordered": true,
    "topic": "stock_export_completed"
  }
}

Key requests

Define your usual unify stock export request for full and diff. The connector has a configuration page to select the stock request that will be used for both.

The connector will call the POST /stock_export api with the configured values for the request names and SFTP. Once the file is available, it will receive the stock_export_completed webhook and fetch the file on the sftp server to update stock on shopify.

Installation

The OneStock connector is available on the Shopify marketplace. To install the OneStock connector, you need a Shopify Plus shop.

...