Skip to content

Commit da2f238

Browse files
committed
Merge branch 'main' of https://github.com/yale-swe/f23-here
2 parents 9ce1fe3 + 04e5534 commit da2f238

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

app/newHere1/newHere/Utils/api_call.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ extension Double {
3131
}
3232
}
3333

34-
// Structure for request body of posting a message
34+
/// Structure for request body of posting a message
3535
struct PostMessageRequest: Codable {
3636
let user_id: String
3737
let text: String
3838
let visibility: String
3939
let location: GeoJSONPoint
4040
}
4141

42-
/// Structure for response of a message
42+
//// Structure for response of a message
4343
struct MessageResponse: Codable {
4444
let _id: String
4545
let user_id: String
@@ -48,17 +48,17 @@ struct MessageResponse: Codable {
4848
let location: GeoJSONPoint
4949
}
5050

51-
/// Structure for response of adding a friend
51+
//// Structure for response of adding a friend
5252
struct AddFriendResponse: Codable {
5353
let message: String
5454
}
5555

56-
/// Structure for request body of adding a friend
56+
//// Structure for request body of adding a friend
5757
struct FriendRequest: Codable {
5858
let friendName: String
5959
}
6060

61-
/// Structure for user message data
61+
//// Structure for user message data
6262
struct UserMessage: Codable {
6363
struct Location: Codable {
6464
let type: String
@@ -74,7 +74,7 @@ struct UserMessage: Codable {
7474
let replies: [String]
7575
}
7676

77-
/// Function to fetch user messages
77+
//// Function to fetch user messages
7878
func getUserMessages(userId: String, completion: @escaping (Result<[MessageResponse], Error>) -> Void) {
7979
// API URL
8080
let urlString = "https://here-swe.vercel.app/user/\(userId)/messages"
@@ -127,6 +127,13 @@ func getUserMessages(userId: String, completion: @escaping (Result<[MessageRespo
127127

128128
}
129129

130+
/// Posts a message to a remote server.
131+
/// - Parameters:
132+
/// - user_id: A `String` representing the user's ID.
133+
/// - text: The text content of the message.
134+
/// - visibility: The visibility status of the message.
135+
/// - locationDataManager: A `LocationDataManager` to provide the current location.
136+
/// - completion: A completion handler that returns either `MessageResponse` or `Error`.
130137
/// Posts a message to a remote server.
131138
/// - Parameters:
132139
/// - user_id: A `String` representing the user's ID.
@@ -182,6 +189,8 @@ func postMessage(user_id: String, text: String, visibility: String, locationData
182189

183190
// Function to get all friends of a user
184191
func getAllUserFriends(userId: String, completion: @escaping (Result<[String: String], Error>) -> Void) {
192+
/// Function to get all friends of a user
193+
func getAllUserFriends(userId: String, completion: @escaping (Result<[String], Error>) -> Void) {
185194
// API URL
186195
let urlString = "https://here-swe.vercel.app/user/\(userId)/friends"
187196

0 commit comments

Comments
 (0)