-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EACQAPW-5763]: Реализовал передачу параметров для фискализации (#503)
* EACQAPW-5765. Implement passing `ffdVersion` into `v2/Init` request * EACQAPW-5765. Delete useless init * EACQAPW-5765. Update `Receipt` model * EACQAPW-5765. Update properties * EACQAPW-5763. Delete useless comment * EACQAPW-5763. Update `CHANGELOG.md` * EACQAPW-5763. Fixes after code review * EACQAPW-5763. Fixes after code review
- Loading branch information
Showing
8 changed files
with
181 additions
and
125 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
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
15 changes: 15 additions & 0 deletions
15
TinkoffASDKCore/TinkoffASDKCore/Domain/AcquiringAPI/Models/FfdVersion.swift
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,15 @@ | ||
// | ||
// FfdVersion.swift | ||
// TinkoffASDKCore | ||
// | ||
// Created by Никита Васильев on 02.08.2023. | ||
// | ||
// swiftlint:disable identifier_name | ||
|
||
import Foundation | ||
|
||
public enum FfdVersion: String, Codable { | ||
/// По умолчанию версия ФФД - 1.05 | ||
case version1_05 = "1.05" | ||
case version1_2 = "1.2" | ||
} |
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
71 changes: 71 additions & 0 deletions
71
TinkoffASDKCore/TinkoffASDKCore/Domain/AcquiringAPI/Models/ReceiptFdv1_05.swift
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,71 @@ | ||
// | ||
// ReceiptFdv1_05.swift | ||
// TinkoffASDKCore | ||
// | ||
// Created by Никита Васильев on 02.08.2023. | ||
// | ||
// swiftlint:disable type_name | ||
|
||
import Foundation | ||
|
||
public struct ReceiptFdv1_05: Encodable, Equatable { | ||
/// Код магазина | ||
public var shopCode: String? | ||
/// Электронный адрес для отправки чека покупателю | ||
/// Параметр `email` или `phone` должен быть заполнен. | ||
public var email: String? | ||
/// Телефон покупателя | ||
/// Параметр `email` или `phone` должен быть заполнен. | ||
public var phone: String? | ||
/// Система налогообложения | ||
public var taxation: Taxation | ||
/// Массив, содержащий в себе информацию о товарах | ||
public var items: [Item] | ||
/// Данные агента | ||
public var agentData: AgentData? | ||
/// Данные поставщика платежного агента | ||
public var supplierInfo: SupplierInfo? | ||
/// Версия ФФД. | ||
public let ffdVersion: FfdVersion = .version1_05 | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case shopCode = "ShopCode" | ||
case items = "Items" | ||
case ffdVersion = "FfdVersion" | ||
case email = "Email" | ||
case phone = "Phone" | ||
case taxation = "Taxation" | ||
case agentData = "AgentData" | ||
case supplierInfo = "SupplierInfo" | ||
} | ||
|
||
public init( | ||
shopCode: String?, | ||
email: String?, | ||
taxation: Taxation, | ||
phone: String?, | ||
items: [Item], | ||
agentData: AgentData?, | ||
supplierInfo: SupplierInfo? | ||
) { | ||
self.shopCode = shopCode | ||
self.email = email | ||
self.taxation = taxation | ||
self.phone = phone | ||
self.items = items | ||
self.agentData = agentData | ||
self.supplierInfo = supplierInfo | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(shopCode, forKey: .shopCode) | ||
try container.encodeIfPresent(email, forKey: .email) | ||
try container.encodeIfPresent(phone, forKey: .phone) | ||
try container.encodeIfPresent(agentData, forKey: .agentData) | ||
try container.encodeIfPresent(supplierInfo, forKey: .supplierInfo) | ||
try container.encode(ffdVersion, forKey: .ffdVersion) | ||
try container.encode(taxation.rawValue, forKey: .taxation) | ||
try container.encode(items, forKey: .items) | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
TinkoffASDKCore/TinkoffASDKCore/Domain/AcquiringAPI/Models/ReceiptFdv1_2.swift
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,53 @@ | ||
// | ||
// ReceiptFdv1_2.swift | ||
// TinkoffASDKCore | ||
// | ||
// Created by Никита Васильев on 02.08.2023. | ||
// | ||
// swiftlint:disable type_name | ||
|
||
import Foundation | ||
|
||
public struct ReceiptFdv1_2: Encodable, Equatable { | ||
|
||
public let base: ReceiptFdv1_05 | ||
/// Версия ФФД. | ||
public let ffdVersion: FfdVersion = .version1_2 | ||
/// Идентификатор покупателя | ||
public var customer: String? | ||
/// Инн покупателя. Если ИНН иностранного гражданина, необходимо указать 00000000000 | ||
public var customerInn: String? | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case shopCode = "ShopCode" | ||
case items = "Items" | ||
case ffdVersion = "FfdVersion" | ||
case email = "Email" | ||
case phone = "Phone" | ||
case taxation = "Taxation" | ||
case agentData = "AgentData" | ||
case supplierInfo = "SupplierInfo" | ||
case customer = "Customer" | ||
case customerInn = "CustomerInn" | ||
} | ||
|
||
public init(base: ReceiptFdv1_05, customer: String?, customerInn: String?) { | ||
self.base = base | ||
self.customer = customer | ||
self.customerInn = customerInn | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(base.shopCode, forKey: .shopCode) | ||
try container.encodeIfPresent(base.email, forKey: .email) | ||
try container.encodeIfPresent(base.phone, forKey: .phone) | ||
try container.encodeIfPresent(base.agentData, forKey: .agentData) | ||
try container.encodeIfPresent(base.supplierInfo, forKey: .supplierInfo) | ||
try container.encodeIfPresent(customer, forKey: .customer) | ||
try container.encodeIfPresent(customerInn, forKey: .customerInn) | ||
try container.encode(ffdVersion, forKey: .ffdVersion) | ||
try container.encode(base.taxation.rawValue, forKey: .taxation) | ||
try container.encode(base.items, forKey: .items) | ||
} | ||
} |
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