mailmeteor 0.0.45 → 0.0.47

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/dist/index.cjs CHANGED
@@ -1751,6 +1751,15 @@ class Integrations extends HeyApiClient {
1751
1751
  ...params
1752
1752
  });
1753
1753
  }
1754
+ connectAccount(integration_id, account_id, options) {
1755
+ const params = buildClientParams([integration_id, account_id], [{ in: 'path', key: 'integration_id' }, { in: 'path', key: 'account_id' }]);
1756
+ return (options?.client ?? this.client).post({
1757
+ responseStyle: 'data',
1758
+ url: '/integrations/{integration_id}/accounts/{account_id}/connect',
1759
+ ...options,
1760
+ ...params
1761
+ });
1762
+ }
1754
1763
  }
1755
1764
  class Integrations2 extends HeyApiClient {
1756
1765
  constructor(args) {
@@ -1797,6 +1806,12 @@ function querySerializer(query) {
1797
1806
  }
1798
1807
  return parts.join('&');
1799
1808
  }
1809
+ function getAuthorizationHeader(apiKey) {
1810
+ if (apiKey.startsWith('sk_')) {
1811
+ return `Basic ${Buffer.from(String(apiKey) + ':').toString('base64')}`;
1812
+ }
1813
+ return `Bearer ${apiKey}`;
1814
+ }
1800
1815
  class Mailmeteor {
1801
1816
  constructor(key, config) {
1802
1817
  const baseUrl = config?.baseUrl || 'https://api.mailmeteor.com/v1';
@@ -1805,7 +1820,7 @@ class Mailmeteor {
1805
1820
  throwOnError: true,
1806
1821
  querySerializer,
1807
1822
  headers: {
1808
- 'Authorization': `Bearer ${key}`,
1823
+ 'Authorization': getAuthorizationHeader(key),
1809
1824
  },
1810
1825
  }));
1811
1826
  this.billingAddons = new BillingAddons({ client: this.client });
@@ -1826,7 +1841,7 @@ class Mailmeteor {
1826
1841
  ...currentConfig,
1827
1842
  headers: {
1828
1843
  ...currentHeaders,
1829
- 'Authorization': `Bearer ${key}`,
1844
+ 'Authorization': getAuthorizationHeader(key),
1830
1845
  },
1831
1846
  });
1832
1847
  }