apogeoapi 1.0.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/CHANGELOG.md +52 -0
- package/EXAMPLES.md +666 -0
- package/README.md +532 -0
- package/dist/clients/account.client.d.ts +76 -0
- package/dist/clients/account.client.d.ts.map +1 -0
- package/dist/clients/account.client.js +85 -0
- package/dist/clients/account.client.js.map +1 -0
- package/dist/clients/api-keys.client.d.ts +90 -0
- package/dist/clients/api-keys.client.d.ts.map +1 -0
- package/dist/clients/api-keys.client.js +105 -0
- package/dist/clients/api-keys.client.js.map +1 -0
- package/dist/clients/auth.client.d.ts +63 -0
- package/dist/clients/auth.client.d.ts.map +1 -0
- package/dist/clients/auth.client.js +86 -0
- package/dist/clients/auth.client.js.map +1 -0
- package/dist/clients/billing.client.d.ts +79 -0
- package/dist/clients/billing.client.d.ts.map +1 -0
- package/dist/clients/billing.client.js +101 -0
- package/dist/clients/billing.client.js.map +1 -0
- package/dist/clients/geo.client.d.ts +105 -0
- package/dist/clients/geo.client.d.ts.map +1 -0
- package/dist/clients/geo.client.js +149 -0
- package/dist/clients/geo.client.js.map +1 -0
- package/dist/clients/webhooks.client.d.ts +110 -0
- package/dist/clients/webhooks.client.d.ts.map +1 -0
- package/dist/clients/webhooks.client.js +129 -0
- package/dist/clients/webhooks.client.js.map +1 -0
- package/dist/index.d.ts +137 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +243 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/http-client.d.ts +43 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +140 -0
- package/dist/utils/http-client.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeoClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* GeoClient - Handles geography data queries
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const geo = new GeoClient(httpClient);
|
|
10
|
+
*
|
|
11
|
+
* // Get all countries
|
|
12
|
+
* const countries = await geo.getCountries();
|
|
13
|
+
*
|
|
14
|
+
* // Get country by ISO code
|
|
15
|
+
* const usa = await geo.getCountryByIso('US');
|
|
16
|
+
*
|
|
17
|
+
* // Get states of a country
|
|
18
|
+
* const usStates = await geo.getStates('US');
|
|
19
|
+
*
|
|
20
|
+
* // Search for cities
|
|
21
|
+
* const cities = await geo.searchCities({ query: 'New York', limit: 10 });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class GeoClient {
|
|
25
|
+
constructor(http) {
|
|
26
|
+
this.http = http;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get all countries
|
|
30
|
+
*
|
|
31
|
+
* @param limit - Maximum number of results (optional)
|
|
32
|
+
* @param offset - Pagination offset (optional)
|
|
33
|
+
* @returns Array of countries
|
|
34
|
+
*/
|
|
35
|
+
async getCountries(limit, offset) {
|
|
36
|
+
const params = {};
|
|
37
|
+
if (limit)
|
|
38
|
+
params.limit = limit;
|
|
39
|
+
if (offset)
|
|
40
|
+
params.offset = offset;
|
|
41
|
+
return this.http.get('/geo/countries', { params });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get country by ISO2 code
|
|
45
|
+
*
|
|
46
|
+
* @param iso2 - ISO2 country code (e.g., 'US', 'CA', 'MX')
|
|
47
|
+
* @returns Country data
|
|
48
|
+
*/
|
|
49
|
+
async getCountryByIso(iso2) {
|
|
50
|
+
return this.http.get(`/geo/countries/${iso2.toUpperCase()}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get states/provinces of a country
|
|
54
|
+
*
|
|
55
|
+
* @param countryIso2 - ISO2 country code
|
|
56
|
+
* @param limit - Maximum number of results (optional)
|
|
57
|
+
* @param offset - Pagination offset (optional)
|
|
58
|
+
* @returns Array of states
|
|
59
|
+
*/
|
|
60
|
+
async getStates(countryIso2, limit, offset) {
|
|
61
|
+
const params = {};
|
|
62
|
+
if (limit)
|
|
63
|
+
params.limit = limit;
|
|
64
|
+
if (offset)
|
|
65
|
+
params.offset = offset;
|
|
66
|
+
return this.http.get(`/geo/countries/${countryIso2.toUpperCase()}/states`, { params });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get state by ID
|
|
70
|
+
*
|
|
71
|
+
* @param stateId - State ID
|
|
72
|
+
* @returns State data
|
|
73
|
+
*/
|
|
74
|
+
async getStateById(stateId) {
|
|
75
|
+
return this.http.get(`/geo/states/${stateId}`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get cities of a state
|
|
79
|
+
*
|
|
80
|
+
* @param stateId - State ID
|
|
81
|
+
* @param limit - Maximum number of results (optional)
|
|
82
|
+
* @param offset - Pagination offset (optional)
|
|
83
|
+
* @returns Array of cities
|
|
84
|
+
*/
|
|
85
|
+
async getCities(stateId, limit, offset) {
|
|
86
|
+
const params = {};
|
|
87
|
+
if (limit)
|
|
88
|
+
params.limit = limit;
|
|
89
|
+
if (offset)
|
|
90
|
+
params.offset = offset;
|
|
91
|
+
return this.http.get(`/geo/states/${stateId}/cities`, { params });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get city by ID
|
|
95
|
+
*
|
|
96
|
+
* @param cityId - City ID
|
|
97
|
+
* @returns City data
|
|
98
|
+
*/
|
|
99
|
+
async getCityById(cityId) {
|
|
100
|
+
return this.http.get(`/geo/cities/${cityId}`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Search for countries, states, or cities
|
|
104
|
+
*
|
|
105
|
+
* @param params - Search parameters (query, limit, offset, type)
|
|
106
|
+
* @returns Paginated search results
|
|
107
|
+
*/
|
|
108
|
+
async search(params) {
|
|
109
|
+
return this.http.get('/geo/search', { params });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Search specifically for countries
|
|
113
|
+
*
|
|
114
|
+
* @param query - Search query
|
|
115
|
+
* @param limit - Maximum number of results (optional)
|
|
116
|
+
* @returns Array of matching countries
|
|
117
|
+
*/
|
|
118
|
+
async searchCountries(query, limit) {
|
|
119
|
+
return this.http.get('/geo/search', {
|
|
120
|
+
params: { query, type: 'country', limit },
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Search specifically for states
|
|
125
|
+
*
|
|
126
|
+
* @param query - Search query
|
|
127
|
+
* @param limit - Maximum number of results (optional)
|
|
128
|
+
* @returns Array of matching states
|
|
129
|
+
*/
|
|
130
|
+
async searchStates(query, limit) {
|
|
131
|
+
return this.http.get('/geo/search', {
|
|
132
|
+
params: { query, type: 'state', limit },
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Search specifically for cities
|
|
137
|
+
*
|
|
138
|
+
* @param query - Search query
|
|
139
|
+
* @param limit - Maximum number of results (optional)
|
|
140
|
+
* @returns Array of matching cities
|
|
141
|
+
*/
|
|
142
|
+
async searchCities(query, limit) {
|
|
143
|
+
return this.http.get('/geo/search', {
|
|
144
|
+
params: { query, type: 'city', limit },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.GeoClient = GeoClient;
|
|
149
|
+
//# sourceMappingURL=geo.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo.client.js","sourceRoot":"","sources":["../../src/clients/geo.client.ts"],"names":[],"mappings":";;;AASA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,SAAS;IACpB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;;OAMG;IACH,KAAK,CAAC,YAAY,CAAC,KAAc,EAAE,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,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,MAAc;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAO,eAAe,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,MAAuB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAyB,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,KAAa,EAAE,KAAc;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAY,aAAa,EAAE;YAC7C,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,KAAc;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,aAAa,EAAE;YAC3C,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE;SACxC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,KAAc;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAS,aAAa,EAAE;YAC1C,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;SACvC,CAAC,CAAC;IACL,CAAC;CACF;AA3ID,8BA2IC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { Webhook, CreateWebhookDto, UpdateWebhookDto, WebhookLog } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* WebhooksClient - Handles webhook management
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const webhooks = new WebhooksClient(httpClient);
|
|
9
|
+
*
|
|
10
|
+
* // Create webhook
|
|
11
|
+
* const webhook = await webhooks.create({
|
|
12
|
+
* url: 'https://myapp.com/webhooks/geo-api',
|
|
13
|
+
* events: ['usage.quota_warning', 'subscription.updated']
|
|
14
|
+
* });
|
|
15
|
+
* console.log('Webhook secret:', webhook.secret); // Use for validation
|
|
16
|
+
*
|
|
17
|
+
* // List webhooks
|
|
18
|
+
* const allWebhooks = await webhooks.list();
|
|
19
|
+
*
|
|
20
|
+
* // Test webhook
|
|
21
|
+
* await webhooks.test(webhook.id);
|
|
22
|
+
*
|
|
23
|
+
* // Get delivery logs
|
|
24
|
+
* const logs = await webhooks.getLogs(webhook.id);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class WebhooksClient {
|
|
28
|
+
private http;
|
|
29
|
+
constructor(http: HttpClient);
|
|
30
|
+
/**
|
|
31
|
+
* List all webhooks for the current user
|
|
32
|
+
*
|
|
33
|
+
* @returns Array of webhooks
|
|
34
|
+
*/
|
|
35
|
+
list(): Promise<Webhook[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Get specific webhook by ID
|
|
38
|
+
*
|
|
39
|
+
* @param id - Webhook ID
|
|
40
|
+
* @returns Webhook data
|
|
41
|
+
*/
|
|
42
|
+
get(id: string): Promise<Webhook>;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new webhook
|
|
45
|
+
*
|
|
46
|
+
* **Important:** Save the webhook secret for validating incoming webhooks
|
|
47
|
+
*
|
|
48
|
+
* @param data - Webhook creation data (url, events)
|
|
49
|
+
* @returns Newly created webhook with secret
|
|
50
|
+
*/
|
|
51
|
+
create(data: CreateWebhookDto): Promise<Webhook>;
|
|
52
|
+
/**
|
|
53
|
+
* Update webhook
|
|
54
|
+
*
|
|
55
|
+
* Can update URL, events, or activate/deactivate
|
|
56
|
+
*
|
|
57
|
+
* @param id - Webhook ID
|
|
58
|
+
* @param data - Update data (url, events, isActive)
|
|
59
|
+
* @returns Updated webhook
|
|
60
|
+
*/
|
|
61
|
+
update(id: string, data: UpdateWebhookDto): Promise<Webhook>;
|
|
62
|
+
/**
|
|
63
|
+
* Delete webhook permanently
|
|
64
|
+
*
|
|
65
|
+
* **Warning:** This action is irreversible
|
|
66
|
+
*
|
|
67
|
+
* @param id - Webhook ID
|
|
68
|
+
* @returns Success response
|
|
69
|
+
*/
|
|
70
|
+
delete(id: string): Promise<{
|
|
71
|
+
message: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Send a test event to the webhook
|
|
75
|
+
*
|
|
76
|
+
* Useful for testing webhook configuration and endpoint availability
|
|
77
|
+
*
|
|
78
|
+
* @param id - Webhook ID
|
|
79
|
+
* @returns Success response
|
|
80
|
+
*/
|
|
81
|
+
test(id: string): Promise<{
|
|
82
|
+
message: string;
|
|
83
|
+
success: boolean;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Get delivery logs for a webhook
|
|
87
|
+
*
|
|
88
|
+
* Shows history of webhook deliveries including success/failure status
|
|
89
|
+
*
|
|
90
|
+
* @param id - Webhook ID
|
|
91
|
+
* @param limit - Maximum number of logs to return (optional)
|
|
92
|
+
* @returns Array of webhook delivery logs
|
|
93
|
+
*/
|
|
94
|
+
getLogs(id: string, limit?: number): Promise<WebhookLog[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Deactivate webhook without deleting it
|
|
97
|
+
*
|
|
98
|
+
* @param id - Webhook ID
|
|
99
|
+
* @returns Updated webhook
|
|
100
|
+
*/
|
|
101
|
+
deactivate(id: string): Promise<Webhook>;
|
|
102
|
+
/**
|
|
103
|
+
* Reactivate a deactivated webhook
|
|
104
|
+
*
|
|
105
|
+
* @param id - Webhook ID
|
|
106
|
+
* @returns Updated webhook
|
|
107
|
+
*/
|
|
108
|
+
activate(id: string): Promise<Webhook>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=webhooks.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.client.d.ts","sourceRoot":"","sources":["../../src/clients/webhooks.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACX,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIhC;;;;;OAKG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvC;;;;;;;OAOG;IACG,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAItD;;;;;;;;OAQG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlE;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAItD;;;;;;;OAOG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAMtE;;;;;;;;OAQG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAOhE;;;;;OAKG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9C;;;;;OAKG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAG7C"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhooksClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* WebhooksClient - Handles webhook management
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const webhooks = new WebhooksClient(httpClient);
|
|
10
|
+
*
|
|
11
|
+
* // Create webhook
|
|
12
|
+
* const webhook = await webhooks.create({
|
|
13
|
+
* url: 'https://myapp.com/webhooks/geo-api',
|
|
14
|
+
* events: ['usage.quota_warning', 'subscription.updated']
|
|
15
|
+
* });
|
|
16
|
+
* console.log('Webhook secret:', webhook.secret); // Use for validation
|
|
17
|
+
*
|
|
18
|
+
* // List webhooks
|
|
19
|
+
* const allWebhooks = await webhooks.list();
|
|
20
|
+
*
|
|
21
|
+
* // Test webhook
|
|
22
|
+
* await webhooks.test(webhook.id);
|
|
23
|
+
*
|
|
24
|
+
* // Get delivery logs
|
|
25
|
+
* const logs = await webhooks.getLogs(webhook.id);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class WebhooksClient {
|
|
29
|
+
constructor(http) {
|
|
30
|
+
this.http = http;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* List all webhooks for the current user
|
|
34
|
+
*
|
|
35
|
+
* @returns Array of webhooks
|
|
36
|
+
*/
|
|
37
|
+
async list() {
|
|
38
|
+
return this.http.get('/webhooks');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get specific webhook by ID
|
|
42
|
+
*
|
|
43
|
+
* @param id - Webhook ID
|
|
44
|
+
* @returns Webhook data
|
|
45
|
+
*/
|
|
46
|
+
async get(id) {
|
|
47
|
+
return this.http.get(`/webhooks/${id}`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a new webhook
|
|
51
|
+
*
|
|
52
|
+
* **Important:** Save the webhook secret for validating incoming webhooks
|
|
53
|
+
*
|
|
54
|
+
* @param data - Webhook creation data (url, events)
|
|
55
|
+
* @returns Newly created webhook with secret
|
|
56
|
+
*/
|
|
57
|
+
async create(data) {
|
|
58
|
+
return this.http.post('/webhooks', data);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Update webhook
|
|
62
|
+
*
|
|
63
|
+
* Can update URL, events, or activate/deactivate
|
|
64
|
+
*
|
|
65
|
+
* @param id - Webhook ID
|
|
66
|
+
* @param data - Update data (url, events, isActive)
|
|
67
|
+
* @returns Updated webhook
|
|
68
|
+
*/
|
|
69
|
+
async update(id, data) {
|
|
70
|
+
return this.http.put(`/webhooks/${id}`, data);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Delete webhook permanently
|
|
74
|
+
*
|
|
75
|
+
* **Warning:** This action is irreversible
|
|
76
|
+
*
|
|
77
|
+
* @param id - Webhook ID
|
|
78
|
+
* @returns Success response
|
|
79
|
+
*/
|
|
80
|
+
async delete(id) {
|
|
81
|
+
return this.http.delete(`/webhooks/${id}`);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Send a test event to the webhook
|
|
85
|
+
*
|
|
86
|
+
* Useful for testing webhook configuration and endpoint availability
|
|
87
|
+
*
|
|
88
|
+
* @param id - Webhook ID
|
|
89
|
+
* @returns Success response
|
|
90
|
+
*/
|
|
91
|
+
async test(id) {
|
|
92
|
+
return this.http.post(`/webhooks/${id}/test`);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get delivery logs for a webhook
|
|
96
|
+
*
|
|
97
|
+
* Shows history of webhook deliveries including success/failure status
|
|
98
|
+
*
|
|
99
|
+
* @param id - Webhook ID
|
|
100
|
+
* @param limit - Maximum number of logs to return (optional)
|
|
101
|
+
* @returns Array of webhook delivery logs
|
|
102
|
+
*/
|
|
103
|
+
async getLogs(id, limit) {
|
|
104
|
+
const params = {};
|
|
105
|
+
if (limit)
|
|
106
|
+
params.limit = limit;
|
|
107
|
+
return this.http.get(`/webhooks/${id}/logs`, { params });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Deactivate webhook without deleting it
|
|
111
|
+
*
|
|
112
|
+
* @param id - Webhook ID
|
|
113
|
+
* @returns Updated webhook
|
|
114
|
+
*/
|
|
115
|
+
async deactivate(id) {
|
|
116
|
+
return this.update(id, { isActive: false });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Reactivate a deactivated webhook
|
|
120
|
+
*
|
|
121
|
+
* @param id - Webhook ID
|
|
122
|
+
* @returns Updated webhook
|
|
123
|
+
*/
|
|
124
|
+
async activate(id) {
|
|
125
|
+
return this.update(id, { isActive: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.WebhooksClient = WebhooksClient;
|
|
129
|
+
//# sourceMappingURL=webhooks.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.client.js","sourceRoot":"","sources":["../../src/clients/webhooks.client.ts"],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,cAAc;IACzB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAY,WAAW,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,aAAa,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,IAAsB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAU,WAAW,EAAE,IAAI,CA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geographic data API with comprehensive country, state, and city information.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { GeoAPI } from '@geo-api/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Initialize with API key
|
|
11
|
+
* const client = new GeoAPI({
|
|
12
|
+
* apiKey: 'geoapi_live_xxxxx',
|
|
13
|
+
* baseURL: 'https://api.yourcompany.com/v1'
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Use the API
|
|
17
|
+
* const countries = await client.geo.getCountries();
|
|
18
|
+
* const usage = await client.account.getDashboard();
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @packageDocumentation
|
|
22
|
+
*/
|
|
23
|
+
import { AuthClient } from './clients/auth.client';
|
|
24
|
+
import { GeoClient } from './clients/geo.client';
|
|
25
|
+
import { AccountClient } from './clients/account.client';
|
|
26
|
+
import { ApiKeysClient } from './clients/api-keys.client';
|
|
27
|
+
import { BillingClient } from './clients/billing.client';
|
|
28
|
+
import { WebhooksClient } from './clients/webhooks.client';
|
|
29
|
+
import { SDKConfig } from './types';
|
|
30
|
+
/**
|
|
31
|
+
* Main SDK class
|
|
32
|
+
*
|
|
33
|
+
* Provides access to all API modules:
|
|
34
|
+
* - `auth` - Authentication (login, register, refresh token)
|
|
35
|
+
* - `geo` - Geography data (countries, states, cities)
|
|
36
|
+
* - `account` - User account management
|
|
37
|
+
* - `apiKeys` - API keys CRUD
|
|
38
|
+
* - `billing` - Subscription and billing
|
|
39
|
+
* - `webhooks` - Webhook management
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const client = new GeoAPI({
|
|
44
|
+
* apiKey: 'geoapi_live_xxxxx'
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Get countries
|
|
48
|
+
* const countries = await client.geo.getCountries();
|
|
49
|
+
*
|
|
50
|
+
* // Login
|
|
51
|
+
* const { access_token } = await client.auth.login({
|
|
52
|
+
* email: 'user@example.com',
|
|
53
|
+
* password: 'password123'
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Get dashboard
|
|
57
|
+
* const dashboard = await client.account.getDashboard();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class GeoAPI {
|
|
61
|
+
private httpClient;
|
|
62
|
+
/**
|
|
63
|
+
* Authentication client
|
|
64
|
+
*/
|
|
65
|
+
readonly auth: AuthClient;
|
|
66
|
+
/**
|
|
67
|
+
* Geography data client
|
|
68
|
+
*/
|
|
69
|
+
readonly geo: GeoClient;
|
|
70
|
+
/**
|
|
71
|
+
* User account client
|
|
72
|
+
*/
|
|
73
|
+
readonly account: AccountClient;
|
|
74
|
+
/**
|
|
75
|
+
* API keys management client
|
|
76
|
+
*/
|
|
77
|
+
readonly apiKeys: ApiKeysClient;
|
|
78
|
+
/**
|
|
79
|
+
* Billing and subscription client
|
|
80
|
+
*/
|
|
81
|
+
readonly billing: BillingClient;
|
|
82
|
+
/**
|
|
83
|
+
* Webhooks management client
|
|
84
|
+
*/
|
|
85
|
+
readonly webhooks: WebhooksClient;
|
|
86
|
+
/**
|
|
87
|
+
* Create a new Geo API client
|
|
88
|
+
*
|
|
89
|
+
* @param config - SDK configuration
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* // With API key (recommended for client-side)
|
|
94
|
+
* const client = new GeoAPI({
|
|
95
|
+
* apiKey: 'geoapi_live_xxxxx'
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // With JWT token (for server-side after login)
|
|
99
|
+
* const client = new GeoAPI({
|
|
100
|
+
* token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // With custom configuration
|
|
104
|
+
* const client = new GeoAPI({
|
|
105
|
+
* apiKey: 'geoapi_live_xxxxx',
|
|
106
|
+
* baseURL: 'https://api.yourcompany.com/v1',
|
|
107
|
+
* timeout: 30000,
|
|
108
|
+
* retries: 3,
|
|
109
|
+
* debug: true
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
constructor(config: SDKConfig);
|
|
114
|
+
/**
|
|
115
|
+
* Update authentication token
|
|
116
|
+
*
|
|
117
|
+
* Useful after login or token refresh
|
|
118
|
+
*
|
|
119
|
+
* @param token - New JWT token
|
|
120
|
+
*/
|
|
121
|
+
setToken(token: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Update API key
|
|
124
|
+
*
|
|
125
|
+
* @param apiKey - New API key
|
|
126
|
+
*/
|
|
127
|
+
setApiKey(apiKey: string): void;
|
|
128
|
+
}
|
|
129
|
+
export * from './types';
|
|
130
|
+
export { AuthClient } from './clients/auth.client';
|
|
131
|
+
export { GeoClient } from './clients/geo.client';
|
|
132
|
+
export { AccountClient } from './clients/account.client';
|
|
133
|
+
export { ApiKeysClient } from './clients/api-keys.client';
|
|
134
|
+
export { BillingClient } from './clients/billing.client';
|
|
135
|
+
export { WebhooksClient } from './clients/webhooks.client';
|
|
136
|
+
export default GeoAPI;
|
|
137
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,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