@mongoui/skills 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/install.js +48 -1
- package/dist/products/index.js +4 -2
- package/dist/tools/index.js +2 -2
- package/package.json +1 -1
- package/skills/flink-flight-api/flink-openapi-integration/SKILL.md +63 -0
- package/skills/flink-flight-api/flink-openapi-integration/agents/openai.yaml +4 -0
- package/skills/flink-flight-api/flink-openapi-integration/references/api-workflows.md +104 -0
- package/skills/flink-flight-api/flink-openapi-integration/references/auth-and-credentials.md +136 -0
- package/skills/flink-flight-api/flink-openapi-integration/references/endpoint-index.md +92 -0
- package/skills/flink-flight-api/flink-openapi-integration/scripts/flink_signed_request.py +188 -0
- package/skills/glink-hotel-api/glink-openapi-integration/SKILL.md +75 -0
- package/skills/glink-hotel-api/glink-openapi-integration/agents/openai.yaml +4 -0
- package/skills/glink-hotel-api/glink-openapi-integration/references/api-workflows.md +110 -0
- package/skills/glink-hotel-api/glink-openapi-integration/references/auth-and-credentials.md +157 -0
- package/skills/glink-hotel-api/glink-openapi-integration/references/endpoint-index.md +130 -0
- package/skills/glink-hotel-api/glink-openapi-integration/scripts/glink_signed_request.py +188 -0
- package/skills/flink-flight-api/SKILL.md +0 -8
- package/skills/glink-hotel-api/SKILL.md +0 -175
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Generate or send signed requests for the Flink open-platform gateway.
|
|
3
|
+
|
|
4
|
+
Examples:
|
|
5
|
+
python scripts/flink_signed_request.py ^
|
|
6
|
+
--method POST ^
|
|
7
|
+
--path /openapi/v1/flink/zh_CN/airlines/list ^
|
|
8
|
+
--body-json "{\"page\":1,\"pageSize\":20}" ^
|
|
9
|
+
--app-key open_app_xxx ^
|
|
10
|
+
--app-secret sk_xxx
|
|
11
|
+
|
|
12
|
+
python scripts/flink_signed_request.py ^
|
|
13
|
+
--method GET ^
|
|
14
|
+
--path /openapi/v1/flink/fields ^
|
|
15
|
+
--query orderNo=dd20251020161158787680281 ^
|
|
16
|
+
--app-key open_app_xxx ^
|
|
17
|
+
--app-secret sk_xxx ^
|
|
18
|
+
--send
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import hashlib
|
|
25
|
+
import hmac
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import sys
|
|
29
|
+
import time
|
|
30
|
+
import urllib.parse
|
|
31
|
+
import urllib.request
|
|
32
|
+
import uuid
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def sha256_hex(data: bytes) -> str:
|
|
37
|
+
return hashlib.sha256(data).hexdigest()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def parse_query_items(items: list[str]) -> list[tuple[str, str]]:
|
|
41
|
+
pairs: list[tuple[str, str]] = []
|
|
42
|
+
for item in items:
|
|
43
|
+
if "=" not in item:
|
|
44
|
+
raise ValueError(f"invalid query item: {item!r}; expected key=value")
|
|
45
|
+
key, value = item.split("=", 1)
|
|
46
|
+
pairs.append((key, value))
|
|
47
|
+
return pairs
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def canonical_query(pairs: list[tuple[str, str]]) -> str:
|
|
51
|
+
ordered = sorted(pairs, key=lambda item: (item[0], item[1]))
|
|
52
|
+
return "&".join(
|
|
53
|
+
f"{urllib.parse.quote(key, safe='~-._')}={urllib.parse.quote(value, safe='~-._')}"
|
|
54
|
+
for key, value in ordered
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def build_sign_payload(
|
|
59
|
+
method: str,
|
|
60
|
+
path: str,
|
|
61
|
+
query_string: str,
|
|
62
|
+
body_bytes: bytes,
|
|
63
|
+
timestamp: str,
|
|
64
|
+
nonce: str,
|
|
65
|
+
app_key: str,
|
|
66
|
+
) -> str:
|
|
67
|
+
return "\n".join(
|
|
68
|
+
[
|
|
69
|
+
method.upper(),
|
|
70
|
+
path,
|
|
71
|
+
query_string,
|
|
72
|
+
sha256_hex(body_bytes),
|
|
73
|
+
timestamp,
|
|
74
|
+
nonce,
|
|
75
|
+
app_key,
|
|
76
|
+
]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def sign(secret: str, payload: str) -> str:
|
|
81
|
+
return hmac.new(secret.encode("utf-8"), payload.encode("utf-8"), hashlib.sha256).hexdigest()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def load_body(args: argparse.Namespace) -> bytes:
|
|
85
|
+
if args.body_file:
|
|
86
|
+
return Path(args.body_file).read_bytes()
|
|
87
|
+
if args.body_json is None:
|
|
88
|
+
return b""
|
|
89
|
+
parsed = json.loads(args.body_json)
|
|
90
|
+
return json.dumps(parsed, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def build_url(base_url: str, path: str, query_string: str) -> str:
|
|
94
|
+
base = base_url.rstrip("/")
|
|
95
|
+
url = f"{base}{path}"
|
|
96
|
+
if query_string:
|
|
97
|
+
url = f"{url}?{query_string}"
|
|
98
|
+
return url
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def build_headers(app_key: str, timestamp: str, nonce: str, signature: str, has_body: bool) -> dict[str, str]:
|
|
102
|
+
headers = {
|
|
103
|
+
"Accept": "application/json",
|
|
104
|
+
"X-OP-App-Key": app_key,
|
|
105
|
+
"X-OP-Timestamp": timestamp,
|
|
106
|
+
"X-OP-Nonce": nonce,
|
|
107
|
+
"X-OP-Sign": signature,
|
|
108
|
+
}
|
|
109
|
+
if has_body:
|
|
110
|
+
headers["Content-Type"] = "application/json"
|
|
111
|
+
return headers
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def send_request(method: str, url: str, headers: dict[str, str], body_bytes: bytes, timeout: float) -> tuple[int, str]:
|
|
115
|
+
request = urllib.request.Request(url=url, data=body_bytes or None, headers=headers, method=method.upper())
|
|
116
|
+
try:
|
|
117
|
+
with urllib.request.urlopen(request, timeout=timeout) as response:
|
|
118
|
+
return response.status, response.read().decode("utf-8", errors="replace")
|
|
119
|
+
except urllib.error.HTTPError as exc:
|
|
120
|
+
return exc.code, exc.read().decode("utf-8", errors="replace")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def main() -> int:
|
|
124
|
+
parser = argparse.ArgumentParser(description="Generate or send a signed Flink open-platform request.")
|
|
125
|
+
parser.add_argument("--base-url", default=os.getenv("OPEN_PLATFORM_BASE_URL", "http://127.0.0.1:8671"))
|
|
126
|
+
parser.add_argument("--method", required=True)
|
|
127
|
+
parser.add_argument("--path", required=True)
|
|
128
|
+
parser.add_argument("--query", action="append", default=[], help="Repeatable key=value query parameter")
|
|
129
|
+
parser.add_argument("--body-json", help="JSON string request body")
|
|
130
|
+
parser.add_argument("--body-file", help="Path to a raw request body file")
|
|
131
|
+
parser.add_argument("--app-key", default=os.getenv("OPEN_PLATFORM_APP_KEY") or os.getenv("OPEN_PLATFORM_OPEN_APP_ID"))
|
|
132
|
+
parser.add_argument("--app-secret", default=os.getenv("OPEN_PLATFORM_APP_SECRET") or os.getenv("OPEN_PLATFORM_OPEN_SECRET"))
|
|
133
|
+
parser.add_argument("--timestamp", default=str(int(time.time())))
|
|
134
|
+
parser.add_argument("--nonce", default=uuid.uuid4().hex)
|
|
135
|
+
parser.add_argument("--send", action="store_true")
|
|
136
|
+
parser.add_argument("--timeout", type=float, default=15.0)
|
|
137
|
+
args = parser.parse_args()
|
|
138
|
+
|
|
139
|
+
if not args.app_key or not args.app_secret:
|
|
140
|
+
print("app key and app secret are required", file=sys.stderr)
|
|
141
|
+
return 2
|
|
142
|
+
|
|
143
|
+
try:
|
|
144
|
+
query_pairs = parse_query_items(args.query)
|
|
145
|
+
body_bytes = load_body(args)
|
|
146
|
+
except Exception as exc: # pragma: no cover - simple CLI error path
|
|
147
|
+
print(str(exc), file=sys.stderr)
|
|
148
|
+
return 2
|
|
149
|
+
|
|
150
|
+
query_string = canonical_query(query_pairs)
|
|
151
|
+
payload = build_sign_payload(
|
|
152
|
+
method=args.method,
|
|
153
|
+
path=args.path,
|
|
154
|
+
query_string=query_string,
|
|
155
|
+
body_bytes=body_bytes,
|
|
156
|
+
timestamp=args.timestamp,
|
|
157
|
+
nonce=args.nonce,
|
|
158
|
+
app_key=args.app_key,
|
|
159
|
+
)
|
|
160
|
+
signature = sign(args.app_secret, payload)
|
|
161
|
+
headers = build_headers(args.app_key, args.timestamp, args.nonce, signature, bool(body_bytes))
|
|
162
|
+
url = build_url(args.base_url, args.path, query_string)
|
|
163
|
+
|
|
164
|
+
print("URL:")
|
|
165
|
+
print(url)
|
|
166
|
+
print()
|
|
167
|
+
print("Canonical String:")
|
|
168
|
+
print(payload)
|
|
169
|
+
print()
|
|
170
|
+
print("Headers:")
|
|
171
|
+
print(json.dumps(headers, ensure_ascii=False, indent=2))
|
|
172
|
+
if body_bytes:
|
|
173
|
+
print()
|
|
174
|
+
print("Body:")
|
|
175
|
+
print(body_bytes.decode("utf-8", errors="replace"))
|
|
176
|
+
|
|
177
|
+
if not args.send:
|
|
178
|
+
return 0
|
|
179
|
+
|
|
180
|
+
status, response_text = send_request(args.method, url, headers, body_bytes, args.timeout)
|
|
181
|
+
print()
|
|
182
|
+
print(f"HTTP {status}")
|
|
183
|
+
print(response_text)
|
|
184
|
+
return 0
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
if __name__ == "__main__":
|
|
188
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: glink-openapi-integration
|
|
3
|
+
description: Integrate with the Glink hotel OpenAPI exposed through the Open Platform runtime gateway. Use when Codex needs to read, verify, explain, test, or implement against `docs/swagger/glink-api.json` or Glink route code; choose Glink hotel endpoints; generate or debug `X-OP-*` signatures; explain sandbox or production credential issuance/reset; or drive Chinese/English requests about Glink 酒店 static data, hotel search, hotel info, product detail, booking, payment, order, cancel, order status push/callback, checkout, invoice, and balance workflows.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Glink OpenAPI Integration
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
|
|
10
|
+
Use this skill when the task is "call Glink through the open platform".
|
|
11
|
+
|
|
12
|
+
Start with the smallest current source that answers the request:
|
|
13
|
+
|
|
14
|
+
- Prefer the repository source of truth when it exists: `docs/swagger/glink-api.json`, route handlers, DTOs, and tests.
|
|
15
|
+
- Read `references/auth-and-credentials.md` for signing, headers, key acquisition, reset, and auth troubleshooting.
|
|
16
|
+
- Read `references/api-workflows.md` for hotel search, booking, cancel, checkout, invoice, and balance workflows.
|
|
17
|
+
- Read `references/endpoint-index.md` for a compact endpoint map and platform-managed field caveats, then verify fragile fields against the current swagger or code.
|
|
18
|
+
- Use `scripts/glink_signed_request.py` to generate headers, inspect the canonical string, or send a signed request.
|
|
19
|
+
|
|
20
|
+
## Working Rules
|
|
21
|
+
|
|
22
|
+
Follow this workflow:
|
|
23
|
+
|
|
24
|
+
1. Confirm the environment: `sandbox` and `production` credentials are separate.
|
|
25
|
+
2. Confirm whether the user is asking for documentation, code changes, local smoke testing, or live API calls.
|
|
26
|
+
3. Confirm the public path under `/openapi/v1/glink/*`.
|
|
27
|
+
4. Build the minimum valid request body from swagger/code first, using `references/endpoint-index.md` as navigation.
|
|
28
|
+
5. Sign the exact public path, sorted query string, and raw body bytes with the platform secret.
|
|
29
|
+
6. Evaluate both HTTP status and response envelope `code`, not HTTP status alone.
|
|
30
|
+
|
|
31
|
+
When the user asks for the Open Platform Glink hotel onboarding or booking flow, apply this required sequence:
|
|
32
|
+
|
|
33
|
+
1. Static bootstrap: `queryCityList` -> `queryHotelIdList` by city -> `queryHotelInfo` for hotel/room static data, then persist mapping locally.
|
|
34
|
+
2. Static maintenance: run `queryHotelIncrement`, then call `queryHotelInfo` for changed hotel IDs and update or disconnect local mappings when needed.
|
|
35
|
+
3. List pricing: run `queryHotelLowestPrice` for mapped hotels, normally as a daily job after the Glink price refresh window, and use it as list-page display/reference data.
|
|
36
|
+
4. Detail pricing: before `queryProductDetail`, check the local saleable hotel ID cache; skip hotels not in the saleable list. Use `bookType=1` products as bookable candidates.
|
|
37
|
+
5. Booking: call `checkBooking` with the actual room count before entering or submitting the order flow; call it again before `createOrder` when the local order is ready.
|
|
38
|
+
6. Payment and confirmation: after `createOrder`, call `payOrder` only after local customer payment succeeds or the platform has decided the Glink order should be confirmed.
|
|
39
|
+
7. Confirmation result: treat Glink order operation push/callback as primary and idempotent; use `queryOrderDetail` only as low-frequency compensation before final confirmation or cancellation.
|
|
40
|
+
8. Cancellation: call `cancelOrder` for unpaid timeout such as 30 minutes or customer cancellation. If the cancellation API returns success, update the local order and do not keep polling for another status push.
|
|
41
|
+
|
|
42
|
+
Do not violate these rules:
|
|
43
|
+
|
|
44
|
+
- Always send `X-OP-App-Key`, `X-OP-Timestamp`, `X-OP-Nonce`, and `X-OP-Sign`.
|
|
45
|
+
- Never send Glink-side `partnerCode`, `signature`, `requestType`, or Glink-side `timestamp`.
|
|
46
|
+
- Never wrap the payload in Glink-style `header` or `businessRequest`; send only business fields.
|
|
47
|
+
- Never invent credentials or secrets. Use explicit user-provided values or environment variables.
|
|
48
|
+
- Treat `code=SUCCESS` as success. Treat `code=SUPPLIER_BIZ_ERROR` as a business failure even if HTTP status is `200`.
|
|
49
|
+
- Keep timestamp skew within `+-5` minutes.
|
|
50
|
+
- Reuse of the same nonce under the same app key can trigger `NONCE_REPLAY`.
|
|
51
|
+
- If a swagger schema still shows Glink-managed fields as required, follow the route description first and omit those platform-managed downstream fields from the client payload.
|
|
52
|
+
- Do not frequently poll order status. Stop polling once the order is confirmed or canceled; rely on idempotent push/callback handling as the source of truth for confirmation progress.
|
|
53
|
+
- Do not query real-time products for hotels outside the cached saleable hotel list; it wastes integration quota and usually returns no useful sellable data.
|
|
54
|
+
|
|
55
|
+
## Typical Requests
|
|
56
|
+
|
|
57
|
+
Use these patterns by default:
|
|
58
|
+
|
|
59
|
+
- Static data: city, country, district, business area, and brand lookup calls
|
|
60
|
+
- Catalog sync: `queryCityList` -> `queryHotelIdList` -> `queryHotelInfo`; maintain with `queryHotelIncrement` -> `queryHotelInfo`
|
|
61
|
+
- Search and booking: mapped saleable hotel IDs -> `queryHotelLowestPrice` for list display -> `queryProductDetail` for hotel detail -> `checkBooking` -> optional second `checkBooking` -> `createOrder` -> `payOrder` -> order push/callback primary, `queryOrderDetail` as compensation
|
|
62
|
+
- Order aftercare: `cancelOrder`, Glink order push/callback, `queryOrderDetail`, `queryOrderCheckDetailInfo`, `checkoutApply`, `queryCheckoutDetail`
|
|
63
|
+
- Finance: `createInvoice`, `queryCreditBalance`
|
|
64
|
+
|
|
65
|
+
## Output Expectations
|
|
66
|
+
|
|
67
|
+
When answering or coding with this skill:
|
|
68
|
+
|
|
69
|
+
- Prefer concrete request examples over abstract summaries.
|
|
70
|
+
- Name the source used when the current swagger/code and bundled references disagree.
|
|
71
|
+
- State which environment the credential belongs to.
|
|
72
|
+
- State whether the payload should contain only business fields.
|
|
73
|
+
- Call out Glink-managed field residue in the swagger when relevant.
|
|
74
|
+
- Call out auth failures with the likely root cause and the exact header or field to inspect.
|
|
75
|
+
- For code changes, keep Glink downstream auth and platform gateway auth clearly separated.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Glink API Workflows
|
|
2
|
+
|
|
3
|
+
## Static Data
|
|
4
|
+
|
|
5
|
+
Use these calls to build hotel search prerequisites:
|
|
6
|
+
|
|
7
|
+
- `glink.queryCountryList`
|
|
8
|
+
- `glink.queryCityList`
|
|
9
|
+
- `glink.queryHotCityList`
|
|
10
|
+
- `glink.queryDistrictList`
|
|
11
|
+
- `glink.queryDistrictAndBusiness`
|
|
12
|
+
- `glink.queryBusinessList`
|
|
13
|
+
- `glink.queryHotelPlateList`
|
|
14
|
+
- `glink.queryCityAndHotelByKeyword`
|
|
15
|
+
|
|
16
|
+
These APIs usually feed city selection, district filters, brand filters, and keyword suggestions.
|
|
17
|
+
|
|
18
|
+
For the required Open Platform Glink onboarding flow, build local hotel and room mapping in this order:
|
|
19
|
+
|
|
20
|
+
1. `glink.queryCityList`
|
|
21
|
+
- Get Glink city codes used by the platform hotel flow.
|
|
22
|
+
2. `glink.queryHotelIdList`
|
|
23
|
+
- Use the city code to fetch the account's saleable hotel ID list and cache it locally.
|
|
24
|
+
3. `glink.queryHotelInfo`
|
|
25
|
+
- Fetch hotel and room static data for the cached hotel IDs. Persist only the fields needed for local hotel and room mapping.
|
|
26
|
+
4. `glink.queryHotelIncrement`
|
|
27
|
+
- Periodically fetch changed hotel IDs, including added, updated, or deleted hotels.
|
|
28
|
+
5. `glink.queryHotelInfo`
|
|
29
|
+
- Rehydrate changed hotel IDs and decide whether local mappings should be updated or disconnected.
|
|
30
|
+
|
|
31
|
+
## Hotel Search And Product Selection
|
|
32
|
+
|
|
33
|
+
Use this sequence for discovery and pricing:
|
|
34
|
+
|
|
35
|
+
1. `glink.getDestination` or `glink.queryCityAndHotelByKeyword`
|
|
36
|
+
- Resolve the destination or keyword to a city or hotel scope.
|
|
37
|
+
2. `glink.getHotelSearch` or `glink.findHotelList`
|
|
38
|
+
- Search hotels using city, dates, room count, and optional filters.
|
|
39
|
+
3. `glink.queryHotelLowestPrice`
|
|
40
|
+
- Pull summary pricing for selected hotel IDs.
|
|
41
|
+
4. `glink.queryProductDetail`
|
|
42
|
+
- Read real-time sellable products for a selected hotel and stay range.
|
|
43
|
+
5. `glink.queryHotelInfo`, `glink.queryHotelImage`, or `glink.queryHotelMainInfoByHotelIds`
|
|
44
|
+
- Hydrate hotel details for display or validation.
|
|
45
|
+
|
|
46
|
+
Use `queryHotelAllList`, `queryHotelIdList`, and `queryHotelIncrement` when synchronizing hotel catalogs rather than serving live booking UX.
|
|
47
|
+
|
|
48
|
+
For the Open Platform Glink flow, prefer the local mapped catalog over broad live search during booking:
|
|
49
|
+
|
|
50
|
+
- Use `glink.queryHotelLowestPrice` for mapped hotels to refresh daily starting prices. It is list-page reference/display data and should normally be refreshed once daily after the Glink price refresh window, for example after 05:00.
|
|
51
|
+
- Before calling `glink.queryProductDetail`, verify that the hotel is still in the cached saleable hotel ID list. Do not query products for hotels outside the saleable list.
|
|
52
|
+
- Use `glink.queryProductDetail` when the customer enters a hotel detail or booking path. Treat products with `bookType=1` as bookable candidates, then confirm with `checkBooking`.
|
|
53
|
+
|
|
54
|
+
## Booking Flow
|
|
55
|
+
|
|
56
|
+
Use this sequence for a normal hotel booking flow:
|
|
57
|
+
|
|
58
|
+
1. `glink.queryProductDetail`
|
|
59
|
+
- Identify the exact sellable room and rate.
|
|
60
|
+
2. `glink.checkBooking`
|
|
61
|
+
- Perform pre-booking validation with the actual room count. Use this before showing or entering the final order submission path.
|
|
62
|
+
3. `glink.createOrder`
|
|
63
|
+
- Submit the order with guest, contact, amount, and price item details. When the local order has been created and is ready to submit, call `checkBooking` again first if there is any delay or state change risk.
|
|
64
|
+
4. `glink.payOrder`
|
|
65
|
+
- Notify Glink after local customer payment succeeds, or after the platform has decided the Glink order should be confirmed.
|
|
66
|
+
5. Glink order operation push/callback
|
|
67
|
+
- Treat the push/callback as the primary confirmation result channel. The receiver must be idempotent.
|
|
68
|
+
6. `glink.queryOrderDetail`
|
|
69
|
+
- Use as low-frequency compensation only before final confirmation or cancellation. Do not keep polling confirmed or canceled orders.
|
|
70
|
+
|
|
71
|
+
Key order identifiers:
|
|
72
|
+
|
|
73
|
+
- `coOrderCode`: your platform-side order number
|
|
74
|
+
- `fcOrderCode`: Glink-side order number when available
|
|
75
|
+
|
|
76
|
+
Prefer carrying both once they appear, because several aftercare APIs accept one or both.
|
|
77
|
+
|
|
78
|
+
## Order Aftercare
|
|
79
|
+
|
|
80
|
+
Use these calls after booking:
|
|
81
|
+
|
|
82
|
+
- `glink.cancelOrder`
|
|
83
|
+
- Cancel an order when policy permits, when the customer asks to cancel, or when the local unpaid timeout is reached, such as 30 minutes. If cancellation returns success, update the local order and do not continue polling for another push.
|
|
84
|
+
- Glink order operation push/callback
|
|
85
|
+
- This is required for order confirmation progress after `payOrder`. It may not appear as a public `/openapi/v1/glink/*` request route in swagger because it is an inbound callback capability; inspect platform callback route code before implementing.
|
|
86
|
+
- `glink.queryOrderCheckDetailInfo`
|
|
87
|
+
- Read extended order or check-in related detail.
|
|
88
|
+
- `glink.checkoutApply`
|
|
89
|
+
- Submit a checkout or refund-like aftercare request for an order.
|
|
90
|
+
- `glink.queryCheckoutDetail`
|
|
91
|
+
- Query the checkout task by `taskOrderCode`.
|
|
92
|
+
|
|
93
|
+
## Finance
|
|
94
|
+
|
|
95
|
+
Use these calls for financial follow-up:
|
|
96
|
+
|
|
97
|
+
- `glink.createInvoice`
|
|
98
|
+
- Submit invoice information using business fields only.
|
|
99
|
+
- Ignore Glink-managed `partnerCode` and `sign` even if they appear in the swagger schema.
|
|
100
|
+
- `glink.queryCreditBalance`
|
|
101
|
+
- Read remaining credit balance.
|
|
102
|
+
|
|
103
|
+
## Business Handling Rules
|
|
104
|
+
|
|
105
|
+
- Do not treat HTTP `200` as enough; inspect `code`.
|
|
106
|
+
- Do not rebuild Glink headers or wrapper payloads; the runtime gateway handles downstream authentication and wrapping.
|
|
107
|
+
- Preserve Glink order identifiers from earlier responses instead of recomputing them.
|
|
108
|
+
- Keep local saleable hotel ID cache and hotel/room mappings current before pricing and booking.
|
|
109
|
+
- Avoid integration quota waste: skip `queryProductDetail` for hotels not in the saleable hotel cache.
|
|
110
|
+
- Push/callback is primary for order confirmation; `queryOrderDetail` is only a compensation path and should not be frequent.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Glink Auth And Credentials
|
|
2
|
+
|
|
3
|
+
## Required Headers
|
|
4
|
+
|
|
5
|
+
Send these headers on every Glink open-platform request:
|
|
6
|
+
|
|
7
|
+
- `X-OP-App-Key`
|
|
8
|
+
- `X-OP-Timestamp`
|
|
9
|
+
- `X-OP-Nonce`
|
|
10
|
+
- `X-OP-Sign`
|
|
11
|
+
|
|
12
|
+
Optional headers that can help tracing or idempotency:
|
|
13
|
+
|
|
14
|
+
- `X-OP-Client-Request-Id`
|
|
15
|
+
- `X-Trace-Id`
|
|
16
|
+
- `X-Idempotency-Key`
|
|
17
|
+
|
|
18
|
+
`X-OP-App-Key` is the issued `open_app_id`.
|
|
19
|
+
|
|
20
|
+
## Signature Algorithm
|
|
21
|
+
|
|
22
|
+
Build the canonical string in this exact order, separated by newline characters:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
METHOD
|
|
26
|
+
PATH
|
|
27
|
+
CANONICAL_QUERY
|
|
28
|
+
BODY_SHA256
|
|
29
|
+
TIMESTAMP
|
|
30
|
+
NONCE
|
|
31
|
+
APP_KEY
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Rules:
|
|
35
|
+
|
|
36
|
+
- Uppercase `METHOD`.
|
|
37
|
+
- Use the exact public request path, for example `/openapi/v1/glink/queryBusinessList`.
|
|
38
|
+
- Sort query parameters by key and then value before joining them as `k=v&k2=v2`.
|
|
39
|
+
- Hash the raw request body bytes with SHA256 and use the lowercase hex digest.
|
|
40
|
+
- Use the request timestamp exactly as sent in `X-OP-Timestamp`.
|
|
41
|
+
- Use the request nonce exactly as sent in `X-OP-Nonce`.
|
|
42
|
+
- Use the same `open_app_id` that is sent in `X-OP-App-Key`.
|
|
43
|
+
- Sign the canonical string with the plain `open_app_secret` using HMAC-SHA256, then output lowercase hex.
|
|
44
|
+
|
|
45
|
+
Notes:
|
|
46
|
+
|
|
47
|
+
- Timestamp may be Unix seconds, Unix milliseconds, or RFC3339.
|
|
48
|
+
- The platform validates timestamp drift within roughly `+-5` minutes.
|
|
49
|
+
- Nonce must be unique for the same app key in a short time window.
|
|
50
|
+
- For empty bodies, hash the empty byte string.
|
|
51
|
+
|
|
52
|
+
## Platform Wrapping Rules
|
|
53
|
+
|
|
54
|
+
Glink downstream authentication is handled by the runtime gateway.
|
|
55
|
+
|
|
56
|
+
Client responsibilities:
|
|
57
|
+
|
|
58
|
+
- Send only business fields.
|
|
59
|
+
- Sign the public open-platform request.
|
|
60
|
+
|
|
61
|
+
Do not send:
|
|
62
|
+
|
|
63
|
+
- `partnerCode`
|
|
64
|
+
- `signature` or `sign` used by Glink downstream auth
|
|
65
|
+
- `requestType`
|
|
66
|
+
- Glink-side `timestamp`
|
|
67
|
+
- wrapper objects like `header` or `businessRequest`
|
|
68
|
+
|
|
69
|
+
Important exception handling:
|
|
70
|
+
|
|
71
|
+
- `createInvoice` currently still exposes `partnerCode` and `sign` in schema examples and required lists.
|
|
72
|
+
- The route description still says the platform fills those fields automatically.
|
|
73
|
+
- Prefer the route description and treat those fields as platform-managed downstream fields.
|
|
74
|
+
|
|
75
|
+
## Credential Acquisition
|
|
76
|
+
|
|
77
|
+
Treat credentials as environment-specific.
|
|
78
|
+
|
|
79
|
+
Sandbox:
|
|
80
|
+
|
|
81
|
+
1. The developer applies for app access.
|
|
82
|
+
2. The operator activates the app access with `env_type=sandbox`.
|
|
83
|
+
3. The platform records sandbox Glink mapping and issues a sandbox `open_app_id/open_app_secret`.
|
|
84
|
+
4. The app access becomes `sandbox_active`.
|
|
85
|
+
|
|
86
|
+
Production:
|
|
87
|
+
|
|
88
|
+
1. The developer submits production access after sandbox work is complete.
|
|
89
|
+
2. The operator approves production with `env_type=production`.
|
|
90
|
+
3. The platform issues a production `open_app_id/open_app_secret`.
|
|
91
|
+
4. The production credential becomes usable only after the app access reaches `production_active`.
|
|
92
|
+
|
|
93
|
+
Important constraints:
|
|
94
|
+
|
|
95
|
+
- Sandbox and production credentials are separate and not interchangeable.
|
|
96
|
+
- Developers can see platform credentials only.
|
|
97
|
+
- Developers cannot see Glink downstream secrets.
|
|
98
|
+
|
|
99
|
+
## How To View Or Reset Keys
|
|
100
|
+
|
|
101
|
+
Developer portal APIs:
|
|
102
|
+
|
|
103
|
+
- `GET /api/portal/apps/{app_id}/credentials`
|
|
104
|
+
- Returns the credential list for the app.
|
|
105
|
+
- Includes `open_app_id`, `provider_code`, `env_type`, `open_secret_version`, and masked secret data.
|
|
106
|
+
- Does not return the plain secret in normal list queries.
|
|
107
|
+
- `POST /api/portal/apps/{app_id}/credentials/reset`
|
|
108
|
+
- Resets the platform secret and returns `plain_open_secret`.
|
|
109
|
+
- If the app has more than one credential mapping, pass both `provider_code` and `env_type`.
|
|
110
|
+
|
|
111
|
+
Response fields that matter:
|
|
112
|
+
|
|
113
|
+
- `open_app_id`: the App Key to place into `X-OP-App-Key`
|
|
114
|
+
- `open_secret_masked`: masked secret for display only
|
|
115
|
+
- `open_secret_version`: useful for rotation tracking
|
|
116
|
+
- `plain_open_secret`: returned only on first issuance or reset
|
|
117
|
+
|
|
118
|
+
Practical guidance:
|
|
119
|
+
|
|
120
|
+
- If a developer says "I can only see a masked secret", instruct them to use the reset endpoint or the corresponding portal UI action.
|
|
121
|
+
- If the task is only to call sandbox APIs, do not assume production credentials work.
|
|
122
|
+
- If the app has both sandbox and production mappings, always name the target `env_type` explicitly.
|
|
123
|
+
|
|
124
|
+
## Common Auth Failures
|
|
125
|
+
|
|
126
|
+
- `APP_KEY_INVALID`
|
|
127
|
+
- Wrong `open_app_id`, wrong environment, or the credential does not exist.
|
|
128
|
+
- `SIGN_ERROR`
|
|
129
|
+
- Wrong secret, wrong path, wrong query ordering, wrong body hash, or newline formatting mismatch.
|
|
130
|
+
- `TIMESTAMP_EXPIRED`
|
|
131
|
+
- Clock skew exceeds the allowed window.
|
|
132
|
+
- `NONCE_REPLAY`
|
|
133
|
+
- Nonce was reused under the same app key.
|
|
134
|
+
- `PRODUCT_FORBIDDEN`
|
|
135
|
+
- The app is not enabled for the product, the mapping is not active, or an IP whitelist rule failed.
|
|
136
|
+
|
|
137
|
+
## Response Contract
|
|
138
|
+
|
|
139
|
+
The platform wraps business responses in a common envelope:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"request_id": "req_xxx",
|
|
144
|
+
"trace_id": "trc_xxx",
|
|
145
|
+
"downstream_request_id": "optional",
|
|
146
|
+
"code": "SUCCESS",
|
|
147
|
+
"message": "ok",
|
|
148
|
+
"data": {}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Interpretation:
|
|
153
|
+
|
|
154
|
+
- `request_id` and `trace_id` are platform-side tracing keys.
|
|
155
|
+
- `downstream_request_id` is the Glink request identifier when available.
|
|
156
|
+
- `code=SUCCESS` means the business call succeeded.
|
|
157
|
+
- `code=SUPPLIER_BIZ_ERROR` means Glink returned a business error and can still arrive with HTTP `200`.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Glink Endpoint Index
|
|
2
|
+
|
|
3
|
+
All routes are public gateway routes. Sign the public path, not the downstream Glink path.
|
|
4
|
+
|
|
5
|
+
## Static Data
|
|
6
|
+
|
|
7
|
+
- `glink.queryBusinessList`
|
|
8
|
+
- `POST /openapi/v1/glink/queryBusinessList`
|
|
9
|
+
- Required body fields: `cityCode`
|
|
10
|
+
- `glink.queryCountryList`
|
|
11
|
+
- `POST /openapi/v1/glink/queryCountryList`
|
|
12
|
+
- Required body fields: none
|
|
13
|
+
- `glink.queryHotelPlateList`
|
|
14
|
+
- `POST /openapi/v1/glink/queryHotelPlateList`
|
|
15
|
+
- Required body fields: none
|
|
16
|
+
- `glink.queryHotCityList`
|
|
17
|
+
- `POST /openapi/v1/glink/queryHotCityList`
|
|
18
|
+
- Required body fields: none
|
|
19
|
+
- `glink.queryDistrictList`
|
|
20
|
+
- `POST /openapi/v1/glink/queryDistrictList`
|
|
21
|
+
- Required body fields: `cityCode`
|
|
22
|
+
- `glink.queryDistrictAndBusiness`
|
|
23
|
+
- `POST /openapi/v1/glink/queryDistrictAndBusiness`
|
|
24
|
+
- Required body fields: `cityCode`
|
|
25
|
+
- `glink.queryCityList`
|
|
26
|
+
- `POST /openapi/v1/glink/queryCityList`
|
|
27
|
+
- Required body fields: `countryCode`
|
|
28
|
+
|
|
29
|
+
## Hotel Query
|
|
30
|
+
|
|
31
|
+
- `glink.queryCityAndHotelByKeyword`
|
|
32
|
+
- `POST /openapi/v1/glink/queryCityAndHotelByKeyword`
|
|
33
|
+
- Required body fields: `keyWord`
|
|
34
|
+
- `glink.getDestination`
|
|
35
|
+
- `POST /openapi/v1/glink/getDestination`
|
|
36
|
+
- Required body fields: `keyWord`
|
|
37
|
+
- Swagger example uses `keyword`; double-check the field naming against current backend behavior before coding around it.
|
|
38
|
+
- `glink.getHotelSearch`
|
|
39
|
+
- `POST /openapi/v1/glink/getHotelSearch`
|
|
40
|
+
- Required body fields: none
|
|
41
|
+
- Common fields: `cityCode`, `checkInDate`, `checkOutDate`, `roomNum`, `language`
|
|
42
|
+
- `glink.findHotelList`
|
|
43
|
+
- `POST /openapi/v1/glink/findHotelList`
|
|
44
|
+
- Required body fields from schema: `roomFacilityCodes`, `hotelFacilityCodes`, `checkInDate`, `checkOutDate`, `distance`
|
|
45
|
+
- Treat this as a high-friction route and inspect the real example payload before implementing.
|
|
46
|
+
- `glink.queryHotelAllList`
|
|
47
|
+
- `POST /openapi/v1/glink/queryHotelAllList`
|
|
48
|
+
- Required body fields: none
|
|
49
|
+
|
|
50
|
+
## Hotel Info
|
|
51
|
+
|
|
52
|
+
- `glink.queryHotelIdList`
|
|
53
|
+
- `POST /openapi/v1/glink/queryHotelIdList`
|
|
54
|
+
- Required body fields: none
|
|
55
|
+
- The Open Platform Glink onboarding flow commonly uses `cityCode` to fetch the account's saleable hotel IDs for that city; verify the current swagger/code example before generating strict DTOs.
|
|
56
|
+
- `glink.queryHotelInfo`
|
|
57
|
+
- `POST /openapi/v1/glink/queryHotelInfo`
|
|
58
|
+
- Required body fields: `hotelIds`
|
|
59
|
+
- `glink.queryHotelIncrement`
|
|
60
|
+
- `POST /openapi/v1/glink/queryHotelIncrement`
|
|
61
|
+
- Required body fields: `startTime`, `endTime`
|
|
62
|
+
- Swagger example uses `lastUpdateTime`; inspect schema versus example before generating code.
|
|
63
|
+
- `glink.queryHotelImage`
|
|
64
|
+
- `POST /openapi/v1/glink/queryHotelImage`
|
|
65
|
+
- Required body fields: `hotelIds`
|
|
66
|
+
- Swagger example uses `hotelId`; inspect schema versus example before generating code.
|
|
67
|
+
- `glink.queryHotelMainInfoByHotelIds`
|
|
68
|
+
- `POST /openapi/v1/glink/queryHotelMainInfoByHotelIds`
|
|
69
|
+
- Required body fields: `language`
|
|
70
|
+
|
|
71
|
+
## Product Info
|
|
72
|
+
|
|
73
|
+
- `glink.queryHotelLowestPrice`
|
|
74
|
+
- `POST /openapi/v1/glink/queryHotelLowestPrice`
|
|
75
|
+
- Required body fields: `hotelIds`
|
|
76
|
+
- `glink.queryProductDetail`
|
|
77
|
+
- `POST /openapi/v1/glink/queryProductDetail`
|
|
78
|
+
- Required body fields: `hotelId`, `checkInDate`, `checkOutDate`, `roomNum`
|
|
79
|
+
|
|
80
|
+
## Order Info
|
|
81
|
+
|
|
82
|
+
- `glink.checkBooking`
|
|
83
|
+
- `POST /openapi/v1/glink/checkBooking`
|
|
84
|
+
- Required body fields: `hotelId`, `checkInDate`, `checkOutDate`, `roomId`, `ratePlanId`, `roomNum`, `supplyCode`
|
|
85
|
+
- `glink.createOrder`
|
|
86
|
+
- `POST /openapi/v1/glink/createOrder`
|
|
87
|
+
- Required body fields: `hotelId`, `checkInDate`, `checkOutDate`, `roomId`, `ratePlanId`, `roomNum`, `supplyCode`, `totalAmount`, `coOrderCode`, `priceItems`, `guestInfos`, `linkMan`, `linkPhone`, `arriveTime`, `latestArriveTime`
|
|
88
|
+
- `glink.payOrder`
|
|
89
|
+
- `POST /openapi/v1/glink/payOrder`
|
|
90
|
+
- Required body fields: none
|
|
91
|
+
- Common fields: `coOrderCode`, `fcOrderCode`
|
|
92
|
+
- `glink.cancelOrder`
|
|
93
|
+
- `POST /openapi/v1/glink/cancelOrder`
|
|
94
|
+
- Required body fields: none
|
|
95
|
+
- Common fields: `coOrderCode`, `fcOrderCode`, `cancelReson`
|
|
96
|
+
- `glink.queryOrderDetail`
|
|
97
|
+
- `POST /openapi/v1/glink/queryOrderDetail`
|
|
98
|
+
- Required body fields: none
|
|
99
|
+
- Common fields: `coOrderCode`, `fcOrderCode`
|
|
100
|
+
- Glink order operation push/callback
|
|
101
|
+
- Required by the Open Platform Glink booking flow after `payOrder`.
|
|
102
|
+
- This is an inbound callback capability rather than a normal public `/openapi/v1/glink/*` request route in the current endpoint list. Before implementing, inspect route code or product requirements for the platform callback URL, signature/auth expectations, idempotency key, and retry handling.
|
|
103
|
+
- `glink.queryOrderCheckDetailInfo`
|
|
104
|
+
- `POST /openapi/v1/glink/queryOrderCheckDetailInfo`
|
|
105
|
+
- Required body fields: none
|
|
106
|
+
- Common fields: `coOrderCode`, `fcOrderCode`
|
|
107
|
+
- `glink.checkoutApply`
|
|
108
|
+
- `POST /openapi/v1/glink/checkoutApply`
|
|
109
|
+
- Required body fields: `fcOrderCode`, `checkoutReason`, `checkoutRoomInfoList`
|
|
110
|
+
- `glink.queryCheckoutDetail`
|
|
111
|
+
- `POST /openapi/v1/glink/queryCheckoutDetail`
|
|
112
|
+
- Required body fields: `taskOrderCode`
|
|
113
|
+
- Swagger example uses order codes instead of `taskOrderCode`; inspect the live contract before coding.
|
|
114
|
+
|
|
115
|
+
## Finance
|
|
116
|
+
|
|
117
|
+
- `glink.createInvoice`
|
|
118
|
+
- `POST /openapi/v1/glink/createInvoice`
|
|
119
|
+
- Business-required fields to focus on: `orderCode`, `invoiceTypeInteger`, `invoiceHeader`, `amount`, `applyId`, `invoiceTitleType`, `getMethod`
|
|
120
|
+
- Schema still marks `partnerCode` and `sign` as required, but route docs say the platform injects Glink auth fields. Do not send Glink-managed fields from the client.
|
|
121
|
+
- `glink.queryCreditBalance`
|
|
122
|
+
- `POST /openapi/v1/glink/queryCreditBalance`
|
|
123
|
+
- Required body fields: none
|
|
124
|
+
|
|
125
|
+
## Global Notes
|
|
126
|
+
|
|
127
|
+
- Most Glink routes accept plain business JSON bodies with no wrapper objects.
|
|
128
|
+
- Platform error responses can return `401`, `403`, `404`, `500`, `502`, or `504`.
|
|
129
|
+
- Common auth-related `401` codes are `APP_KEY_INVALID`, `SIGN_ERROR`, `TIMESTAMP_EXPIRED`, and `NONCE_REPLAY`.
|
|
130
|
+
- Common `403` cause is `PRODUCT_FORBIDDEN`.
|