Skip to content

Commit

Permalink
Merge pull request #49 from tink-sdk-build/release-changes-2.1.0-527
Browse files Browse the repository at this point in the history
BANKX-527: Tink Core 2.1.0 release
  • Loading branch information
belous committed Nov 17, 2023
2 parents 038b766 + 62bd48e commit efefc82
Show file tree
Hide file tree
Showing 45 changed files with 4,413 additions and 2,516 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
targets: [
.binaryTarget(
name: "TinkCore",
url: "https://github.com/tink-ab/tink-core-ios/releases/download/2.0.0/TinkCore.xcframework.zip", checksum: "b6f61c67ed2dac2fcca3a75253dd642285d002eb88cd5d7986d789f818814be7"
url: "https://github.com/tink-ab/tink-core-ios/releases/download/2.1.0/TinkCore.xcframework.zip", checksum: "b44c79ad86466339a11555e565994c0e88b300e50a1c86ad06f92c40980bcf95"
),
]
)
2 changes: 1 addition & 1 deletion Sources/TinkCore/AIS/Models/SelectOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct SelectOption: Equatable {
self.value = value
}

internal init(restSelectOption: RESTSelectOption) {
init(restSelectOption: RESTSelectOption) {
self.iconURL = restSelectOption.iconUrl
self.text = restSelectOption.text
self.value = restSelectOption.value
Expand Down
10 changes: 10 additions & 0 deletions Sources/TinkCore/PFM/Models/Mapping/RecommendedBudget+REST.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

extension RecommendedBudget {
init(restRecommendedBudget: RESTRecommendedBudget) {
self.amount = CurrencyDenominatedAmount(restCurrencyDenominatedAmount: restRecommendedBudget.amount)
self.filter = Budget.Filter.makeFilters(restFilter: restRecommendedBudget.filter)
self.name = restRecommendedBudget.name
self.recurringPeriodicity = Budget.RecurringPeriodicity(restRecurringPeriodicity: restRecommendedBudget.recurringPeriodicity)
}
}
12 changes: 12 additions & 0 deletions Sources/TinkCore/PFM/Models/RecommendedBudget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

public struct RecommendedBudget {
/// The target amount for the budget. The currency will match the user profile currency setting.
public let amount: CurrencyDenominatedAmount?
/// The filter defines the budget and which transactions that are included in it. The configured fields of the filter are applied as logical and operator (intersection).
public let filter: [Budget.Filter]
/// The name of the recommended Budget.
public let name: String
/// Periodicity configuration for the recurring budget.
public let recurringPeriodicity: Budget.RecurringPeriodicity?
}
12 changes: 12 additions & 0 deletions Sources/TinkCore/PFM/REST/Models/RESTRecommendedBudget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

struct RESTRecommendedBudget: Decodable {
let amount: RESTCurrencyDenominatedAmount
let filter: RESTBudget.Filter
let name: String
let recurringPeriodicity: RESTBudget.RecurringPeriodicity
}

struct RESTRecommendedBudgetResponse: Decodable {
let recommendedBudgets: [RESTRecommendedBudget]
}
15 changes: 15 additions & 0 deletions Sources/TinkCore/PFM/REST/Services/RESTBudgetService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,19 @@ final class RESTBudgetService: BudgetService {
}
return client.performRequest(request)
}

@discardableResult
func recommendedBudgets(
completion: @escaping (Result<[RecommendedBudget], Error>) -> Void
) -> Cancellable? {
let request = RESTResourceRequest<RESTRecommendedBudgetResponse>(
path: "/api/v1/budgets/recommended",
method: .get,
contentType: .json
) { result in
let newResult = result.map { $0.recommendedBudgets.compactMap(RecommendedBudget.init(restRecommendedBudget:)) }
completion(newResult)
}
return client.performRequest(request)
}
}
2 changes: 2 additions & 0 deletions Sources/TinkCore/PFM/Services/BudgetService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public protocol BudgetService {
func budgetDetails(id: Budget.ID, dateInterval: DateInterval, completion: @escaping (Result<BudgetDetails, Error>) -> Void) -> Cancellable?

func archive(id: Budget.ID, completion: @escaping (Result<Budget, Error>) -> Void) -> Cancellable?

func recommendedBudgets(completion: @escaping (Result<[RecommendedBudget], Error>) -> Void) -> Cancellable?
}
2 changes: 1 addition & 1 deletion Sources/TinkCore/Shared/Tink/Tink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
#endif

/// Current TinkCore version.
public let version = "2.0.0"
public let version = "2.1.0"

/// The `Tink` class encapsulates a connection to the Tink API.
///
Expand Down
2 changes: 1 addition & 1 deletion Tests/TinkCoreTests/CurrencyDenominatedAmountTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import TinkCore
import XCTest

extension CurrencyDenominatedAmount {
var doubleValue: Double {
Expand Down
2 changes: 1 addition & 1 deletion Tests/TinkCoreTests/PFM/Models/CodeTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import TinkCore
import XCTest

final class CodeTests: XCTestCase {
func testInit() {
Expand Down
21 changes: 21 additions & 0 deletions Tests/TinkCoreTests/PFM/Models/RecommendedBudgetTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@testable import TinkCore
import XCTest

final class RecommendedBudgetTests: XCTestCase {
func testMapping() throws {
let sut = try RecommendedBudget(restRecommendedBudget: RESTRecommendedBudget.instanceFromJson())

XCTAssertTrue(sut.amount == CurrencyDenominatedAmount(10.5, currencyCode: "EUR"))
if case Budget.Filter.category(let cat) = sut.filter[0] {
XCTAssertTrue(cat == "expenses:food.coffee")
} else {
XCTFail()
}
XCTAssertTrue(sut.name == "Coffee budget")
XCTAssertTrue(sut.recurringPeriodicity?.periodUnit == Budget.RecurringPeriodicity.PeriodUnit.week)
}
}

extension RecommendedBudget {
static func dummyInstance() throws -> Self { try RecommendedBudget(restRecommendedBudget: RESTRecommendedBudget.instanceFromJson()) }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import TinkCore
import XCTest

class ActionableInsightsRESTDecodingTests: XCTestCase {
let decoder = JSONDecoder()
Expand Down
40 changes: 40 additions & 0 deletions Tests/TinkCoreTests/REST/RESTRecommendedBudgetResponseTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@testable import TinkCore
import XCTest

final class RESTRecommendedBudgetResponseTests: XCTestCase {
func testDecodable() throws {
let data = RESTRecommendedBudgetResponse.json.data(using: String.Encoding.utf8)
let decoder = JSONDecoder()
let sut = try decoder.decode(RESTRecommendedBudgetResponse.self, from: data!)

XCTAssertTrue(sut.recommendedBudgets.count == 1)
}
}

extension RESTRecommendedBudgetResponse {
static let json: String =
"""
{
"recommendedBudgets": [
{
"amount": {
"currencyCode": "EUR",
"scale": 2,
"unscaledValue": 1050
},
"filter": {
"categories": [
{
"code": "expenses:food.coffee"
}
]
},
"name": "Coffee budget",
"recurringPeriodicity": {
"periodUnit": "WEEK"
}
}
]
}
"""
}
50 changes: 50 additions & 0 deletions Tests/TinkCoreTests/REST/RESTRecommendedBudgetTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@testable import TinkCore
import XCTest

final class RESTRecommendedBudgetTests: XCTestCase {
func testDecodable() throws {
let sut0 = try RESTRecommendedBudget.instanceFromJson()

XCTAssertEqual(sut0.amount.currencyCode, "EUR")
XCTAssertEqual(sut0.amount.scale, 2)
XCTAssertEqual(sut0.amount.unscaledValue, 1050)

XCTAssertNil(sut0.filter.tags)
XCTAssertNil(sut0.filter.freeTextQuery)
XCTAssertNil(sut0.filter.accounts)
XCTAssertEqual(sut0.filter.categories?.count, 1)
XCTAssertEqual(sut0.filter.categories?[0].code, "expenses:food.coffee")

XCTAssertEqual(sut0.name, "Coffee budget")

XCTAssertEqual(sut0.recurringPeriodicity.periodUnit.rawValue, "WEEK")
}
}

extension RESTRecommendedBudget {
static let json: String =
"""
{
"amount": {
"currencyCode": "EUR",
"scale": 2,
"unscaledValue": 1050
},
"filter": {
"categories": [
{
"code": "expenses:food.coffee"
}
]
},
"name": "Coffee budget",
"recurringPeriodicity": {
"periodUnit": "WEEK"
}
}
"""

static func instanceFromJson() throws -> Self {
try JSONDecoder().decode(Self.self, from: json.data(using: String.Encoding.utf8)!)
}
}
2 changes: 1 addition & 1 deletion Tests/TinkCoreTests/ScopeTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import TinkCore
import XCTest

class ScopeTests: XCTestCase {
func testScopeDescription() {
Expand Down
2 changes: 1 addition & 1 deletion TinkCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pod::Spec.new do |spec|
spec.description = <<-DESC
Core library for Tink SDKs.
DESC
spec.version = "2.0.0"
spec.version = "2.1.0"
spec.license = { :type => "MIT", :file => "LICENSE" }
spec.authors = { "Tink AB" => "mobile@tink.se" }
spec.homepage = "https://github.com/tink-ab/tink-core-ios"
Expand Down
10 changes: 5 additions & 5 deletions TinkCore.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>TinkCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
Expand All @@ -31,18 +34,15 @@
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>TinkCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file modified TinkCore.xcframework/ios-arm64/TinkCore.framework/Info.plist
Binary file not shown.

0 comments on commit efefc82

Please sign in to comment.