How do I get information about the DistributionGates?
  • 29 Jun 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

How do I get information about the DistributionGates?

  • Dark
    Light

Article Summary

Your software can communicate with the DistributionGates connected to your DistributionChannel.

You get the information you need to authenticate using the connectedDistributionGates query.

Each distributor has its own DistributionGate. A Distributor can create a connection between your software and their DistributionGate; your software then takes the role of DistributionChannel and can communicate with the DistributionGate

Request connected DistributionGates

First, you need a token for our BusinessManager API. With the token you can send a request to get the connected DistributionGates.

For tests: http://bm.stage.promaterial.com/graphql

curl --request POST \
--url http://bm.stage.promaterial.com/graphql \
--header 'authorization: Bearer <your token>' \
--header 'content-type: application/json' \
--data '{"query":"query q1 {\n connectedDistributionGates \
{\n name\n domain\n code\n auth0Domain\n auth0ClientId\n \
auth0ClientSecret\n subtype\n defaultSite\n defaultStore\n \
defaultOrderDate {\n value\n type\n saturdaysAllowed\n }\n \
orderTypes {\n name\n mapping\n }\n \
distributionChannelId\n }\n}\n","operationName":"q1"}'

Answer:

{
  "data": {
    "connectedDistributionGates": [
      {
        "name": "<DistributionGate friendly name>",
        "domain": "<URl for API>",
        "code": "<DistributionGate code>",
        "auth0Domain": "<Domain for authorization>",
        "auth0ClientId": "<Client ID>",
        "auth0ClientSecret": "<Client Secret>",
        "subtype": "<PERSONAL or ANONYMOUS>",
        "defaultSite": "<Default Site>",
        "defaultStore": "<Default Store>",
        "defaultOrderDate": {
          "value": "<Date like YYYY-MM-DD or offset in Format +dd>",
          "type": "<ABSOLUTE or RELATIVE>",
	  "saturdaysAllowed": <bool>
	 },
        "orderTypes": [
          {
            "name": "delivery",
            "mapping": "<Code for delivery>"
          },
          {
            "name": "pickup",
            "mapping": "<Code for pickup>"
          }
        ]
      }
    ],
    "distributionChannelId": <ID of your software>
  }
}

auth0

You need the fields starting with "auth0" for the authorization with the DistributionGate.

subtype

Depending on the subtype, you have to request the token from auth0 differently. You can get information for the same DistributionGate twice, one tome with subtype = personal and one time with subtype = anonymous.

PERSONAL
You communicate with the DistributionGate as a real user and you will get prices for this user. You have to send a username and a password to get a token. How the get a token for a username and password is described in this article.

ANONYMOUS
You communicate with the DistributionGate as a machine / as an anonymous user. You will get some general prices. The token can be requested like this:

curl --request POST \
--url https://promaterial.eu.auth0.com/oauth/token \
--header 'content-type: application/json' \
--data '{
"client_id":"<Client ID>",
"client_secret":"<Client Secret>",
"audience":"http://mdg.promaterial.com/api",
"grant_type":"client_credentials"
}'

defaultSite

The defaultSite (sometimes called "project"). Prices can differ for different sites. Use the defaultSite if you don't target a specific site.

defaultStore

The distributor can have more than one shop. The default store is needed for billing.

orderTypes

"Pickup" und "delivery" have different codes for different distributors.

distributionChannelId

The ID of your software for this DistributionGate.


Was this article helpful?