Working on DART api (half-time)

This commit is contained in:
2023-07-10 09:27:55 +09:00
parent 5679950f4d
commit 6496d4e5a2
6 changed files with 1427 additions and 23 deletions

View File

@@ -65,6 +65,83 @@ public struct DomesticDart {
///
case annual = "11011"
}
public enum FinancialStatementDivision: String, Codable {
///
case consolated = "CFS"
///
case one = "OFS"
}
public enum StatementDivision: String, Codable {
///
case basis = "BS"
/// - - /
case basis1 = "BS1"
/// - - /
case basis2 = "BS2"
/// - -
case basis3 = "BS3"
/// - -
case basis4 = "BS4"
///
case income = "IS"
/// - -
case income1 = "IS1"
/// - -
case income2 = "IS2"
/// - -
case income3 = "IS3"
/// - -
case income4 = "IS4"
///
case comprehensiveIncome = "CIS"
/// - -
case comprehensiveIncome1 = "CIS1"
/// - -
case comprehensiveIncome2 = "CIS2"
/// - -
case comprehensiveIncome3 = "CIS3"
/// - -
case comprehensiveIncome4 = "CIS4"
///
case singleComprehensiveIncome = "DCIS"
/// - - -
case singleComprehensiveIncome1 = "DCIS1"
/// - - -
case singleComprehensiveIncome2 = "DCIS2"
/// - - -
case singleComprehensiveIncome3 = "DCIS3"
/// - - -
case singleComprehensiveIncome4 = "DCIS4"
/// - - -
case singleComprehensiveIncome5 = "DCIS5"
/// - - -
case singleComprehensiveIncome6 = "DCIS6"
/// - - -
case singleComprehensiveIncome7 = "DCIS7"
/// - - -
case singleComprehensiveIncome8 = "DCIS8"
///
case cashFlow = "CF"
/// - -
case cashFlow1 = "CF1"
/// - -
case cashFlow2 = "CF2"
/// - -
case cashFlow3 = "CF3"
/// - -
case cashFlow4 = "CF4"
///
case changesInEquity = "SCE"
/// -
case changesInEquity1 = "SCE1"
/// -
case changesInEquity2 = "SCE2"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,391 @@
//
// DomesticDartListedCompany.swift
// KissMe
//
// Created by ened-book-m1 on 2023/07/10.
//
import Foundation
extension DomesticDart {
/// - 1
///
public struct SingleAccountRequest: DartBalanceRequest {
public typealias KResult = AccountResult
public var url: String {
"/api/fnlttSinglAcnt.json"
}
public var result: KResult? = nil
public let openApiKey: String
public let corporationCode: String
public let businessYear: String
public let reportCode: ReportCode
public init(openApiKey: String, corporationCode: String, businessYear: String, reportCode: ReportCode) {
self.openApiKey = openApiKey
self.corporationCode = corporationCode
self.businessYear = businessYear
self.reportCode = reportCode
}
}
/// - 2
///
public struct MultipleAccountRequest: DartBalanceRequest {
public typealias KResult = AccountResult
public var url: String {
"/api/fnlttMultiAcnt.json"
}
public var result: KResult? = nil
public let openApiKey: String
public let corporationCode: String
public let businessYear: String
public let reportCode: ReportCode
public init(openApiKey: String, corporationCode: String, businessYear: String, reportCode: ReportCode) {
self.openApiKey = openApiKey
self.corporationCode = corporationCode
self.businessYear = businessYear
self.reportCode = reportCode
}
}
/// - 3 (XBRL)
///
public struct XBRLRequest: DartRequest {
public typealias KResult = Data // Zip file
public var url: String {
"/api/fnlttXbrl.xml"
}
public var method: Method { .get }
public var header: [String : String?] {
[:]
}
public var body: [String: Any] {
return [
"crtfc_key": openApiKey,
"rcept_no": receiptNo,
"reprt_code": reportCode.rawValue,
]
}
public var result: KResult? = nil
public let openApiKey: String
public let receiptNo: String
public let reportCode: ReportCode
public init(openApiKey: String, receiptNo: String, reportCode: ReportCode) {
self.openApiKey = openApiKey
self.receiptNo = receiptNo
self.reportCode = reportCode
}
}
/// - 4
///
public struct SingleAccountAllFinancialStatementRequest: DartRequest {
public typealias KResult = SingleAccountAllFinancialStatementResult
public var url: String {
"/api/fnlttSinglAcntAll.json"
}
public var method: Method { .get }
public var header: [String : String?] {
[:]
}
public var body: [String: Any] {
return [
"crtfc_key": openApiKey,
"corp_code": corporationCode,
"bsns_year": businessYear,
"reprt_code": reportCode.rawValue,
"fs_div": financialStatementDivision.rawValue
]
}
public var result: KResult? = nil
public let openApiKey: String
let corporationCode: String
let businessYear: String
let reportCode: ReportCode
let financialStatementDivision: FinancialStatementDivision
public init(openApiKey: String, corporationCode: String, businessYear: String, reportCode: ReportCode, financialStatementDivision: FinancialStatementDivision) {
self.openApiKey = openApiKey
self.corporationCode = corporationCode
self.businessYear = businessYear
self.reportCode = reportCode
self.financialStatementDivision = financialStatementDivision
}
}
/// - 5 XBRL
///
public struct XBRLTaxonomyRequest: DartRequest {
public typealias KResult = XBRLTaxonomyResult
public var url: String {
"/api/xbrlTaxonomy.json"
}
public var method: Method { .get }
public var header: [String : String?] {
[:]
}
public var body: [String: Any] {
return [
"crtfc_key": openApiKey,
"sj_div": statementDivision.rawValue,
]
}
public var result: KResult? = nil
public let openApiKey: String
let statementDivision: StatementDivision
init(openApiKey: String, statementDivision: StatementDivision) {
self.openApiKey = openApiKey
self.statementDivision = statementDivision
}
}
}
extension DomesticDart {
public struct AccountResult: Codable {
public let result: Result
public struct Result: Codable {
public let status: String
public let message: String
public let list: [Item]
private enum CodingKeys: String, CodingKey {
case status
case message
case list
}
}
public struct Item: Codable {
///
public let receiptNo: String
///
public let businessYear: String
///
public let productNo: String
///
public let reportCode: ReportCode
///
public let accountName: String
/// /
public let financialStatementDivision: String
/// /
public let financialStatementName: String
///
public let statementDivision: StatementDivision
///
public let statementName: String
///
public let thisTermName: String
///
public let thisTermDate: String
///
public let thisTermAmount: String
///
public let thisTermAccumulatedAmount: String
///
public let formerTermName: String
///
public let formerTermDate: String
///
public let formerTermAmount: String
///
public let formerTermAccumulatedAmount: String
///
public let beforeFormerTermName: String
///
public let beforeFormerTermDate: String
///
public let beforeFormerTermAmount: String
///
public let order: String
///
public let currency: String
private enum CodingKeys: String, CodingKey {
case receiptNo = "rcept_no"
case businessYear = "bsns_year"
case productNo = "stock_code"
case reportCode = "reprt_code"
case accountName = "account_nm"
case financialStatementDivision = "fs_div"
case financialStatementName = "fs_nm"
case statementDivision = "sj_div"
case statementName = "sj_nm"
case thisTermName = "thstrm_nm"
case thisTermDate = "thstrm_dt"
case thisTermAmount = "thstrm_amount"
case thisTermAccumulatedAmount = "thstrm_add_amount"
case formerTermName = "frmtrm_nm"
case formerTermDate = "frmtrm_dt"
case formerTermAmount = "frmtrm_amount"
case formerTermAccumulatedAmount = "frmtrm_add_amount"
case beforeFormerTermName = "bfefrmtrm_nm"
case beforeFormerTermDate = "bfefrmtrm_dt"
case beforeFormerTermAmount = "bfefrmtrm_amount"
case order = "ord"
case currency = "currency"
}
}
}
public struct SingleAccountAllFinancialStatementResult: Codable {
public let result: Result
public struct Result: Codable {
public let status: String
public let message: String
public let list: [Item]
private enum CodingKeys: String, CodingKey {
case status
case message
case list
}
}
public struct Item: Codable {
///
public let receiptNo: String
///
public let reportCode: ReportCode
///
public let businessYear: String
///
public let corporationCode: String
///
public let statementDivision: StatementDivision
///
public let statementName: String
/// ID
public let accountId: String
///
public let accountName: String
///
public let accountDetail: String
///
public let thisTermName: String
///
public let thisTermAmount: String
///
public let thisTermAccumulatedAmount: String
///
public let formerTermName: String
///
public let formerTermAmount: String
/// (/)
public let formerTermQuaterName: String
/// (/)
public let formerTermQuaterAmount: String
///
public let formerTermAccumulatedAmount: String
///
public let beforeFormerTermName: String
///
public let beforeFormerTermAmount: String
///
public let order: String
///
public let currency: String
private enum CodingKeys: String, CodingKey {
case receiptNo = "rcept_no"
case reportCode = "reprt_code"
case businessYear = "bsns_year"
case corporationCode = "corp_code"
case statementDivision = "sj_div"
case statementName = "sj_nm"
case accountId = "account_id"
case accountName = "account_nm"
case accountDetail = "account_detail"
case thisTermName = "thstrm_nm"
case thisTermAmount = "thstrm_amount"
case thisTermAccumulatedAmount = "thstrm_add_amount"
case formerTermName = "frmtrm_nm"
case formerTermAmount = "frmtrm_amount"
case formerTermQuaterName = "frmtrm_q_nm"
case formerTermQuaterAmount = "frmtrm_q_amount"
case formerTermAccumulatedAmount = "frmtrm_add_amount"
case beforeFormerTermName = "bfefrmtrm_nm"
case beforeFormerTermAmount = "bfefrmtrm_amount"
case order = "ord"
case currency = "currency"
}
}
}
public struct XBRLTaxonomyResult: Codable {
public let result: Result
public struct Result: Codable {
public let status: String
public let message: String
public let list: [Item]
private enum CodingKeys: String, CodingKey {
case status
case message
case list
}
}
public struct Item: Codable {
///
public let statementDivision: StatementDivision
/// ID
public let accountId: String
///
public let accountName: String
///
public let businessDate: String
///
public let labelKorean: String
///
public let labelEnglish: String
///
public let dataType: String
/// IFRS Reference
public let ifrsReference: String
private enum CodingKeys: String, CodingKey {
case statementDivision = "sj_div"
case accountId = "account_id"
case accountName = "account_nm"
case businessDate = "bsns_de"
case labelKorean = "label_kor"
case labelEnglish = "label_eng"
case dataType = "data_tp"
case ifrsReference = "ifrs_ref"
}
}
}
}

View File

@@ -10,7 +10,7 @@ import Foundation
extension DomesticDart {
/// -
/// - 1
///
public struct NoticeListRequest: DartRequest {
public typealias KResult = NoticeListResult
@@ -62,7 +62,7 @@ extension DomesticDart {
}
/// -
/// - 2
///
public struct CompanyRequest: DartRequest {
public typealias KResult = CompanyResult
@@ -94,7 +94,7 @@ extension DomesticDart {
}
/// -
/// - 3
///
public struct DocumentRequest: DartRequest {
public typealias KResult = Data
@@ -126,7 +126,7 @@ extension DomesticDart {
}
/// -
/// - 4
///
public struct CorporationCodesRequest: DartRequest {
public typealias KResult = CorporationCodesResult
@@ -230,7 +230,7 @@ extension DomesticDart {
/// () ()
public let stockName: String
///
public let productCode: String
public let productNo: String
///
public let ceoName: String
///
@@ -263,7 +263,7 @@ extension DomesticDart {
case corporationName = "corp_name"
case englishCorporationName = "corp_name_eng"
case stockName = "stock_name"
case productCode = "stock_code"
case productNo = "stock_code"
case ceoName = "ceo_nm"
case marketType = "corp_cls"
case corporationNo = "jurir_no"
@@ -302,14 +302,14 @@ extension DomesticDart {
///
public let corporationName: String
///
public let productCode: String
public let productNo: String
///
public let modifyDate: String
private enum CodingKeys: String, CodingKey {
case corporationCode = "corp_code"
case corporationName = "corp_name"
case productCode = "stock_code"
case productNo = "stock_code"
case modifyDate = "modify_date"
}
}

View File

@@ -43,6 +43,7 @@
34C1BA4F2A5A603F00423D64 /* DomesticExtra.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C1BA4E2A5A603F00423D64 /* DomesticExtra.swift */; };
34C1BA512A5A607D00423D64 /* DomesticDart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C1BA502A5A607D00423D64 /* DomesticDart.swift */; };
34C1BA532A5A683D00423D64 /* DomesticDartBusinessReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C1BA522A5A683D00423D64 /* DomesticDartBusinessReport.swift */; };
34C1BA552A5B033E00423D64 /* DomesticDartListedCompany.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C1BA542A5B033E00423D64 /* DomesticDartListedCompany.swift */; };
34D3680F2A2AA0BE005E6756 /* PropertyIterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D3680E2A2AA0BE005E6756 /* PropertyIterable.swift */; };
34E7B9112A49BD2800B3AB9F /* DomesticIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34E7B9102A49BD2800B3AB9F /* DomesticIndex.swift */; };
34F1900C2A41982A0068C697 /* KissIndexResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34F1900B2A41982A0068C697 /* KissIndexResult.swift */; };
@@ -98,6 +99,7 @@
34C1BA4E2A5A603F00423D64 /* DomesticExtra.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomesticExtra.swift; sourceTree = "<group>"; };
34C1BA502A5A607D00423D64 /* DomesticDart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomesticDart.swift; sourceTree = "<group>"; };
34C1BA522A5A683D00423D64 /* DomesticDartBusinessReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomesticDartBusinessReport.swift; sourceTree = "<group>"; };
34C1BA542A5B033E00423D64 /* DomesticDartListedCompany.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomesticDartListedCompany.swift; sourceTree = "<group>"; };
34D3680E2A2AA0BE005E6756 /* PropertyIterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertyIterable.swift; sourceTree = "<group>"; };
34E7B9102A49BD2800B3AB9F /* DomesticIndex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomesticIndex.swift; sourceTree = "<group>"; };
34F1900B2A41982A0068C697 /* KissIndexResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KissIndexResult.swift; sourceTree = "<group>"; };
@@ -237,6 +239,7 @@
34C1BA502A5A607D00423D64 /* DomesticDart.swift */,
34C1BA4C2A59CD3400423D64 /* DomesticDartNotice.swift */,
34C1BA522A5A683D00423D64 /* DomesticDartBusinessReport.swift */,
34C1BA542A5B033E00423D64 /* DomesticDartListedCompany.swift */,
);
path = DART;
sourceTree = "<group>";
@@ -388,6 +391,7 @@
340A4DCE2A4EA5D8005A1FBA /* Runner.swift in Sources */,
341F5F0B2A15115400962D48 /* KissShop.swift in Sources */,
3435A7F72A35D82000D604F1 /* DomesticShortSelling.swift in Sources */,
34C1BA552A5B033E00423D64 /* DomesticDartListedCompany.swift in Sources */,
341F5F072A14634F00962D48 /* Foundation+Extensions.swift in Sources */,
341F5F032A11A2BC00962D48 /* Credential.swift in Sources */,
341F5EB02A0A80EC00962D48 /* KissMe.docc in Sources */,