-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from YanisGitHubCours/main
merge to back
- Loading branch information
Showing
23 changed files
with
547 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
### | ||
GET http://localhost:8081/getPlaceUser HTTP/1.1 | ||
Content-Type: application/json | ||
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjMwYTM1ZjFkYWMwMDQ4NjlhYjUxMjVhIiwiZW1haWwiOiJUZXN0QGdtYWlsLmNvbSIsImlhdCI6MTY2MzExMDkzMCwiZXhwIjoxNjYzMTM2MTMwfQ.wwQyWz_F7aJzv-R8iXOgmAWlKomypCbT1pDCQa7MInk | ||
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjMwYTM1ZjFkYWMwMDQ4NjlhYjUxMjVhIiwiZW1haWwiOiJUZXN0QGdtYWlsLmNvbSIsImlhdCI6MTY2MzExMzY5MSwiZXhwIjoxNjYzMTM4ODkxfQ.APwPe34yKzGmkNJxNH0mT6FN21COc--3REUvM803yB8 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+19.9 KB
(120%)
....xcodeproj/project.xcworkspace/xcuserdata/alex.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// User.swift | ||
// CoWorkApp | ||
// | ||
// Created by Alexandre Marcos on 22/08/2022. | ||
// | ||
|
||
import Foundation | ||
|
||
class Sub: CustomStringConvertible, Identifiable { | ||
var description: String { | ||
"This is a user" | ||
} | ||
|
||
let id: String? | ||
let name: String | ||
let price: String | ||
let fk_service: String | ||
|
||
public init(id: String?, name: String, price: String, fk_service: String){ | ||
self.id = id | ||
self.name = name | ||
self.price = price | ||
self.fk_service = fk_service | ||
} | ||
|
||
public class func fromDict(_ array: [String: Any]) -> Sub? { | ||
guard let id = array["id"] as? String, | ||
let name = array["name"] as? String, | ||
let price = array["price"] as? String, | ||
let fk_service = array["fk_service"] as? String else { | ||
return nil | ||
} | ||
|
||
return Sub(id: id, name: name, price: price, fk_service: fk_service ) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ApiResponse.swift | ||
// CoWorkApp | ||
// | ||
// Created by Alexandre Marcos on 25/08/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class SubResponse: CustomStringConvertible, Identifiable { | ||
var description: String { | ||
"Api default response" | ||
} | ||
|
||
let sub: [Sub] | ||
|
||
public init(sub: [Sub]){ | ||
self.sub = sub | ||
} | ||
|
||
public class func fromDict(_ array: [String: Any]) -> SubResponse? { | ||
|
||
guard let subOnly = array["sub"] as? [[String: Any]] else { | ||
return nil | ||
} | ||
|
||
let subR = subOnly.compactMap(Sub.fromDict(_:)) | ||
|
||
return SubResponse(sub: subR) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// ApiResponse.swift | ||
// CoWorkApp | ||
// | ||
// Created by Alexandre Marcos on 25/08/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class UserRent: CustomStringConvertible, Identifiable { | ||
var description: String { | ||
"Api default response" | ||
} | ||
|
||
let name: String | ||
let time: String | ||
let day: String | ||
let placeId: String | ||
let scheduleId: String | ||
let userId: String | ||
|
||
public init(name: String, time: String, day: String, placeId: String, scheduleId: String, userId: String){ | ||
self.name = name | ||
self.time = time | ||
self.day = day | ||
self.placeId = placeId | ||
self.scheduleId = scheduleId | ||
self.userId = userId | ||
} | ||
|
||
public class func fromDict(_ array: [String: Any]) -> UserRent? { | ||
|
||
guard let name = array["name"] as? String, | ||
let time = array["time"] as? String, | ||
let day = array["day"] as? String, | ||
let placeId = array["fk_place"] as? String, | ||
let scheduleId = array["fk_pls"] as? String, | ||
let userId = array["fk_user"] as? String else { | ||
return nil | ||
} | ||
|
||
|
||
|
||
return UserRent(name: name, time: time, day: day, placeId: placeId, scheduleId: scheduleId, userId: userId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ApiResponse.swift | ||
// CoWorkApp | ||
// | ||
// Created by Alexandre Marcos on 25/08/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class UserRentResponse: CustomStringConvertible, Identifiable { | ||
var description: String { | ||
"Api default response" | ||
} | ||
|
||
let userRent: [UserRent] | ||
|
||
public init(userRent: [UserRent]){ | ||
self.userRent = userRent | ||
} | ||
|
||
public class func fromDict(_ array: [String: Any]) -> UserRentResponse? { | ||
|
||
guard let userRent = array["rent"] as? [[String: Any]] else { | ||
return nil | ||
} | ||
|
||
let UserRentResponseArray = userRent.compactMap(UserRent.fromDict(_:)) | ||
|
||
return UserRentResponse(userRent: UserRentResponseArray) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// UserSignUpService.swift | ||
// CoWorkApp | ||
// | ||
// Created by Alexandre Marcos on 22/08/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
|
||
class AllUserRentService { | ||
class func Show(completion: @escaping ([UserRentResponse]) -> Void){ | ||
guard let url = URL(string: ApiService.URL + "/getRentByIdUSer") else { | ||
completion([]) | ||
return | ||
} | ||
|
||
var urlRequest = URLRequest(url: url) | ||
urlRequest.httpMethod = "POST" | ||
urlRequest.addValue("application/json", forHTTPHeaderField: "Content-Type") | ||
urlRequest.addValue(ApiService.TOKEN, forHTTPHeaderField: "Authorization") | ||
|
||
var dataArray:[String:Any] = [:] | ||
|
||
dataArray["id"] = ApiService.USER!.id | ||
|
||
|
||
let datas = try? JSONSerialization.data(withJSONObject: dataArray, options: .fragmentsAllowed) | ||
urlRequest.httpBody = datas | ||
|
||
let req = URLSession.shared.dataTask(with: urlRequest) { (datas, res, err) in | ||
guard err == nil, let d = datas else { | ||
completion([]) | ||
return | ||
} | ||
|
||
let json = try? JSONSerialization.jsonObject(with: d,options: .allowFragments) | ||
|
||
guard let apiResponseArray = json as? [[String: Any]] else { | ||
completion([]) | ||
return | ||
} | ||
|
||
completion(apiResponseArray.compactMap(UserRentResponse.fromDict(_:))) | ||
|
||
} | ||
req.resume() | ||
} | ||
} |
Oops, something went wrong.