@entergreat/unipile-wrapper 1.0.7 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entergreat/unipile-wrapper",
3
- "version": "1.0.7",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  "homepage": "https://github.com/nivkman/unipile-wrapper#readme",
22
22
  "dependencies": {
23
23
  "axios": "^1.7.9",
24
- "cors": "^2.8.5"
24
+ "cors": "^2.8.5",
25
+ "form-data": "^4.0.0"
25
26
  }
26
27
  }
@@ -1,4 +1,5 @@
1
1
  import { get, post, patch } from "../utils/api.js";
2
+ import FormData from "form-data";
2
3
 
3
4
  function extractCompanyIdFromUrl(url) {
4
5
  // Handle URLs like:
@@ -174,7 +175,7 @@ export default class LinkedinService {
174
175
  }
175
176
  }
176
177
 
177
- // edit LinkedIn profile
178
+ // edit LinkedIn profile (headline, summary - JSON format)
178
179
  async editProfile({ accountId, profileData }) {
179
180
  try {
180
181
  if (!accountId) {
@@ -194,4 +195,68 @@ export default class LinkedinService {
194
195
  throw error;
195
196
  }
196
197
  }
198
+
199
+ // add experience position (multipart/form-data format with bracket notation)
200
+ async addExperience({ accountId, experience }) {
201
+ try {
202
+ if (!accountId) {
203
+ throw "account_id must be provided";
204
+ }
205
+
206
+ if (!experience || !experience.role || !experience.company) {
207
+ throw "experience with role and company is required";
208
+ }
209
+
210
+ const url = `${this.unipileUrl}/users/me/edit?account_id=${accountId}`;
211
+
212
+ const formData = new FormData();
213
+ formData.append("type", "LINKEDIN");
214
+ formData.append("account_id", accountId);
215
+
216
+ // Experience fields use bracket notation
217
+ formData.append("experience[role]", experience.role);
218
+ formData.append("experience[company]", experience.company);
219
+
220
+ if (experience.description) {
221
+ formData.append("experience[description]", experience.description);
222
+ }
223
+ if (experience.notify_network !== undefined) {
224
+ formData.append("experience[notify_network]", experience.notify_network.toString());
225
+ }
226
+
227
+ // Start date with bracket notation
228
+ if (experience.start_month) {
229
+ formData.append("experience[seniority][start_date][month]", experience.start_month.toString());
230
+ }
231
+ if (experience.start_year) {
232
+ formData.append("experience[seniority][start_date][year]", experience.start_year.toString());
233
+ }
234
+
235
+ // End date with bracket notation (optional - for non-current positions)
236
+ if (experience.end_month) {
237
+ formData.append("experience[seniority][end_date][month]", experience.end_month.toString());
238
+ }
239
+ if (experience.end_year) {
240
+ formData.append("experience[seniority][end_date][year]", experience.end_year.toString());
241
+ }
242
+
243
+ // Skills array - repeat key for each skill
244
+ if (experience.skills && Array.isArray(experience.skills)) {
245
+ for (const skill of experience.skills) {
246
+ formData.append("experience[skills]", skill);
247
+ }
248
+ }
249
+
250
+ // Use formData.getHeaders() to get correct content-type with boundary
251
+ const headers = {
252
+ accept: "application/json",
253
+ "X-API-KEY": this.headers["X-API-KEY"],
254
+ ...formData.getHeaders(),
255
+ };
256
+
257
+ return await patch(url, formData, headers);
258
+ } catch (error) {
259
+ throw error;
260
+ }
261
+ }
197
262
  }