@entergreat/unipile-wrapper 1.0.7 → 1.0.9

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.9",
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,60 @@ export default class LinkedinService {
194
195
  throw error;
195
196
  }
196
197
  }
198
+
199
+ // add experience position (multipart/form-data format)
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
+ formData.append("role", experience.role);
216
+ formData.append("company", experience.company);
217
+
218
+ if (experience.description) {
219
+ formData.append("description", experience.description);
220
+ }
221
+ if (experience.location) {
222
+ formData.append("location", experience.location);
223
+ }
224
+ if (experience.notify_network !== undefined) {
225
+ formData.append("notify_network", experience.notify_network.toString());
226
+ }
227
+
228
+ // Start date (required)
229
+ if (experience.start_month) {
230
+ formData.append("month", experience.start_month.toString());
231
+ }
232
+ if (experience.start_year) {
233
+ formData.append("year", experience.start_year.toString());
234
+ }
235
+
236
+ // End date (optional - for non-current positions)
237
+ if (experience.end_month) {
238
+ formData.append("month", experience.end_month.toString());
239
+ }
240
+ if (experience.end_year) {
241
+ formData.append("year", experience.end_year.toString());
242
+ }
243
+
244
+ const headers = {
245
+ ...this.headers,
246
+ "content-type": "multipart/form-data",
247
+ };
248
+
249
+ return await patch(url, formData, headers);
250
+ } catch (error) {
251
+ throw error;
252
+ }
253
+ }
197
254
  }