Skip to content

Commit

Permalink
v2.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mo9a7i committed Oct 12, 2023
1 parent de53a28 commit b470f03
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# swarmapp-api

## 2.11.1

### Patch Changes

- better logging

## 2.11.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flowdegree/swarmapp-api",
"version": "2.11.0",
"version": "2.11.1",
"description": "A javascript wrapper for swarmapp (foursquare) API",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions src/api/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function login(this:any, username: any, password: any, client_id: a

return response.data.access_token;
} catch (error) {
console.log(`error occured while logging in`)
this.error(error)
return;
}
Expand All @@ -37,7 +38,8 @@ export async function initiatemultifactorlogin(this:any, username: string, passw

return response.data;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while initiating multifactor login`)
this.error(error)
return error;
}
}
Expand All @@ -57,7 +59,8 @@ export async function completemultifactorlogin(this:any, code: string, client_id

return response.data.access_token;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while completing multifactor login`)
this.error(error)
return;
}
}
6 changes: 4 additions & 2 deletions src/api/checkins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export async function checkIn(this:any, venue_id: string, silent: boolean) {
const checkin = result.data.response?.checkin;
return checkin;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while checking in`)
this.error(error)
return;
}
}
Expand All @@ -43,7 +44,8 @@ export async function getRecent(this:any, limit: number = 100, ll?: string) {

return result.data.response.recent;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting recent`)
this.error(error)
return;
}
}
17 changes: 12 additions & 5 deletions src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export async function getFriends(this: any, user_id: string = 'self'): Promise<a
const result = await axios.get(this.basePath + 'users/' + user_id + '/friends', { 'params': this.config });
return result.data.response.friends;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting friends`)
this.error(error)
return null;
}
}
Expand All @@ -23,7 +24,8 @@ export async function getFollowings(this: any, user_id: string = 'self'): Promis
const result = await axios.get(this.basePath + 'users/' + user_id + '/following', { 'params': this.config });
return result.data.response.following;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting followings`)
this.error(error)
return null;
}
}
Expand All @@ -38,7 +40,8 @@ export async function getFollowers(this: any, user_id: string = 'self'): Promise
const result = await axios.get(this.basePath + 'users/' + user_id + '/followers', { 'params': this.config });
return result.data.response.followers;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting followers`)
this.error(error)
return null;
}
}
Expand All @@ -48,6 +51,8 @@ export async function getUser(this:any, user_id: string = 'self') {
const result = await axios.get(`${this.basePath}users/${user_id}`, { 'params': this.config });
return result;
} catch (error: any) {
console.log(`error occured while getting user`)
this.error(error)
throw new Error("Error getting user data, maybe an authentication error ?");
return;
}
Expand All @@ -65,7 +70,8 @@ export async function getCheckins(this:any, user_id: string = 'self', limit: num
const result = await axios.get(`${this.basePath}users/${user_id}/checkins`, { 'params': this.config });
return result;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting checkins`)
this.error(error)
return;
}
}
Expand All @@ -87,6 +93,7 @@ export async function addFriendByID(this:any, user_id: number): Promise<string |
return false;
}
catch (error: any) {
this.error(error.response.data);
console.log(`error occured while adding friend by id`)
this.error(error);
}
}
4 changes: 3 additions & 1 deletion src/api/venues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export async function getVenue(this:any, venue_id: string) {
const result = await axios.get(`${this.basePath}venues/${venue_id}/`, { 'params': this.config });
return result.data.response.venue;
} catch (error: any) {
console.log(`error occured while getting venue`)
throw new Error("Error getting venue data, maybe an authentication error ?");
return;
}
Expand Down Expand Up @@ -39,7 +40,8 @@ export async function getTrending(this:any, limit: number = 50, ll?: string, nea
return result.data.response.venues;
}
catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting trending venues`)
this.error(error)
return;
}
}
23 changes: 14 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export default class SwarmappApi {
try {
return this.getUser(user_id);
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting last seen`)
this.error(error)
}
}

Expand All @@ -115,7 +116,8 @@ export default class SwarmappApi {
const response = await axios.get(this.basePath + '/users/' + user_id + '/map', { 'params': this.config });
return response.data.response;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while getting geos`)
this.error(error)
}
}

Expand Down Expand Up @@ -148,7 +150,8 @@ export default class SwarmappApi {
});
return result;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while private logging`)
this.error(error)
return;
}
}
Expand Down Expand Up @@ -181,14 +184,13 @@ export default class SwarmappApi {
const registeration = result.data.response?.checkin;
return registeration;
} catch (error: any) {
this.error(error.response.data)
console.log(`error occured while registering device`)
this.error(error)
return;
}



}

// TODO: move to client
async addHereNow(checkin: any, females_only: boolean = true): Promise<{ hereNow: any, friendships: any[] }> {
const hereNow = checkin?.venue?.hereNow;
const friendships: any[] = [];
Expand Down Expand Up @@ -222,6 +224,7 @@ export default class SwarmappApi {
}

// auto add trending function
// TODO: maybe move it to the client, not the library
async autoAddTrending(location_name: string, limit_trending: number): Promise<any[]> {
try {
const trending = await this.getTrending(limit_trending, undefined, location_name);
Expand All @@ -237,13 +240,14 @@ export default class SwarmappApi {
return result.filter(item => item !== null);

} catch (error) {
console.error("An error occurred:", error);
console.log("An error occurred while auto adding trending:");
this.error("An error occurred:", error);
return [];

}
}

// Like Functions
// TODO: move it to checkins
async likeCheckin(checkin_id: string) {
try {
const result = await axios.post(this.basePath + 'checkins/' + checkin_id + '/like', querystring.stringify(this.config));
Expand All @@ -255,6 +259,7 @@ export default class SwarmappApi {
}
}

// TODO: move to client
async likeUnliked(limit: number = 40): Promise<{ succeeded: any[], failed: any[] }> {
try {
const succeeded: any[] = [];
Expand Down

0 comments on commit b470f03

Please sign in to comment.