@hyphen/sdk 1.10.0 → 1.12.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 CHANGED
@@ -24,6 +24,16 @@ The Hyphen Node.js SDK is a JavaScript library that allows developers to easily
24
24
  - [Loading Environment Variables](#loading-environment-variables)
25
25
  - [Net Info - Geo Information Service](#net-info---geo-information-service)
26
26
  - [Link - Short Code Service](#link---short-code-service)
27
+ - [Creating a Short Code](#creating-a-short-code)
28
+ - [Updating a Short Code](#updating-a-short-code)
29
+ - [Getting a Short Code](#getting-a-short-code)
30
+ - [Getting Short Codes](#getting-short-codes)
31
+ - [Getting all Organization Tags](#getting-all-organization-tags)
32
+ - [Getting Short Code Stats](#getting-short-code-stats)
33
+ - [Deleting a Short Code](#deleting-a-short-code)
34
+ - [Creating a QR Code from a Short Code](#creating-a-qr-code-from-a-short-code)
35
+ - [Get QR Codes for a Short Code](#get-qr-codes-for-a-short-code)
36
+ - [Deleting a QR Code](#deleting-a-qr-code)
27
37
  - [Contributing](#contributing)
28
38
  - [Testing Your Changes](#testing-your-changes)
29
39
  - [License and Copyright](#license-and-copyright)
@@ -577,44 +587,44 @@ console.log('Boolean toggle value:', result); // true
577
587
  Hyphens secret management service known as [ENV](https://hyphen.ai/env) allows you to manage your environment variables in a secure way. The Hyphen Node.js SDK provides a simple way to access your environment variables.
578
588
 
579
589
  ## Loading Environment Variables
580
- To load your environment variables, you can use the `loadEnv` function from the SDK. This function will automatically load your environment variables from the `.env` file and then override them with the environment based environment file if it exists (ex: `.env.development`). This is useful for managing different environments such as development, staging, and production.
590
+ To load your environment variables, you can use the `env()` function from the SDK. This function will automatically load your environment variables from the `.env` file and then override them with the environment based environment file if it exists (ex: `.env.development`). This is useful for managing different environments such as development, staging, and production.
581
591
 
582
592
  The following override path is:
583
593
  ```
584
594
  .env -> .env.local -> .env.<environment> -> .env.<environment>.local
585
595
  ```
586
596
 
587
- Here is an example of how to use the `loadEnv` function:
597
+ Here is an example of how to use the `env()` function:
588
598
 
589
599
  ```javascript
590
- import { loadEnv } from '@hyphen/sdk';
600
+ import { env } from '@hyphen/sdk';
591
601
 
592
602
  //load your default environment variables and envrionment variables
593
- loadEnv();
603
+ env();
594
604
  ```
595
605
 
596
606
  If your environment variables are not stored in the root of your project you can specify the path to your `.env` file:
597
607
 
598
608
  ```javascript
599
- import { loadEnv } from '@hyphen/sdk';
609
+ import { env } from '@hyphen/sdk';
600
610
  //load your default environment variables and envrionment variables
601
- loadEnv({ path: '/path/to/your/env/files/' });
611
+ env({ path: '/path/to/your/env/files/' });
602
612
  ```
603
613
 
604
614
  You can also specify the environment variables to load by passing an array of variable names:
605
615
 
606
616
  ```javascript
607
- import { loadEnv } from '@hyphen/sdk';
617
+ import { env } from '@hyphen/sdk';
608
618
  //load your default environment variables and envrionment variables
609
- loadEnv({ environment: 'development' });
619
+ env({ environment: 'development' });
610
620
  ```
611
621
 
612
622
  if you want to turn off the local environment variables you can do it like this:
613
623
 
614
624
  ```javascript
615
- import { loadEnv } from '@hyphen/sdk';
625
+ import { env } from '@hyphen/sdk';
616
626
  //load your default environment variables and envrionment variables
617
- loadEnv({ local: false });
627
+ env({ local: false });
618
628
  ```
619
629
 
620
630
  # Net Info - Geo Information Service
@@ -653,7 +663,14 @@ You can also set the API key using the `HYPHEN_API_KEY` environment variable. Th
653
663
 
654
664
  # Link - Short Code Service
655
665
 
656
- The Hyphen Node.js SDK also provides a `Link` class that allows you to create and manage short codes. This can be useful for generating short links for your application. Here is an example of creating a short code:
666
+ The Hyphen Node.js SDK also provides a `Link` class that allows you to create and manage short codes. This can be useful for generating short links for your application.
667
+
668
+ * [Website](https://hyphen.ai/link)
669
+ * [Guides](https://docs.hyphen.ai/docs/create-short-link)
670
+ * [API Reference](https://docs.hyphen.ai/reference/post_api-organizations-organizationid-link-codes)
671
+
672
+ ## Creating a Short Code
673
+ To create a short code, you can use the `createShortCode` method:
657
674
 
658
675
  ```javascript
659
676
  import { Link } from '@hyphen/sdk';
@@ -670,6 +687,88 @@ const response = await link.createShortCode(longUrl, domain, options);
670
687
  console.log('Short Code Response:', response);
671
688
  ```
672
689
 
690
+ ## Updating a Short Code
691
+ To update a short code, you can use the `updateShortCode` method:
692
+
693
+ ```javascript
694
+ import { Link } from '@hyphen/sdk';
695
+ const link = new Link({
696
+ organizationId: 'your_organization_id',
697
+ apiKey: 'your_api_key',
698
+ });
699
+ const code = 'code_1234567890'; // It is the code identifier for the short code you want to update
700
+ const longUrl = 'https://hyphen.ai/updated';
701
+ const options = {
702
+ title: 'Updated Short Code',
703
+ tags: ['sdk-test', 'unit-test'],
704
+ long_url: longUrl,
705
+ };
706
+
707
+ const updateResponse = await link.updateShortCode(code, options);
708
+ console.log('Update Short Code Response:', updateResponse);
709
+ ```
710
+
711
+ ## Getting a Short Code
712
+ To get a short code, you can use the `getShortCode` method:
713
+
714
+ ```javascript
715
+ import { Link } from '@hyphen/sdk';
716
+ const link = new Link({
717
+ organizationId: 'your_organization_id',
718
+ apiKey: 'your_api_key',
719
+ });
720
+ const code = 'code_1234567890'; // It is the code identifier for the short code you want to get
721
+ const response = await link.getShortCode(code);
722
+ console.log('Get Short Code Response:', response);
723
+ ```
724
+
725
+ ## Getting Short Codes
726
+ To get a list of short codes, you can use the `getShortCodes` method:
727
+
728
+ ```javascript
729
+ import { Link } from '@hyphen/sdk';
730
+ const link = new Link({
731
+ organizationId: 'your_organization_id',
732
+ apiKey: 'your_api_key',
733
+ });
734
+ const title = 'My Short Codes'; // Optional title to filter short codes
735
+ const tags = ['sdk-test', 'unit-test']; // Optional tags to filter short codes
736
+ const response = await link.getShortCodes(title, tags);
737
+ console.log('Get Short Codes Response:', response);
738
+ ```
739
+
740
+ ## Getting all Organization Tags
741
+
742
+ To get all tags for your organization, you can use the `getTags` method:
743
+
744
+ ```javascript
745
+ import { Link } from '@hyphen/sdk';
746
+ const link = new Link({
747
+ organizationId: 'your_organization_id',
748
+ apiKey: 'your_api_key',
749
+ });
750
+ const response = await link.getTags();
751
+ console.log('Get Tags Response:', response);
752
+ ```
753
+
754
+ ## Get Short Code Stats
755
+
756
+ To get the stats for a short code, you can use the `getShortCodeStats` method:
757
+
758
+ ```javascript
759
+ import { Link } from '@hyphen/sdk';
760
+ const link = new Link({
761
+ organizationId: 'your_organization_id',
762
+ apiKey: 'your_api_key',
763
+ });
764
+ const code = 'code_1234567890'; // It is the code identifier for the short code
765
+ const startDate = new Date('2023-01-01'); // Optional start date for the stats
766
+ const endDate = new Date('2023-12-31'); // Optional end date for the stats
767
+ const response = await link.getShortCodeStats(code, startDate, endDate);
768
+ console.log('Get Short Code Stats Response:', response);
769
+ ```
770
+
771
+ ## Deleting a Short Code
673
772
  if you want to delete a short code you can do it like this:
674
773
 
675
774
  ```javascript
@@ -683,6 +782,100 @@ const response = await link.deleteShortCode(code);
683
782
  console.log('Delete Short Code Response:', response);
684
783
  ```
685
784
 
785
+ ## Creating a QR Code from a Short Code
786
+
787
+ To create a QR code from a short code, you can use the `createQrCode` method:
788
+
789
+ ```javascript
790
+ import { Link } from '@hyphen/sdk';
791
+ const link = new Link({
792
+ organizationId: 'your_organization_id',
793
+ apiKey: 'your_api_key',
794
+ });
795
+ const code = 'code_1234567890'; // It is the code identifier for the short code you want to create a QR code for
796
+ const response = await link.createQrCode(code);
797
+ console.log('Create QR Code Response:', response);
798
+ ```
799
+
800
+ There are options that you can pass in to the `createQrCode` method to customize the QR code:
801
+
802
+ ```typescript
803
+ export type CreateQrCodeOptions = {
804
+ /**
805
+ * The title of the QR code. This is used for display purposes.
806
+ * @default undefined
807
+ */
808
+ title?: string;
809
+ /**
810
+ * The background color of the QR code. This is a hex color code.
811
+ * @default '#ffffff'
812
+ */
813
+ backgroundColor?: string;
814
+ /**
815
+ * The color of the QR code. This is a hex color code.
816
+ * @default '#000000'
817
+ */
818
+ color?: string;
819
+ /**
820
+ * The size of the QR code. This can be 'small', 'medium', or 'large'.
821
+ * @default QrSize.MEDIUM
822
+ */
823
+ size?: QrSize;
824
+ /**
825
+ * The logo to include in the QR code. This should be a base64 encoded string.
826
+ * @default undefined
827
+ */
828
+ logo?: string;
829
+ };
830
+ ```
831
+
832
+ ## Get a QR Code By Id
833
+
834
+ To get a specific QR code by its ID, you can use the `getQrCode` method:
835
+
836
+ ```javascript
837
+ import { Link } from '@hyphen/sdk';
838
+ const link = new Link({
839
+ organizationId: 'your_organization_id',
840
+ apiKey: 'your_api_key',
841
+ });
842
+ const code = 'code_1234567890'; // It is the code identifier for the short code
843
+ const qr = 'qr_1234567890'; // It is the ID of the QR code you want to retrieve
844
+ const response = await link.getQrCode(code, qr);
845
+ console.log('Get QR Code Response:', response);
846
+ ```
847
+
848
+ ## Get QR Codes for a Short Code
849
+
850
+ To get all QR codes for a short code, you can use the `getQrCodes` method:
851
+
852
+ ```javascript
853
+ import { Link } from '@hyphen/sdk';
854
+ const link = new Link({
855
+ organizationId: 'your_organization_id',
856
+ apiKey: 'your_api_key',
857
+ });
858
+ const code = 'code_1234567890'; // It is the code identifier for the short code
859
+ const response = await link.getQrCodes(code);
860
+ console.log('Get QR Codes Response:', response);
861
+ ```
862
+
863
+ ## Deleting a QR Code
864
+
865
+ To delete a QR code, you can use the `deleteQrCode` method:
866
+
867
+ ```javascript
868
+ import { Link } from '@hyphen/sdk';
869
+ const link = new Link({
870
+ organizationId: 'your_organization_id',
871
+ apiKey: 'your_api_key',
872
+ });
873
+ const code = 'code_1234567890'; // It is the code identifier for the short code
874
+ const qr = 'qr_1234567890'; // It is the ID of the QR code you want to delete
875
+ const response = await link.deleteQrCode(code, qr);
876
+ console.log('Delete QR Code Response:', response);
877
+ ```
878
+
686
879
  # Contributing
687
880
 
688
881
  We welcome contributions to the Hyphen Node.js SDK! If you have an idea for a new feature, bug fix, or improvement, please follow these steps:
package/dist/index.cjs CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  Hyphen: () => Hyphen,
35
35
  Toggle: () => Toggle,
36
36
  ToggleHooks: () => ToggleHooks,
37
+ env: () => env,
37
38
  loadEnv: () => loadEnv
38
39
  });
39
40
  module.exports = __toCommonJS(index_exports);
@@ -404,7 +405,7 @@ var import_node_process2 = __toESM(require("process"), 1);
404
405
  var import_node_fs = __toESM(require("fs"), 1);
405
406
  var import_node_path = __toESM(require("path"), 1);
406
407
  var import_dotenv2 = require("dotenv");
407
- function loadEnv(options) {
408
+ function env(options) {
408
409
  const local = options?.local ?? true;
409
410
  const currentWorkingDirectory = options?.path ?? import_node_process2.default.cwd();
410
411
  const envPath = import_node_path.default.resolve(currentWorkingDirectory, ".env");
@@ -442,7 +443,8 @@ function loadEnv(options) {
442
443
  }
443
444
  }
444
445
  }
445
- __name(loadEnv, "loadEnv");
446
+ __name(env, "env");
447
+ var loadEnv = env;
446
448
 
447
449
  // src/hyphen.ts
448
450
  var import_hookified3 = require("hookified");
@@ -516,6 +518,9 @@ var BaseService = class extends import_hookified2.Hookified {
516
518
  return import_axios.default.put(url, data, config2);
517
519
  }
518
520
  async delete(url, config2) {
521
+ if (config2 && config2.headers) {
522
+ delete config2.headers["content-type"];
523
+ }
519
524
  return import_axios.default.delete(url, config2);
520
525
  }
521
526
  async patch(url, data, config2) {
@@ -534,7 +539,7 @@ var BaseService = class extends import_hookified2.Hookified {
534
539
  };
535
540
 
536
541
  // src/net-info.ts
537
- loadEnv();
542
+ env();
538
543
  var NetInfo = class extends BaseService {
539
544
  static {
540
545
  __name(this, "NetInfo");
@@ -663,7 +668,8 @@ var NetInfo = class extends BaseService {
663
668
 
664
669
  // src/link.ts
665
670
  var import_node_process4 = __toESM(require("process"), 1);
666
- loadEnv();
671
+ var import_node_buffer = require("buffer");
672
+ env();
667
673
  var defaultLinkUris = [
668
674
  "https://api.hyphen.ai/api/organizations/{organizationId}/link/codes/"
669
675
  ];
@@ -743,11 +749,43 @@ var Link = class extends BaseService {
743
749
  this._apiKey = apiKey;
744
750
  }
745
751
  }
752
+ /**
753
+ * Get the URI for a specific organization and code. This is used internally to construct the URI for the link service.
754
+ * @param {string} organizationId The ID of the organization.
755
+ * @param {string} code The code to include in the URI.
756
+ * @returns {string} The constructed URI.
757
+ */
758
+ getUri(organizationId, prefix1, prefix2, prefix3) {
759
+ if (!organizationId) {
760
+ throw new Error("Organization ID is required to get the URI.");
761
+ }
762
+ let url = this._uris[0].replace("{organizationId}", organizationId);
763
+ if (prefix1) {
764
+ url = url.endsWith("/") ? `${url}${prefix1}/` : `${url}/${prefix1}`;
765
+ }
766
+ if (prefix2) {
767
+ url = url.endsWith("/") ? `${url}${prefix2}/` : `${url}/${prefix2}`;
768
+ }
769
+ if (prefix3) {
770
+ url = url.endsWith("/") ? `${url}${prefix3}/` : `${url}/${prefix3}`;
771
+ }
772
+ if (url.endsWith("/")) {
773
+ url = url.slice(0, -1);
774
+ }
775
+ return url;
776
+ }
777
+ /**
778
+ * Create a short code for a long URL.
779
+ * @param {string} longUrl The long URL to shorten.
780
+ * @param {string} domain The domain to use for the short code.
781
+ * @param {CreateShortCodeOptions} options Optional parameters for creating the short code.
782
+ * @returns {Promise<CreateShortCodeResponse>} A promise that resolves to the created short code details.
783
+ */
746
784
  async createShortCode(longUrl, domain, options) {
747
785
  if (!this._organizationId) {
748
786
  throw new Error("Organization ID is required to create a short code.");
749
787
  }
750
- const url = this._uris[0].replace("{organizationId}", this._organizationId);
788
+ const url = this.getUri(this._organizationId);
751
789
  const body = {
752
790
  // eslint-disable-next-line @typescript-eslint/naming-convention
753
791
  long_url: longUrl,
@@ -766,6 +804,119 @@ var Link = class extends BaseService {
766
804
  throw new Error(`Failed to create short code: ${response.statusText}`);
767
805
  }
768
806
  /**
807
+ * Get a short code by its code.
808
+ * @param {string} code The short code to retrieve. Example: 'code_686bed403c3991bd676bba4d'
809
+ * @returns {Promise<GetShortCodeResponse>} A promise that resolves to the short code details.
810
+ */
811
+ async getShortCode(code) {
812
+ if (!this._organizationId) {
813
+ throw new Error("Organization ID is required to get a short code.");
814
+ }
815
+ const url = this.getUri(this._organizationId, code);
816
+ const headers = this.createHeaders(this._apiKey);
817
+ const response = await this.get(url, {
818
+ headers
819
+ });
820
+ if (response.status === 200) {
821
+ return response.data;
822
+ }
823
+ throw new Error(`Failed to get short code: ${response.statusText}`);
824
+ }
825
+ /**
826
+ * Get all short codes for the organization.
827
+ * @param {string} titleSearch Optional search term to filter short codes by title.
828
+ * @param {string[]} tags Optional tags to filter short codes.
829
+ * @param {number} pageNumber The page number to retrieve. Default is 1.
830
+ * @param {number} pageSize The number of short codes per page. Default is 100.
831
+ * @returns {Promise<GetShortCodesResponse>} A promise that resolves to the list of short codes.
832
+ */
833
+ async getShortCodes(titleSearch, tags, pageNumber = 1, pageSize = 100) {
834
+ if (!this._organizationId) {
835
+ throw new Error("Organization ID is required to get short codes.");
836
+ }
837
+ const url = this.getUri(this._organizationId);
838
+ const headers = this.createHeaders(this._apiKey);
839
+ const parameters = {};
840
+ if (titleSearch) {
841
+ parameters.title = titleSearch;
842
+ }
843
+ if (tags && tags.length > 0) {
844
+ parameters.tags = tags.join(",");
845
+ }
846
+ parameters.pageNum = pageNumber.toString();
847
+ parameters.pageSize = pageSize.toString();
848
+ const response = await this.get(url, {
849
+ headers,
850
+ params: parameters
851
+ });
852
+ if (response.status === 200) {
853
+ return response.data;
854
+ }
855
+ throw new Error(`Failed to get short codes: ${response.statusText}`);
856
+ }
857
+ /**
858
+ * Get all tags associated with the organization's short codes.
859
+ * @returns {Promise<string[]>} A promise that resolves to an array of tags.
860
+ */
861
+ async getTags() {
862
+ if (!this._organizationId) {
863
+ throw new Error("Organization ID is required to get tags.");
864
+ }
865
+ const url = this.getUri(this._organizationId, "tags");
866
+ const headers = this.createHeaders(this._apiKey);
867
+ const response = await this.get(url, {
868
+ headers
869
+ });
870
+ if (response.status === 200) {
871
+ return response.data;
872
+ }
873
+ throw new Error(`Failed to get tags: ${response.statusText}`);
874
+ }
875
+ /**
876
+ * Get statistics for a specific short code.
877
+ * @param code The short code to retrieve statistics for.
878
+ * @returns {Promise<GetCodeStatsResponse>} A promise that resolves to the code statistics.
879
+ */
880
+ async getCodeStats(code, startDate, endDate) {
881
+ if (!this._organizationId) {
882
+ throw new Error("Organization ID is required to get code stats.");
883
+ }
884
+ const url = this.getUri(this._organizationId, code, "stats");
885
+ const headers = this.createHeaders(this._apiKey);
886
+ const parameters = {
887
+ startDate: startDate.toISOString(),
888
+ endDate: endDate.toISOString()
889
+ };
890
+ const response = await this.get(url, {
891
+ headers,
892
+ params: parameters
893
+ });
894
+ if (response.status === 200) {
895
+ return response.data;
896
+ }
897
+ throw new Error(`Failed to get code stats: ${response.statusText}`);
898
+ }
899
+ /**
900
+ * Update a short code.
901
+ * @param {string} code The short code to update. Example: 'code_686bed403c3991bd676bba4d'
902
+ * @param {UpdateShortCodeOptions} options The options to update the short code with.
903
+ * @returns {Promise<UpdateShortCodeResponse>} A promise that resolves to the updated short code details.
904
+ */
905
+ async updateShortCode(code, options) {
906
+ if (!this._organizationId) {
907
+ throw new Error("Organization ID is required to update a short code.");
908
+ }
909
+ const url = this.getUri(this._organizationId, code);
910
+ const headers = this.createHeaders(this._apiKey);
911
+ const response = await this.patch(url, options, {
912
+ headers
913
+ });
914
+ if (response.status === 200) {
915
+ return response.data;
916
+ }
917
+ throw new Error(`Failed to update short code: ${response.statusText}`);
918
+ }
919
+ /**
769
920
  * Delete a short code.
770
921
  * @param {string} code The short code to delete. Example: 'code_686bed403c3991bd676bba4d'
771
922
  * @returns {Promise<boolean>} A promise that resolves to true if the short code was deleted successfully, or false if it was not.
@@ -774,10 +925,8 @@ var Link = class extends BaseService {
774
925
  if (!this._organizationId) {
775
926
  throw new Error("Organization ID is required to delete a short code.");
776
927
  }
777
- let url = this._uris[0].replace("{organizationId}", this._organizationId);
778
- url = url.endsWith("/") ? `${url}${code}/` : `${url}/${code}/`;
928
+ const url = this.getUri(this._organizationId, code);
779
929
  const headers = this.createHeaders(this._apiKey);
780
- delete headers["content-type"];
781
930
  const response = await this.delete(url, {
782
931
  headers
783
932
  });
@@ -786,6 +935,112 @@ var Link = class extends BaseService {
786
935
  }
787
936
  throw new Error(`Failed to delete short code: ${response.statusText}`);
788
937
  }
938
+ /**
939
+ * Create a QR code for a specific short code.
940
+ * @param {string} code The short code to create a QR code for.
941
+ * @param {CreateQrCodeOptions} options The options for creating the QR code.
942
+ * @returns {Promise<CreateQrCodeResponse>} A promise that resolves to the created QR code details.
943
+ */
944
+ async createQrCode(code, options) {
945
+ if (!this._organizationId) {
946
+ throw new Error("Organization ID is required to create a QR code.");
947
+ }
948
+ const url = this.getUri(this._organizationId, code, "qrs");
949
+ const headers = this.createHeaders(this._apiKey);
950
+ const body = {
951
+ title: options?.title,
952
+ backgroundColor: options?.backgroundColor,
953
+ color: options?.color,
954
+ size: options?.size,
955
+ logo: options?.logo
956
+ };
957
+ const response = await this.post(url, body, {
958
+ headers
959
+ });
960
+ if (response.status === 201) {
961
+ const result = response.data;
962
+ if (result.qrCode) {
963
+ const buffer = import_node_buffer.Buffer.from(result.qrCode, "base64");
964
+ result.qrCodeBytes = new Uint16Array(buffer);
965
+ }
966
+ return result;
967
+ }
968
+ throw new Error(`Failed to create QR code: ${response.statusText}`);
969
+ }
970
+ /**
971
+ * Get a QR code by its ID.
972
+ * @param code The short code associated with the QR code.
973
+ * @param qr The ID of the QR code to retrieve.
974
+ * @returns The details of the requested QR code.
975
+ */
976
+ async getQrCode(code, qr) {
977
+ if (!this._organizationId) {
978
+ throw new Error("Organization ID is required to get a QR code.");
979
+ }
980
+ const url = this.getUri(this._organizationId, code, "qrs", qr);
981
+ const headers = this.createHeaders(this._apiKey);
982
+ const response = await this.get(url, {
983
+ headers
984
+ });
985
+ if (response.status === 200) {
986
+ const result = response.data;
987
+ if (result.qrCode) {
988
+ const buffer = import_node_buffer.Buffer.from(result.qrCode, "base64");
989
+ result.qrCodeBytes = new Uint16Array(buffer);
990
+ }
991
+ return result;
992
+ }
993
+ throw new Error(`Failed to get QR code: ${response.statusText}`);
994
+ }
995
+ async getQrCodes(code, pageNumber, pageSize) {
996
+ if (!this._organizationId) {
997
+ throw new Error("Organization ID is required to get QR codes.");
998
+ }
999
+ const url = this.getUri(this._organizationId, code, "qrs");
1000
+ const headers = this.createHeaders(this._apiKey);
1001
+ const parameters = {};
1002
+ if (pageNumber) {
1003
+ parameters.pageNum = pageNumber.toString();
1004
+ }
1005
+ if (pageSize) {
1006
+ parameters.pageSize = pageSize.toString();
1007
+ }
1008
+ const response = await this.get(url, {
1009
+ headers,
1010
+ params: parameters
1011
+ });
1012
+ if (response.status === 200) {
1013
+ const result = response.data;
1014
+ for (const qrCode of result.data) {
1015
+ if (qrCode.qrCode) {
1016
+ const buffer = import_node_buffer.Buffer.from(qrCode.qrCode, "base64");
1017
+ qrCode.qrCodeBytes = new Uint16Array(buffer);
1018
+ }
1019
+ }
1020
+ return result;
1021
+ }
1022
+ throw new Error(`Failed to get QR codes: ${response.statusText}`);
1023
+ }
1024
+ /**
1025
+ * Delete a QR code by its ID.
1026
+ * @param {string} code The short code associated with the QR code.
1027
+ * @param {string} qr The ID of the QR code to delete.
1028
+ * @returns {Promise<boolean>} A promise that resolves to true if the QR code was deleted successfully, or false if it was not.
1029
+ */
1030
+ async deleteQrCode(code, qr) {
1031
+ if (!this._organizationId) {
1032
+ throw new Error("Organization ID is required to delete a QR code.");
1033
+ }
1034
+ const url = this.getUri(this._organizationId, code, "qrs", qr);
1035
+ const headers = this.createHeaders(this._apiKey);
1036
+ const response = await this.delete(url, {
1037
+ headers
1038
+ });
1039
+ if (response.status === 204) {
1040
+ return true;
1041
+ }
1042
+ throw new Error(`Failed to delete QR code: ${response.statusText}`);
1043
+ }
789
1044
  };
790
1045
 
791
1046
  // src/hyphen.ts
@@ -910,5 +1165,6 @@ var Hyphen = class extends import_hookified3.Hookified {
910
1165
  Hyphen,
911
1166
  Toggle,
912
1167
  ToggleHooks,
1168
+ env,
913
1169
  loadEnv
914
1170
  });