Skip to content

Commit

Permalink
implement Spanish language
Browse files Browse the repository at this point in the history
  • Loading branch information
saroar committed Oct 27, 2022
1 parent 1651e6c commit 540e117
Showing 5 changed files with 216 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -3,16 +3,16 @@ import Foundation
public struct VerifyReceiptInput: Equatable, Codable {

public init(
receiptData: String,
excludeOldTransactions: Bool,
receiptData: Data,
excludeOldTransactions: Bool? = nil,
password: String
) {
self.receiptData = receiptData
self.excludeOldTransactions = excludeOldTransactions
self.password = password
}
public let receiptData: String
public let excludeOldTransactions: Bool
public let receiptData: Data
public let excludeOldTransactions: Bool?
public let password: String

enum CodingKeys: String, CodingKey {
@@ -25,7 +25,7 @@ public struct VerifyReceiptInput: Equatable, Codable {

// MARK: - VerifyReceiptOutput
public struct VerifyReceiptOutput: Codable {
public let environment: String
public let environment: String?
public let receipt: Receipt
public let latestReceiptInfo: [LatestReceiptInfo]
public let latestReceipt: String
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import StoreKit

public struct VerifyReceiptEnvelope: Codable, Equatable {
public let verifiedProductIds: [String]
21 changes: 19 additions & 2 deletions Sources/NWSharedModels/User/UserObject.swift
Original file line number Diff line number Diff line change
@@ -2,11 +2,28 @@
import BSON

public enum UserRole: String, Codable, CaseIterable {
case basic, superAdmin, englishAdmin, russianAdmin, banglaAdmin
case basic, superAdmin, englishAdmin, russianAdmin, banglaAdmin, spanishAdmin

public var wordTitle: String {
switch self {
case .basic:
return "Basic User"
case .superAdmin:
return "I am SuperAdmin"
case .englishAdmin:
return "English Admin"
case .russianAdmin:
return "Russian Word"
case .banglaAdmin:
return "Bangla Word"
case .spanishAdmin:
return "Spanish Word"
}
}
}

public enum UserLanguage: String, Codable, CaseIterable {
case russian, english, bangla
case russian, english, bangla, spanish
}

public struct UserRoleAndLanguage: Encodable {
72 changes: 60 additions & 12 deletions Sources/NWSharedModels/Word/Word.swift
Original file line number Diff line number Diff line change
@@ -19,12 +19,27 @@ public final class WordModel: Model, Content, PropertyNames {
public init(
id: ObjectId? = nil,
icon: String? = nil,
englishWord: String, englishDefinition: String,
englishImageLink: String? = nil, englishVideoLink: String? = nil,
russianWord: String? = nil, russianDefinition: String? = nil,
russianImageLink: String? = nil, russianVideoLink: String? = nil,
banglaWord: String? = nil, banglaDefinition: String? = nil,
banglaImageLink: String? = nil, banglaVideoLink: String? = nil,

englishWord: String,
englishDefinition: String,
englishImageLink: String? = nil,
englishVideoLink: String? = nil,

russianWord: String? = nil,
russianDefinition: String? = nil,
russianImageLink: String? = nil,
russianVideoLink: String? = nil,

banglaWord: String? = nil,
banglaDefinition: String? = nil,
banglaImageLink: String? = nil,
banglaVideoLink: String? = nil,

spanishWord: String? = nil,
spanishDefinition: String? = nil,
spanishImageLink: String? = nil,
spanishVideoLink: String? = nil,

isReadFromNotification: Bool = false, isReadFromView: Bool = false,
level: WordLevel = .beginner, userId: ObjectId
) {
@@ -45,13 +60,19 @@ public final class WordModel: Model, Content, PropertyNames {
self.banglaImageLink = banglaImageLink
self.banglaVideoLink = banglaVideoLink

self.spanishWord = spanishWord
self.spanishDefinition = spanishDefinition
self.spanishImageLink = spanishImageLink
self.spanishVideoLink = spanishVideoLink

self.isReadFromNotification = isReadFromNotification
self.isReadFromView = isReadFromView
self.level = level

$user.id = userId
}

// @ID(key: "id") public var id: ObjectId?
@ID(custom: "id") public var id: ObjectId?

@OptionalField(key: "icon") public var icon: String?
@@ -70,6 +91,11 @@ public final class WordModel: Model, Content, PropertyNames {
@OptionalField(key: "banglaImageLink") public var banglaImageLink: String?
@OptionalField(key: "banglaVideoLink") public var banglaVideoLink: String?

@OptionalField(key: "spanishWord") public var spanishWord: String?
@OptionalField(key: "spanishDefinition") public var spanishDefinition: String?
@OptionalField(key: "spanishImageLink") public var spanishImageLink: String?
@OptionalField(key: "spanishVideoLink") public var spanishVideoLink: String?

@Field(key: "isReadFromNotification") public var isReadFromNotification: Bool
@Field(key: "isReadFromView") public var isReadFromView: Bool
@Field(key: "level") public var level: WordLevel
@@ -84,12 +110,29 @@ extension WordModel {

public func mapGet() -> WordGetObject {
.init(
_id: id!, icon: icon, englishWord: englishWord, englishDefinition: englishDefinition,
englishImageLink: englishImageLink, englishVideoLink: englishVideoLink,
russianWord: russianWord, russianDefinition: russianDefinition,
russianImageLink: russianImageLink, russianVideoLink: russianVideoLink,
banglaWord: banglaWord, banglaDefinition: banglaDefinition,
banglaImageLink: banglaImageLink, banglaVideoLink: banglaVideoLink,
_id: id!,
icon: icon,

englishWord: englishWord,
englishDefinition: englishDefinition,
englishImageLink: englishImageLink,
englishVideoLink: englishVideoLink,

russianWord: russianWord,
russianDefinition: russianDefinition,
russianImageLink: russianImageLink,
russianVideoLink: russianVideoLink,

banglaWord: banglaWord,
banglaDefinition: banglaDefinition,
banglaImageLink: banglaImageLink,
banglaVideoLink: banglaVideoLink,

spanishWord: spanishWord,
spanishDefinition: spanishDefinition,
spanishImageLink: spanishImageLink,
spanishVideoLink: spanishVideoLink,

isReadFromNotification: isReadFromNotification,
isReadFromView: isReadFromView, user: user.mapGetPublic(), level: level,
createdAt: createdAt, updatedAt: updatedAt
@@ -113,6 +156,11 @@ extension WordModel {
banglaImageLink = input.banglaImageLink
banglaVideoLink = input.banglaVideoLink

spanishWord = input.spanishWord
spanishDefinition = input.spanishDefinition
spanishImageLink = input.spanishImageLink
spanishVideoLink = input.spanishVideoLink

isReadFromNotification = input.isReadFromNotification
isReadFromView = input.isReadFromView
level = input.level
Loading

0 comments on commit 540e117

Please sign in to comment.