Skip to content

Commit

Permalink
Merge pull request #1 from AddaMeSPB/beta
Browse files Browse the repository at this point in the history
Here we NW go
  • Loading branch information
saroar authored Sep 30, 2022
2 parents 7f842e4 + 8708bb6 commit 5266234
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ let package = Package(

// Route
.package(url: "https://github.com/pointfreeco/vapor-routing.git", from: "0.1.1"),
.package(url: "https://github.com/pointfreeco/swift-parsing.git", from: "0.9.2"),
.package(url: "https://github.com/pointfreeco/swift-url-routing.git", from: "0.3.0"),
.package(url: "https://github.com/OpenKitten/BSON.git", from: "7.0.0")
],
Expand Down
4 changes: 3 additions & 1 deletion Sources/NWSharedModels/Auth/AuthMocks.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import BSON

extension VerifySMSInOutput {
static public var draff: VerifySMSInOutput = .init(
phoneNumber: "+79218821217",
Expand All @@ -8,7 +10,7 @@ extension VerifySMSInOutput {
}

extension LoginResponseP {
static public var draff: LoginResponseP = .init(status: "online", user: .init(fullName: "Saroar", email: "", role: .superAdmin, language: .english), access: .draff)
static public var draff: LoginResponseP = .init(status: "online", user: .init(id: ObjectId(),fullName: "Saroar", email: "", role: .superAdmin, language: .english), access: .draff)
}

extension RefreshTokenResponse {
Expand Down
2 changes: 1 addition & 1 deletion Sources/NWSharedModels/SiteRoute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum WordsRoute: Equatable {

public let wordsRouter = OneOf {
Route(.case(WordsRoute.list)) {
Path { "api/words" }
Path { "api"; "words" }
Parse(.memberwise(Language.init)) {
Query {
Field("from", .string, default: "")
Expand Down
2 changes: 0 additions & 2 deletions Sources/NWSharedModels/SwiftUI+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Created by Saroar Khandoker on 08.12.2021.
//

import SwiftUI

//extension View {
// @ViewBuilder
// public func stackNavigationViewStyle() -> some View {
Expand Down
3 changes: 3 additions & 0 deletions Sources/NWSharedModels/URLResponse+extension.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

extension URLResponse {
public func isResponseOK() -> Bool {
Expand Down
21 changes: 19 additions & 2 deletions Sources/NWSharedModels/User/UserModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension UserModel {
extension UserModel {
public func mapGet() -> UserGetObject {
return .init(
id: id,
id: id ?? ObjectId(),
fullName: fullName,
phoneNumber: phoneNumber,
email: email,
Expand Down Expand Up @@ -139,7 +139,24 @@ extension UserModel {

extension UserGetObject: Content {
public init(from user: UserModel) {
self.init(id: user.id, fullName: user.fullName, phoneNumber: user.phoneNumber, email: user.email, role: user.role, language: user.language)
self.init(
id: user.id ?? ObjectId(),
fullName: user.fullName,
phoneNumber: user.phoneNumber,
email: user.email,
role: user.role,
language: user.language
)
}
}

extension UserModel {
public func update(_ input: UserGetObject) async throws {
fullName = input.fullName
language = input.language
role = input.role
email = input.email
phoneNumber = input.phoneNumber
}
}
#endif
22 changes: 14 additions & 8 deletions Sources/NWSharedModels/User/UserObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public struct UserCreateObject: Codable {

public struct UserGetObject: Codable {

public let id: ObjectId?
public let fullName: String
public let phoneNumber: String?
public let email: String?
public let role: UserRole
public let language: UserLanguage
public var id: ObjectId
public var fullName: String
public var phoneNumber: String?
public var email: String?
public var role: UserRole
public var language: UserLanguage

public init(
id: ObjectId? = nil,
id: ObjectId,
fullName: String,
phoneNumber: String? = nil,
email: String? = nil,
Expand All @@ -52,7 +52,13 @@ public struct UserGetObject: Codable {
}
}

extension UserGetObject: Equatable {}
extension UserGetObject: Equatable {
public static func ==(lhs: Self, rhs: Self) -> Bool {
return lhs.id == rhs.id && lhs.role == rhs.role
&& lhs.language == rhs.language && lhs.fullName == rhs.fullName
&& lhs.phoneNumber == rhs.phoneNumber
}
}

public struct UserGetPublicObject: Codable {

Expand Down

0 comments on commit 5266234

Please sign in to comment.