@flexbe/sdk 0.2.9 → 0.2.11

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.
@@ -64,6 +64,14 @@ export class ApiClient {
64
64
  };
65
65
  }
66
66
  }
67
+ // Handle 204 No Content response
68
+ if (response.status === 204) {
69
+ return {
70
+ data: null,
71
+ status: response.status,
72
+ statusText: response.statusText,
73
+ };
74
+ }
67
75
  const data = yield response.json();
68
76
  return {
69
77
  data,
@@ -1,6 +1,7 @@
1
1
  import { FlexbeAuthType } from '../types';
2
2
  import { ApiClient } from './api-client';
3
3
  import { SiteApi } from './site-api';
4
+ import { MetaApi } from './meta-api';
4
5
  export class FlexbeClient {
5
6
  constructor(config) {
6
7
  this.siteApis = new Map();
@@ -20,6 +21,7 @@ export class FlexbeClient {
20
21
  throw new Error('API key is required when using apiKey authentication. Please provide it either through config or FLEXBE_API_KEY environment variable.');
21
22
  }
22
23
  this.api = new ApiClient(this.config);
24
+ this.meta = new MetaApi(this.api);
23
25
  }
24
26
  /**
25
27
  * Get a SiteApi instance for a specific site
@@ -0,0 +1,50 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export class MetaApi {
11
+ constructor(api) {
12
+ this.api = api;
13
+ }
14
+ /**
15
+ * Get list of available site languages
16
+ * @returns Promise with list of site languages
17
+ */
18
+ getSiteLanguages() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const response = yield this.api.get('/meta/site-languages', {
21
+ headers: { 'Authorization': '' }
22
+ });
23
+ return response.data;
24
+ });
25
+ }
26
+ /**
27
+ * Get list of available user interface languages
28
+ * @returns Promise with list of user languages
29
+ */
30
+ getUserLanguages() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const response = yield this.api.get('/meta/user-languages', {
33
+ headers: { 'Authorization': '' }
34
+ });
35
+ return response.data;
36
+ });
37
+ }
38
+ /**
39
+ * Get list of available currencies
40
+ * @returns Promise with list of currencies
41
+ */
42
+ getSiteCurrencies() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const response = yield this.api.get('/meta/site-currencies', {
45
+ headers: { 'Authorization': '' }
46
+ });
47
+ return response.data;
48
+ });
49
+ }
50
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -64,6 +64,14 @@ class ApiClient {
64
64
  };
65
65
  }
66
66
  }
67
+ // Handle 204 No Content response
68
+ if (response.status === 204) {
69
+ return {
70
+ data: null,
71
+ status: response.status,
72
+ statusText: response.statusText,
73
+ };
74
+ }
67
75
  const data = await response.json();
68
76
  return {
69
77
  data,
@@ -4,6 +4,7 @@ exports.FlexbeClient = void 0;
4
4
  const types_1 = require("../types");
5
5
  const api_client_1 = require("./api-client");
6
6
  const site_api_1 = require("./site-api");
7
+ const meta_api_1 = require("./meta-api");
7
8
  class FlexbeClient {
8
9
  constructor(config) {
9
10
  this.siteApis = new Map();
@@ -23,6 +24,7 @@ class FlexbeClient {
23
24
  throw new Error('API key is required when using apiKey authentication. Please provide it either through config or FLEXBE_API_KEY environment variable.');
24
25
  }
25
26
  this.api = new api_client_1.ApiClient(this.config);
27
+ this.meta = new meta_api_1.MetaApi(this.api);
26
28
  }
27
29
  /**
28
30
  * Get a SiteApi instance for a specific site
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetaApi = void 0;
4
+ class MetaApi {
5
+ constructor(api) {
6
+ this.api = api;
7
+ }
8
+ /**
9
+ * Get list of available site languages
10
+ * @returns Promise with list of site languages
11
+ */
12
+ async getSiteLanguages() {
13
+ const response = await this.api.get('/meta/site-languages', {
14
+ headers: { 'Authorization': '' }
15
+ });
16
+ return response.data;
17
+ }
18
+ /**
19
+ * Get list of available user interface languages
20
+ * @returns Promise with list of user languages
21
+ */
22
+ async getUserLanguages() {
23
+ const response = await this.api.get('/meta/user-languages', {
24
+ headers: { 'Authorization': '' }
25
+ });
26
+ return response.data;
27
+ }
28
+ /**
29
+ * Get list of available currencies
30
+ * @returns Promise with list of currencies
31
+ */
32
+ async getSiteCurrencies() {
33
+ const response = await this.api.get('/meta/site-currencies', {
34
+ headers: { 'Authorization': '' }
35
+ });
36
+ return response.data;
37
+ }
38
+ }
39
+ exports.MetaApi = MetaApi;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -61,6 +61,14 @@ export class ApiClient {
61
61
  };
62
62
  }
63
63
  }
64
+ // Handle 204 No Content response
65
+ if (response.status === 204) {
66
+ return {
67
+ data: null,
68
+ status: response.status,
69
+ statusText: response.statusText,
70
+ };
71
+ }
64
72
  const data = await response.json();
65
73
  return {
66
74
  data,
@@ -1,6 +1,7 @@
1
1
  import { FlexbeAuthType } from '../types';
2
2
  import { ApiClient } from './api-client';
3
3
  import { SiteApi } from './site-api';
4
+ import { MetaApi } from './meta-api';
4
5
  export class FlexbeClient {
5
6
  constructor(config) {
6
7
  this.siteApis = new Map();
@@ -20,6 +21,7 @@ export class FlexbeClient {
20
21
  throw new Error('API key is required when using apiKey authentication. Please provide it either through config or FLEXBE_API_KEY environment variable.');
21
22
  }
22
23
  this.api = new ApiClient(this.config);
24
+ this.meta = new MetaApi(this.api);
23
25
  }
24
26
  /**
25
27
  * Get a SiteApi instance for a specific site
@@ -0,0 +1,35 @@
1
+ export class MetaApi {
2
+ constructor(api) {
3
+ this.api = api;
4
+ }
5
+ /**
6
+ * Get list of available site languages
7
+ * @returns Promise with list of site languages
8
+ */
9
+ async getSiteLanguages() {
10
+ const response = await this.api.get('/meta/site-languages', {
11
+ headers: { 'Authorization': '' }
12
+ });
13
+ return response.data;
14
+ }
15
+ /**
16
+ * Get list of available user interface languages
17
+ * @returns Promise with list of user languages
18
+ */
19
+ async getUserLanguages() {
20
+ const response = await this.api.get('/meta/user-languages', {
21
+ headers: { 'Authorization': '' }
22
+ });
23
+ return response.data;
24
+ }
25
+ /**
26
+ * Get list of available currencies
27
+ * @returns Promise with list of currencies
28
+ */
29
+ async getSiteCurrencies() {
30
+ const response = await this.api.get('/meta/site-currencies', {
31
+ headers: { 'Authorization': '' }
32
+ });
33
+ return response.data;
34
+ }
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,11 @@
1
1
  import { FlexbeConfig } from '../types';
2
2
  import { SiteApi } from './site-api';
3
+ import { MetaApi } from './meta-api';
3
4
  export declare class FlexbeClient {
4
5
  private readonly config;
5
6
  private readonly api;
6
7
  private readonly siteApis;
8
+ readonly meta: MetaApi;
7
9
  constructor(config?: Partial<FlexbeConfig>);
8
10
  /**
9
11
  * Get a SiteApi instance for a specific site
@@ -0,0 +1,21 @@
1
+ import { ApiClient } from './api-client';
2
+ import { SiteCurrency, SiteLanguage, UserLanguage } from '../types/meta';
3
+ export declare class MetaApi {
4
+ private readonly api;
5
+ constructor(api: ApiClient);
6
+ /**
7
+ * Get list of available site languages
8
+ * @returns Promise with list of site languages
9
+ */
10
+ getSiteLanguages(): Promise<SiteLanguage[]>;
11
+ /**
12
+ * Get list of available user interface languages
13
+ * @returns Promise with list of user languages
14
+ */
15
+ getUserLanguages(): Promise<UserLanguage[]>;
16
+ /**
17
+ * Get list of available currencies
18
+ * @returns Promise with list of currencies
19
+ */
20
+ getSiteCurrencies(): Promise<SiteCurrency[]>;
21
+ }
@@ -0,0 +1,17 @@
1
+ export interface SiteCurrency {
2
+ code: string;
3
+ name: string;
4
+ symbol: string;
5
+ symbolVariants?: string[];
6
+ decimals: number;
7
+ }
8
+ export interface SiteLanguage {
9
+ code: string;
10
+ nameEn: string;
11
+ nameNative: string;
12
+ }
13
+ export interface UserLanguage {
14
+ code: string;
15
+ nameEn: string;
16
+ nameNative: string;
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexbe/sdk",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "TypeScript SDK for Flexbe API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",