@entergreat/unipile-wrapper 1.0.6 → 1.0.7

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": "@entergreat/unipile-wrapper",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,5 +1,14 @@
1
1
  import { get, post, patch } from "../utils/api.js";
2
2
 
3
+ function extractCompanyIdFromUrl(url) {
4
+ // Handle URLs like:
5
+ // https://www.linkedin.com/company/company-name/
6
+ // https://www.linkedin.com/company/12345678/
7
+ // https://linkedin.com/company/company-name
8
+ const match = url.match(/linkedin\.com\/company\/([^\/\?]+)/i);
9
+ return match ? match[1] : null;
10
+ }
11
+
3
12
  function convertToBracketNotation(obj, prefix = '') {
4
13
  const result = {};
5
14
 
@@ -141,6 +150,30 @@ export default class LinkedinService {
141
150
  }
142
151
  }
143
152
 
153
+ // retrieve LinkedIn company by URL or ID
154
+ async retrieveCompany({ accountId, companyId, companyUrl }) {
155
+ try {
156
+ if (!accountId) {
157
+ throw "account_id must be provided";
158
+ }
159
+
160
+ let id = companyId;
161
+ if (!id && companyUrl) {
162
+ id = extractCompanyIdFromUrl(companyUrl);
163
+ }
164
+
165
+ if (!id) {
166
+ throw "company_id or company_url must be provided";
167
+ }
168
+
169
+ const url = `${this.unipileUrl}/linkedin/company/${id}?account_id=${accountId}`;
170
+
171
+ return await get(url, this.headers);
172
+ } catch (error) {
173
+ throw error;
174
+ }
175
+ }
176
+
144
177
  // edit LinkedIn profile
145
178
  async editProfile({ accountId, profileData }) {
146
179
  try {