# Post Coverage: the raw HTTPS requests behind the five integration moments,
# for a language without an official library. Sandbox only.
#
# Each request is separated by ###, the format the VS Code REST Client and
# JetBrains HTTP Client read. Replace each {{name}} with your value:
#   origin          the sandbox API origin (PC_API_URL), no trailing slash
#   apiKey          your pc_test_ server key (PC_API_KEY). Server-side only.
#   externalId      your own order reference: unique, never reused
#   customerKey     an opaque key for the customer (see the guide)
#   pricingVersion  from the quote the customer was charged
#   orderId         from the order's creation, "PC-..."
#   version         order.version, read immediately before the write
#   requestId       a new id per event or reset, kept and reused on retries
#
# The integration guide (/developers/integrate/) shows the sections marked
# "guide:", and every change to this file sends each of them, as written, to
# a local copy of the API.

### guide:quote
POST {{origin}}/integrations/v1/quotes
Content-Type: application/json
X-API-Key: {{apiKey}}

{
  "amountCents": 7830,
  "currency": "USD"
}

### guide:record
POST {{origin}}/integrations/v1/orders
Content-Type: application/json
X-API-Key: {{apiKey}}

{
  "externalId": "{{externalId}}",
  "amountCents": 7830,
  "currency": "USD",
  "purchaseType": "one_time",
  "customerOptedIn": true,
  "customerKey": "{{customerKey}}",
  "pricingVersion": "{{pricingVersion}}"
}

### guide:read
GET {{origin}}/integrations/v1/orders/detail?orderId={{orderId}}&pageSize=100
X-API-Key: {{apiKey}}

### guide:event
POST {{origin}}/integrations/v1/orders/events
Content-Type: application/json
X-API-Key: {{apiKey}}

{
  "orderId": "{{orderId}}",
  "type": "delivered",
  "requestId": "{{requestId}}",
  "expectedVersion": {{version}},
  "synthetic": true
}

### guide:refund
POST {{origin}}/integrations/v1/orders/events
Content-Type: application/json
X-API-Key: {{apiKey}}

{
  "orderId": "{{orderId}}",
  "type": "refunded",
  "refundAmountCents": 2160,
  "requestId": "{{requestId}}",
  "expectedVersion": {{version}},
  "synthetic": true
}

### guide:reset
POST {{origin}}/integrations/v1/orders/claim-access
Content-Type: application/json
X-API-Key: {{apiKey}}

{
  "orderId": "{{orderId}}",
  "requestId": "{{requestId}}",
  "expectedVersion": {{version}},
  "synthetic": true
}
