|
| 1 | +/* |
| 2 | + * -------------------------------------------------------------------------------- |
| 3 | + * <copyright company="Aspose" file="ProtectionRequestV2.swift"> |
| 4 | + * Copyright (c) 2023 Aspose.Words for Cloud |
| 5 | + * </copyright> |
| 6 | + * <summary> |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + * of this software and associated documentation files (the "Software"), to deal |
| 9 | + * in the Software without restriction, including without limitation the rights |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + * copies of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be included in all |
| 15 | + * copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | + * SOFTWARE. |
| 24 | + * </summary> |
| 25 | + * -------------------------------------------------------------------------------- |
| 26 | + */ |
| 27 | + |
| 28 | +import Foundation |
| 29 | + |
| 30 | +// Request on changing of protection. |
| 31 | +@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *) |
| 32 | +public class ProtectionRequestV2 : ProtectionRequestBase { |
| 33 | + // Gets or sets the new type of the document protection. |
| 34 | + public enum ProtectionType : String, Codable |
| 35 | + { |
| 36 | + // Enum value "allowOnlyRevisions" |
| 37 | + case allowOnlyRevisions = "AllowOnlyRevisions" |
| 38 | + |
| 39 | + // Enum value "allowOnlyComments" |
| 40 | + case allowOnlyComments = "AllowOnlyComments" |
| 41 | + |
| 42 | + // Enum value "allowOnlyFormFields" |
| 43 | + case allowOnlyFormFields = "AllowOnlyFormFields" |
| 44 | + |
| 45 | + // Enum value "readOnly" |
| 46 | + case readOnly = "ReadOnly" |
| 47 | + |
| 48 | + // Enum value "noProtection" |
| 49 | + case noProtection = "NoProtection" |
| 50 | + } |
| 51 | + |
| 52 | + // Field of protectionPassword. Request on changing of protection. |
| 53 | + private var _protectionPassword : String? = nil; |
| 54 | + |
| 55 | + public var protectionPassword : String? { |
| 56 | + get { |
| 57 | + return self._protectionPassword; |
| 58 | + } |
| 59 | + set { |
| 60 | + self._protectionPassword = newValue; |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + // Field of protectionType. Request on changing of protection. |
| 65 | + private var _protectionType : ProtectionType? = nil; |
| 66 | + |
| 67 | + public var protectionType : ProtectionType? { |
| 68 | + get { |
| 69 | + return self._protectionType; |
| 70 | + } |
| 71 | + set { |
| 72 | + self._protectionType = newValue; |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + private enum CodingKeys: String, CodingKey { |
| 77 | + case protectionPassword = "ProtectionPassword"; |
| 78 | + case protectionType = "ProtectionType"; |
| 79 | + case invalidCodingKey; |
| 80 | + } |
| 81 | + |
| 82 | + public override init() { |
| 83 | + super.init(); |
| 84 | + } |
| 85 | + |
| 86 | + public required init(from json: [String: Any]) throws { |
| 87 | + try super.init(from: json); |
| 88 | + self.protectionPassword = json["ProtectionPassword"] as? String; |
| 89 | + if let raw_protectionType = json["ProtectionType"] as? String { |
| 90 | + self.protectionType = ProtectionType(rawValue: raw_protectionType); |
| 91 | + } |
| 92 | + |
| 93 | + } |
| 94 | + |
| 95 | + public required init(from decoder: Decoder) throws { |
| 96 | + try super.init(from: decoder); |
| 97 | + let container = try decoder.container(keyedBy: CodingKeys.self); |
| 98 | + self.protectionPassword = try container.decodeIfPresent(String.self, forKey: .protectionPassword); |
| 99 | + self.protectionType = try container.decodeIfPresent(ProtectionType.self, forKey: .protectionType); |
| 100 | + } |
| 101 | + |
| 102 | + public override func encode(to encoder: Encoder) throws { |
| 103 | + try super.encode(to: encoder); |
| 104 | + var container = encoder.container(keyedBy: CodingKeys.self); |
| 105 | + if (self.protectionPassword != nil) { |
| 106 | + try container.encode(self.protectionPassword, forKey: .protectionPassword); |
| 107 | + } |
| 108 | + if (self.protectionType != nil) { |
| 109 | + try container.encode(self.protectionType, forKey: .protectionType); |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + public override func collectFilesContent(_ resultFilesContent : inout [FileReference]) { |
| 114 | + } |
| 115 | + |
| 116 | + public override func validate() throws { |
| 117 | + try super.validate(); |
| 118 | + if (self.protectionPassword == nil) |
| 119 | + { |
| 120 | + throw WordsApiError.requiredParameterError(paramName: "protectionPassword"); |
| 121 | + } |
| 122 | + if (self.protectionType == nil) |
| 123 | + { |
| 124 | + throw WordsApiError.requiredParameterError(paramName: "protectionType"); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + // Sets protectionPassword. Gets or sets the new password for the document protection. This property is required, but empty value is allowed. |
| 129 | + public func setProtectionPassword(protectionPassword : String?) -> ProtectionRequestV2 { |
| 130 | + self.protectionPassword = protectionPassword; |
| 131 | + return self; |
| 132 | + } |
| 133 | + |
| 134 | + // Gets protectionPassword. Gets or sets the new password for the document protection. This property is required, but empty value is allowed. |
| 135 | + public func getProtectionPassword() -> String? { |
| 136 | + return self.protectionPassword; |
| 137 | + } |
| 138 | + |
| 139 | + |
| 140 | + // Sets protectionType. Gets or sets the new type of the document protection. |
| 141 | + public func setProtectionType(protectionType : ProtectionType?) -> ProtectionRequestV2 { |
| 142 | + self.protectionType = protectionType; |
| 143 | + return self; |
| 144 | + } |
| 145 | + |
| 146 | + // Gets protectionType. Gets or sets the new type of the document protection. |
| 147 | + public func getProtectionType() -> ProtectionType? { |
| 148 | + return self.protectionType; |
| 149 | + } |
| 150 | +} |
0 commit comments