Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

PUT a restaurant

Method: PUT

Authorization:

  • Token: partners api secret (dynamodb)

  • Example: 6dfnPNxMuF1MA5zi5iDY

Header:

[{"key":"x-ui-region","value":"ES","description":null,"type":"text","enabled":true}]

Body:

Code Block
{
    "address": {
        "address1": "Calle de Bravo Murillo 100, 28850",
        "address2": "",
        "city": "Madrid",
        "country": "Spain",
        "postalCode": "28020",
        "stateProvince": "",
        "stateProvinceShort": ""
    },
    "coordinates": {
        "latitude": 40.447520,
        "longitude": -3.703660
    },
    "menuItems": [{"plu":"940270","price": 2500}],
    "restaurantName": "CIT Shop Rapha",
    "storeId": "7788",
    "timezone": "Europe/Madrid"
}

Image Added

Generate an integrationId and a partnerId

Code Block
$ ts-node ./scripts/generate-jwt.ts
prompt: awsRegion:  (eu-central-1) (node:21731) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy
(Use `node --trace-warnings ...` to show where the warning was created)
eu-west-3
prompt: stage:  (dev) 
prompt: brand:  (PLK) 
prompt: 2-letter region code:  ES
prompt: Partner name (will be used as JWT sub claim):  shoprapha
prompt: Usage plan (basic or premium):  (basic) 
prompt: API Key (leave blank to auto generate):  
prompt: Integration Id (leave blank to auto generate):  
prompt: Partner Id (leave blank to auto generate):  
Input received:
┌───────────────┬────────────────────────────────────────┐
│    (index)    │                 Values                 │
├───────────────┼────────────────────────────────────────┤
│   awsRegion   │              'eu-west-3'               │
│     stage     │                 'dev'                  │
│     brand     │                 'PLK'                  │
│    region     │                  'ES'                  │
│      sub      │              'shoprapha'               │
│   usagePlan   │                'basic'                 │
│    apiKey     │                   ''                   │
│ integrationId │ 'dd58dca8-abca-4722-9893-e39dbde8f8f1' │
│   partnerId   │ 'db5c3402-50e1-433a-876b-c10ddc439e8f' │
└───────────────┴────────────────────────────────────────┘
===API Gateway: Found===
{
  id: 'x4rki34mgd',
  name: 'dev-plk-partners-api-apigw',
  description: 'REST API Gateway for Partners API',
  createdDate: 2022-05-10T12:47:01.000Z,
  binaryMediaTypes: [ '*/*' ],
  apiKeySource: 'AUTHORIZER',
  endpointConfiguration: { types: [ 'REGIONAL' ] },
  tags: {
    app: 'partners-api',
    brand: 'plk',
    env: 'dev',
    'rbi:brand': 'plk',
    'rbi:service': 'partners-api',
    'rbi:source': 'terraform',
    'rbi:stage': 'dev',
    service: 'partners-api',
    stage: 'dev',
    version: 'ca8dbd0e'
  },
  disableExecuteApiEndpoint: false
}
===API Key: Created===
{
  id: 'jemf6c7rc8',
  value: 'Kw9EkBW6Yf6KpojDNqZq48FhRRhTe6yp7R1ygqD7',
  name: 'dev-plk-partners-api-shoprapha',
  description: 'shoprapha|db5c3402-50e1-433a-876b-c10ddc439e8f|dd58dca8-abca-4722-9893-e39dbde8f8f1',
  enabled: true,
  createdDate: 2023-09-13T15:25:51.000Z,
  lastUpdatedDate: 2023-09-13T15:25:51.000Z,
  stageKeys: []
}
===Usage Plan: Found===
{
  id: '70m16n',
  name: 'dev-plk-partners-api-basic-usage-plan',
  description: 'Basic usage plan',
  apiStages: [ { apiId: 'x4rki34mgd', stage: 'dev' } ],
  throttle: { burstLimit: 5, rateLimit: 500 },
  quota: { limit: 20000, offset: 0, period: 'DAY' }
}
===Usage Plan Key: Created===
{
  id: 'jemf6c7rc8',
  type: 'API_KEY',
  value: 'Kw9EkBW6Yf6KpojDNqZq48FhRRhTe6yp7R1ygqD7',
  name: 'dev-plk-partners-api-shoprapha'
}
===API Gateway Deployment: Created===
{ id: 'd7167p', createdDate: 2023-09-13T15:25:54.000Z }
===JWT Payload===
{
  iat: 1694618755,
  sub: 'shoprapha',
  brand: 'PLK',
  partnerId: 'db5c3402-50e1-433a-876b-c10ddc439e8f',
  integrationId: 'dd58dca8-abca-4722-9893-e39dbde8f8f1',
  apiKey: 'Kw9EkBW6Yf6KpojDNqZq48FhRRhTe6yp7R1ygqD7',
  region: 'ES'
}
===JWT===
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2OTQ2MTg3NTUsInN1YiI6InNob3ByYXBoYSIsImJyYW5kIjoiUExLIiwicGFydG5lcklkIjoiZGI1YzM0MDItNTBlMS00MzNhLTg3NmItYzEwZGRjNDM5ZThmIiwiaW50ZWdyYXRpb25JZCI6ImRkNThkY2E4LWFiY2EtNDcyMi05ODkzLWUzOWRiZGU4ZjhmMSIsImFwaUtleSI6Ikt3OUVrQlc2WWY2S3BvakROcVpxNDhGaFJSaFRlNnlwN1IxeWdxRDciLCJyZWdpb24iOiJFUyJ9.NczhVp1vBoWwDt7FM9DQMKVo18ZqSofk9efxooKq5Hw

Create Integration

Method: POST

Authorization:

  • Token: partners api secret (dynamodb)

  • Example: 6dfnPNxMuF1MA5zi5iDY

Header:

[{"key":"x-ui-region","value":"ES","description":null,"type":"text","enabled":true}]

Body:

Code Block
{
    "brand": "PLK",
    "country": "ES",
    "storeIds": ["7788"],
    "integrationId": "dd58dca8-abca-4722-9893-e39dbde8f8f1",
    "partnerId": "db5c3402-50e1-433a-876b-c10ddc439e8f"
}

Image Added

Note that the storeIds were inputted above, but later, you’ll that this association really didn’t work. According to the swagger, it could work using an object like

Code Block
{
  "secret": "819759eedea160697759890eb5d9aeb9",
  "stores": [
    {
      "country": "ES",
      "storeId": "7788"
    }
  ]
}

Alternatively, you can update your integration as you can see in the following steps.

Validate the integration

Method: GET

Authorization:

  • Token: partners api secret (dynamodb)

  • Example: 6dfnPNxMuF1MA5zi5iDY

Header:

[{"key":"x-ui-region","value":"ES","description":null,"type":"text","enabled":true}]

Body: N/A

...

Note: See the missing stores.

Update your integration to include your restaurant

Method: PUT

Authorization:

  • Token: partners api secret (dynamodb)

  • Example: 6dfnPNxMuF1MA5zi5iDY

Header:

[{"key":"x-ui-region","value":"ES","description":null,"type":"text","enabled":true}]

Body:

Code Block
{
  "secret": "819759eedea160697759890eb5d9aeb9",
  "stores": [
    {
      "country": "ES",
      "storeId": "7788"
    }
  ]
}

...

Find the restaurant in the app

...

Note that only the Menu Items that you configured for the restaurant will be available:

...

The following cart page will only be available if the restaurant webhooks are well configured

...