@tatil/server-api 0.0.3 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tatil/server-api",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Tatilsepeti Server Api for Next.js server-side operations",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -22,8 +22,8 @@ class TatilsepetiApi {
22
22
  return endpoint.join('/');
23
23
  }
24
24
 
25
- fullEndpoint(endpoint) {
26
- return `${this.baseURL}/api/v1/${this.joinEndpoint(endpoint)}`;
25
+ fullEndpoint(endpoint, version = 'v1') {
26
+ return `${this.baseURL}/api/${version}/${this.joinEndpoint(endpoint)}`;
27
27
  }
28
28
 
29
29
  buildUrl(endpoint) {
@@ -89,10 +89,10 @@ class TatilsepetiApi {
89
89
  );
90
90
  }
91
91
 
92
- async get(endpoint, params = {}) {
92
+ async get(endpoint, params = {}, version = 'v1') {
93
93
  const endpointPath = this.getEndpointPath(endpoint);
94
94
  const logId = this.logger.start(endpointPath, 'GET');
95
- const url = this.buildUrl(endpoint);
95
+ const url = this.buildUrl(endpoint, version);
96
96
 
97
97
  const response = await this.instance.get(url, {
98
98
  params,
@@ -128,10 +128,10 @@ class TatilsepetiApi {
128
128
  return data;
129
129
  }
130
130
 
131
- async post(endpoint, body = {}) {
131
+ async post(endpoint, body = {}, version = 'v1') {
132
132
  const endpointPath = this.getEndpointPath(endpoint);
133
133
  const logId = this.logger.start(endpointPath, 'POST');
134
- const url = this.buildUrl(endpoint);
134
+ const url = this.buildUrl(endpoint, version);
135
135
 
136
136
  const response = await this.instance.post(url, body, {
137
137
  headers: await this.getAuthHeaders(),