@geophrase/core 1.6.1 → 1.7.0
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/README.md +1 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/index.js +3 -0
package/README.md
CHANGED
|
@@ -85,6 +85,7 @@ const geo = new Geophrase({
|
|
|
85
85
|
| `key` | `string` | **Conditional** | Your secret [Geophrase API key](https://geophrase.com/docs/api-keys). **Required if `mode` is `'client'`.** Omit if using server mode. |
|
|
86
86
|
| `theme` | `string` | Optional | `'light'`, `'dark'`, or `'system'`. Defaults to `'system'`. |
|
|
87
87
|
| `orderId` | `string` | Optional | Your internal reference ID for this checkout session. |
|
|
88
|
+
| `noteForAgent` | `string` | Optional | Note shown to your delivery agent, never to the customer. Client mode only; notes over 300 characters are cut. It is sent from the customer's device, so the customer can change it; send payment instructions, such as cash to collect, from your server or the dashboard. In server mode, send `note_for_agent` with your [resolve call](https://geophrase.com/docs/resolve-endpoint). |
|
|
88
89
|
| `phone` | `string` | Optional | The customer's 10-digit phone number (pre-fills the widget). |
|
|
89
90
|
| `onSuccess` | `function` | **Yes** | Called upon completion. Returns an `Address` object (`mode: 'client'`) or a `Token` object (`mode: 'server'`). |
|
|
90
91
|
| `onError` | `function` | Optional | Called if the API fails or a network error occurs. Returns an `Error` object. |
|
package/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export interface GeophraseOptions {
|
|
|
38
38
|
theme?: 'light' | 'dark' | 'system';
|
|
39
39
|
key?: string;
|
|
40
40
|
orderId?: string;
|
|
41
|
+
noteForAgent?: string;
|
|
41
42
|
phone?: string;
|
|
42
43
|
onSuccess: (result: GeophraseAddress | GeophraseRequestId) => void;
|
|
43
44
|
onError?: (error: GeophraseError) => void;
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -37,6 +37,7 @@ class Geophrase {
|
|
|
37
37
|
this.keyId = options.keyId;
|
|
38
38
|
this.apiKey = this.mode === 'client' ? options.key : null;
|
|
39
39
|
this.orderId = options.orderId;
|
|
40
|
+
this.noteForAgent = options.noteForAgent;
|
|
40
41
|
this.phone = options.phone;
|
|
41
42
|
|
|
42
43
|
// 4. Theme validation
|
|
@@ -336,6 +337,8 @@ class Geophrase {
|
|
|
336
337
|
|
|
337
338
|
const payload = { request_id: data.requestId };
|
|
338
339
|
if (this.orderId) payload.order_id = this.orderId;
|
|
340
|
+
// Cut to the API's limit: a longer note would fail the whole address capture.
|
|
341
|
+
if (this.noteForAgent) payload.note_for_agent = String(this.noteForAgent).slice(0, 300);
|
|
339
342
|
|
|
340
343
|
try {
|
|
341
344
|
const response = await fetch(`${this.apiBase}/business/resolve/`, {
|