@vintr/node-sdk 1.0.0 → 1.1.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 +18 -6
- package/dist/alias.js +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +12 -8
- package/dist/types.d.ts +20 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,25 +11,31 @@ npm install @vintr/node-sdk
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Vintr } from
|
|
14
|
+
import { Vintr } from "@vintr/node-sdk";
|
|
15
15
|
|
|
16
|
-
const vintr = new Vintr(
|
|
16
|
+
const vintr = new Vintr("vintr_secret_key");
|
|
17
17
|
|
|
18
|
-
const location = await vintr.alias.resolve({
|
|
18
|
+
const location = await vintr.alias.resolve({
|
|
19
|
+
alias: "apple#vintr",
|
|
20
|
+
code: "ABCDEF", // Alias owner-provided 6-letter authorization code
|
|
21
|
+
});
|
|
19
22
|
```
|
|
20
23
|
|
|
21
24
|
## API
|
|
22
25
|
|
|
23
|
-
### `vintr.alias.resolve({ alias })`
|
|
26
|
+
### `vintr.alias.resolve({ alias, code })`
|
|
24
27
|
|
|
25
28
|
Resolves an alias to its associated location and metadata.
|
|
26
29
|
|
|
27
30
|
**Parameters:**
|
|
28
|
-
|
|
31
|
+
|
|
32
|
+
- `alias` (string, required): The alias to resolve (e.g., `apple#vintr`, `asteik#vintr`, `sushi#vintr`)
|
|
33
|
+
- `code` (string, required): A 6-letter authorization code to resolve the alias
|
|
29
34
|
|
|
30
35
|
**Returns:** `AliasResponse` with location details, coordinates, and delivery instructions.
|
|
31
36
|
|
|
32
37
|
**Sample Response:**
|
|
38
|
+
|
|
33
39
|
```typescript
|
|
34
40
|
{
|
|
35
41
|
alias: "apple#vintr",
|
|
@@ -66,5 +72,11 @@ Resolves an alias to its associated location and metadata.
|
|
|
66
72
|
Full TypeScript support included with exported types:
|
|
67
73
|
|
|
68
74
|
```typescript
|
|
69
|
-
import type {
|
|
75
|
+
import type {
|
|
76
|
+
AliasResponse,
|
|
77
|
+
Location,
|
|
78
|
+
Address,
|
|
79
|
+
Geo,
|
|
80
|
+
Instructions,
|
|
81
|
+
} from "@vintr/node-sdk";
|
|
70
82
|
```
|
package/dist/alias.js
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AliasResponse } from './types.js';
|
|
1
|
+
import type { AliasResponse, ResolveAliasParams } from './types.js';
|
|
2
2
|
export declare class VintrClient {
|
|
3
3
|
private apiKey;
|
|
4
4
|
private readonly baseUrl;
|
|
5
5
|
constructor(apiKey: string);
|
|
6
6
|
private request;
|
|
7
|
-
resolveAlias(
|
|
7
|
+
resolveAlias(params: ResolveAliasParams): Promise<AliasResponse>;
|
|
8
8
|
}
|
package/dist/client.js
CHANGED
|
@@ -4,18 +4,20 @@ export class VintrClient {
|
|
|
4
4
|
this.baseUrl = 'https://api.vintr.xyz';
|
|
5
5
|
this.apiKey = apiKey;
|
|
6
6
|
}
|
|
7
|
-
async request(path) {
|
|
7
|
+
async request(path, headers) {
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
const url = new URL(path, this.baseUrl);
|
|
10
|
+
const defaultHeaders = {
|
|
11
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
};
|
|
14
|
+
const allHeaders = { ...defaultHeaders, ...headers };
|
|
10
15
|
const options = {
|
|
11
16
|
hostname: url.hostname,
|
|
12
17
|
port: url.port || 443,
|
|
13
|
-
path: url.pathname,
|
|
18
|
+
path: url.pathname + url.search,
|
|
14
19
|
method: 'GET',
|
|
15
|
-
headers:
|
|
16
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
},
|
|
20
|
+
headers: allHeaders,
|
|
19
21
|
};
|
|
20
22
|
const req = https.request(options, (res) => {
|
|
21
23
|
let data = '';
|
|
@@ -38,7 +40,9 @@ export class VintrClient {
|
|
|
38
40
|
req.end();
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
|
-
async resolveAlias(
|
|
42
|
-
|
|
43
|
+
async resolveAlias(params) {
|
|
44
|
+
const url = new URL(`/${params.alias}`, this.baseUrl);
|
|
45
|
+
url.searchParams.append('code', params.code);
|
|
46
|
+
return this.request(url.pathname + url.search);
|
|
43
47
|
}
|
|
44
48
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
export interface Address {
|
|
2
|
-
line1
|
|
2
|
+
line1?: string;
|
|
3
3
|
line2?: string;
|
|
4
4
|
line3?: string;
|
|
5
|
-
city
|
|
6
|
-
state
|
|
7
|
-
postal_code
|
|
8
|
-
country
|
|
5
|
+
city?: string;
|
|
6
|
+
state?: string;
|
|
7
|
+
postal_code?: string;
|
|
8
|
+
country?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface Geo {
|
|
11
|
-
latitude
|
|
12
|
-
longitude
|
|
13
|
-
altitude
|
|
14
|
-
precision_meters
|
|
11
|
+
latitude?: number;
|
|
12
|
+
longitude?: number;
|
|
13
|
+
altitude?: number | null;
|
|
14
|
+
precision_meters?: number;
|
|
15
15
|
}
|
|
16
16
|
export interface Instructions {
|
|
17
|
-
general
|
|
18
|
-
delivery
|
|
19
|
-
autonomous
|
|
17
|
+
general?: string;
|
|
18
|
+
delivery?: string;
|
|
19
|
+
autonomous?: string;
|
|
20
20
|
}
|
|
21
21
|
export interface Location {
|
|
22
|
-
address
|
|
23
|
-
geo
|
|
24
|
-
instructions
|
|
22
|
+
address?: Address;
|
|
23
|
+
geo?: Geo;
|
|
24
|
+
instructions?: Instructions;
|
|
25
25
|
}
|
|
26
26
|
export interface AliasResponse {
|
|
27
27
|
alias: string;
|
|
28
|
-
type
|
|
29
|
-
location
|
|
30
|
-
createdAt
|
|
31
|
-
updatedAt
|
|
28
|
+
type?: 'business' | 'individual';
|
|
29
|
+
location?: Location;
|
|
30
|
+
createdAt?: string;
|
|
31
|
+
updatedAt?: string;
|
|
32
32
|
}
|
|
33
33
|
export interface ErrorResponse {
|
|
34
34
|
error: string;
|
|
35
35
|
}
|
|
36
36
|
export interface ResolveAliasParams {
|
|
37
37
|
alias: string;
|
|
38
|
+
code: string;
|
|
38
39
|
}
|