-
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.
- Loading branch information
Georgi Yanakiev
committed
Apr 10, 2023
1 parent
f295aef
commit 43c1347
Showing
9 changed files
with
242 additions
and
31 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
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,80 @@ | ||
// | ||
// BusinessAttributes.swift | ||
// GenesisSwift | ||
// | ||
// Created by Georgi Yanakiev emerchantpay on 3.04.23. | ||
// Copyright © 2023 eMerchantPay. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct BusinessAttributes { | ||
|
||
public let eventStartDate: Date? | ||
public let eventEndDate: Date? | ||
public let eventOrganizerId: String? | ||
public let eventId: String? | ||
public let dateOfOrder: Date? | ||
public let deliveryDate: Date? | ||
public let nameOfTheSupplier: String? | ||
|
||
public init(eventStartDate: Date? = nil, | ||
eventEndDate: Date? = nil, | ||
eventOrganizerId: String? = nil, | ||
eventId: String? = nil, | ||
dateOfOrder: Date? = nil, | ||
deliveryDate: Date? = nil, | ||
nameOfTheSupplier: String? = nil) { | ||
|
||
self.eventStartDate = eventStartDate | ||
self.eventEndDate = eventEndDate | ||
self.eventOrganizerId = eventOrganizerId | ||
self.eventId = eventId | ||
self.dateOfOrder = dateOfOrder | ||
self.deliveryDate = deliveryDate | ||
self.nameOfTheSupplier = nameOfTheSupplier | ||
} | ||
|
||
subscript(key: String) -> Any? { | ||
switch key { | ||
case EventStartDateKey: return eventStartDate | ||
case EventEndDateKey: return eventEndDate | ||
case EventOrganizerIdKey: return eventOrganizerId | ||
case EventIdKey: return eventId | ||
case DateOfOrderKey: return dateOfOrder | ||
case DeliveryDateKey: return deliveryDate | ||
case NameOfTheSupplierKey: return nameOfTheSupplier | ||
default: return nil | ||
} | ||
} | ||
} | ||
|
||
//MARK: GenesisDescriptionProtocol | ||
extension BusinessAttributes: GenesisDescriptionProtocol { | ||
func description() -> String { | ||
toXmlString() | ||
} | ||
|
||
} | ||
|
||
// MARK: GenesisXmlObjectProtocol | ||
extension BusinessAttributes: GenesisXmlObjectProtocol { | ||
func propertyMap() -> [String : String] { | ||
[EventStartDateKey: "event_start_date", | ||
EventEndDateKey: "event_end_date", | ||
EventOrganizerIdKey: "event_organizer_id", | ||
EventIdKey: "event_id", | ||
DateOfOrderKey: "date_of_order", | ||
DeliveryDateKey: "delivery_date", | ||
NameOfTheSupplierKey: "name_of_the_supplier"] | ||
} | ||
|
||
func toXmlString() -> String { | ||
var xmlString = "" | ||
for (key, value) in propertyMap() { | ||
guard let varValue = self[key] else { continue } | ||
xmlString += "<\(value)>" + String(describing: varValue) + "</\(value)>" | ||
} | ||
return xmlString | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// PaymentSubtype.swift | ||
// GenesisSwift | ||
// | ||
// Created by Georgi Yanakiev emerchantpay on 3.04.23. | ||
// Copyright © 2023 eMerchantPay. All rights reserved. | ||
// | ||
|
||
public struct PaymentSubtype { | ||
|
||
public enum TypeValues: String, CaseIterable { | ||
case authorize | ||
case sale | ||
case initRecurringSale = "init_recurring_sale" | ||
} | ||
|
||
public let type: TypeValues | ||
|
||
public init(type: TypeValues) { | ||
self.type = type | ||
} | ||
} | ||
|
||
// MARK: - GenesisDescriptionProtocol | ||
|
||
extension PaymentSubtype: GenesisDescriptionProtocol, XMLConvertable { | ||
|
||
func description() -> String { | ||
type.rawValue | ||
} | ||
} |
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
Oops, something went wrong.