Skip to content

Commit

Permalink
Release 1.0.0-beta13 (#305)
Browse files Browse the repository at this point in the history
- UI Enhancements
- Added support for iOS 14
  • Loading branch information
jsaini-hw authored Mar 31, 2021
1 parent 74d1f51 commit 643d88b
Show file tree
Hide file tree
Showing 64 changed files with 1,421 additions and 223 deletions.
4 changes: 3 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ disabled_rules: # rule identifiers to exclude from running
- file_length
- closure_body_length
- implicit_return
- empty_xctest_method
- inclusive_language
- trailing_whitespace
type_name:
max_length: # warning and error
warning: 60
Expand All @@ -18,7 +21,6 @@ opt_in_rules: # some rules are only opt-in
- unused_declaration
- empty_count
- empty_string
- empty_xctest_method
- explicit_init
- closure_body_length
- closure_end_indentation
Expand Down
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode11.7
osx_image: xcode12.2
os: osx
branches:
only:
Expand All @@ -15,9 +15,9 @@ env:
- IOS_FRAMEWORK_SCHEME="HyperwalletUISDK"
- IOS_UI_TESTS_SCHEME="Demo"
matrix:
- ios_version='13.7' ios_device='iPhone 11' scheme="$IOS_FRAMEWORK_SCHEME" platform='iOS
- ios_version='14.2' ios_device='iPhone 11' scheme="$IOS_FRAMEWORK_SCHEME" platform='iOS
Simulator' configuration="Debug" code_coverage="YES" publish_docs="NO" only_active_arch="YES"
- ios_version='13.7' ios_device='iPhone 11' scheme="$IOS_UI_TESTS_SCHEME" platform='iOS
- ios_version='14.2' ios_device='iPhone 11' scheme="$IOS_UI_TESTS_SCHEME" platform='iOS
Simulator' configuration="XCUITest" code_coverage="NO" publish_docs="NO" only_active_arch="NO"
before_install:
# Boot the emulator by ID
Expand All @@ -28,7 +28,9 @@ before_install:
- xcrun simctl list
# Update the brew and build dependencies tools
# - brew outdated carthage || brew upgrade carthage
- Carthage update --platform iOS --cache-builds
- brew update && brew upgrade carthage
- carthage version
- carthage update --platform ios --use-xcframeworks --no-use-binaries --cache-builds
- gem i slather
# Install build output formatting tool
- gem install xcpretty
Expand Down
29 changes: 29 additions & 0 deletions BalanceRepository/Sources/BalanceRepository.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright 2018 - Present Hyperwallet
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#import <Foundation/Foundation.h>

//! Project version number for BalanceRepository.
FOUNDATION_EXPORT double BalanceRepositoryVersionNumber;

//! Project version string for BalanceRepository.
FOUNDATION_EXPORT const unsigned char BalanceRepositoryVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <BalanceRepository/PublicHeader.h>


41 changes: 41 additions & 0 deletions BalanceRepository/Sources/BalanceRepositoryFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import HyperwalletSDK

/// Balance repository factory
public final class BalanceRepositoryFactory {
private static var instance: BalanceRepositoryFactory?
private var remoteUserBalanceRepository: UserBalanceRepository
private var remotePrepaidCardBalanceRepository: PrepaidCardBalanceRepository

/// Returns the previously initialized instance of the BalanceRepositoryFactory object
public static var shared: BalanceRepositoryFactory {
guard let instance = instance else {
self.instance = BalanceRepositoryFactory()
return self.instance!
}
return instance
}

private init() {
remoteUserBalanceRepository = RemoteUserBalanceRepository()
remotePrepaidCardBalanceRepository = RemotePrepaidCardBalanceRepository()
}

/// Clears the BalanceRepositoryFactory singleton instance.
public static func clearInstance() {
instance = nil
}

/// Gets the `UserBalanceRepository` implementation.
///
/// - Returns: The implementation of the UserBalanceRepository protocol
public func userBalanceRepository() -> UserBalanceRepository {
return remoteUserBalanceRepository
}

/// Gets the `PrepaidCardBalanceRepository` implementation.
///
/// - Returns: The implementation of the PrepaidCardBalanceRepository protocol
public func prepaidCardBalanceRepository() -> PrepaidCardBalanceRepository {
return remotePrepaidCardBalanceRepository
}
}
22 changes: 22 additions & 0 deletions BalanceRepository/Sources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
58 changes: 58 additions & 0 deletions BalanceRepository/Sources/PrepaidCardBalanceRepository.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import HyperwalletSDK

/// Prepaid Card balance repository protocol
public protocol PrepaidCardBalanceRepository {
/// Returns the list of balances for the Prepaid Card associated with the authentication user.
///
/// - Parameters:
/// - offset: The number of records to skip. If no filters are applied, records will be skipped from the
/// beginning (based on default sort criteria). Range is from 0 to {n-1} where
/// n = number of matching records for the query.
/// - limit: The maximum number of records that will be returned per page.
/// - completion: The callback handler of responses from the Hyperwallet platform.
func listPrepaidCardBalances(prepaidCardToken: String,
offset: Int,
limit: Int,
completion: @escaping (Result<HyperwalletPageList<HyperwalletBalance>?,
HyperwalletErrorType>) -> Void)
}

/// Prepaid Card balance repository
public final class RemotePrepaidCardBalanceRepository: PrepaidCardBalanceRepository {
public func listPrepaidCardBalances(prepaidCardToken: String,
offset: Int,
limit: Int,
completion: @escaping (Result<HyperwalletPageList<HyperwalletBalance>?,
HyperwalletErrorType>) -> Void) {
Hyperwallet.shared.listPrepaidCardBalances(prepaidCardToken: prepaidCardToken,
queryParam: setUpPrepaidCardBalanceQueryParam(offset, limit),
completion: listPrepaidCardBalancesHandler(completion))
}

/// Preparid card balance response handler
private func listPrepaidCardBalancesHandler(
_ completion: @escaping (Result<HyperwalletPageList<HyperwalletBalance>?,
HyperwalletErrorType>) -> Void)
-> (HyperwalletPageList<HyperwalletBalance>?, HyperwalletErrorType?) -> Void {
return { (result, error) in
if let error = error {
DispatchQueue.main.async {
completion(.failure(error))
}
} else {
DispatchQueue.main.async {
completion(.success(result))
}
}
}
}

/// Set up prepaid card balance query param
private func setUpPrepaidCardBalanceQueryParam(_ offset: Int, _ limit: Int)
-> HyperwalletPrepaidCardBalanceQueryParam {
let queryParam = HyperwalletPrepaidCardBalanceQueryParam()
queryParam.offset = offset
queryParam.limit = limit
return queryParam
}
}
44 changes: 44 additions & 0 deletions BalanceRepository/Sources/UserBalanceRepository.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import HyperwalletSDK

/// User balance repository protocol
public protocol UserBalanceRepository {
/// Returns the list of balances for the User associated with the authentication token.
///
/// - Parameters:
/// - offset: The number of records to skip. If no filters are applied, records will be skipped from the
/// beginning (based on default sort criteria). Range is from 0 to {n-1} where
/// n = number of matching records for the query.
/// - limit: The maximum number of records that will be returned per page.
/// - completion: The callback handler of responses from the Hyperwallet platform.
func listUserBalances( offset: Int,
limit: Int,
completion: @escaping (Result<HyperwalletPageList<HyperwalletBalance>?,
HyperwalletErrorType>) -> Void)
}

/// User balance repository
public final class RemoteUserBalanceRepository: UserBalanceRepository {
public func listUserBalances( offset: Int,
limit: Int,
completion: @escaping (Result<HyperwalletPageList<HyperwalletBalance>?,
HyperwalletErrorType>) -> Void) {
Hyperwallet.shared.listUserBalances(queryParam: setUpBalanceQueryParam(offset, limit),
completion: listUserBalancesHandler(completion))
}

private func listUserBalancesHandler(
_ completion: @escaping (Result<HyperwalletPageList<HyperwalletBalance>?,
HyperwalletErrorType>) -> Void)
-> (HyperwalletPageList<HyperwalletBalance>?, HyperwalletErrorType?) -> Void {
return { (result, error) in if let error = error {
DispatchQueue.main.async { completion(.failure(error)) } } else {
DispatchQueue.main.async { completion(.success(result)) } } }
}

private func setUpBalanceQueryParam(_ offset: Int, _ limit: Int) -> HyperwalletBalanceQueryParam {
let queryParam = HyperwalletBalanceQueryParam()
queryParam.offset = offset
queryParam.limit = limit
return queryParam
}
}
22 changes: 22 additions & 0 deletions BalanceRepository/Tests/BalanceRepositoryFactoryTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import BalanceRepository
import XCTest

class BalanceRepositoryFactoryTests: XCTestCase {
func testBalanceRepository() {
let factory = BalanceRepositoryFactory.shared

XCTAssertNotNil(factory, "BalanceRepositoryFactory instance should not be nil")
XCTAssertNoThrow(factory.userBalanceRepository(), "BalanceRepository should exist")
XCTAssertNoThrow(factory.prepaidCardBalanceRepository(), "PrepaidCardBalanceRepository should exist")
}

func testClearInstance() {
let factory = BalanceRepositoryFactory.shared
BalanceRepositoryFactory.clearInstance()
let recreatedFactory = BalanceRepositoryFactory.shared

XCTAssertNotNil(factory, "Previously created BalanceRepositoryFactory instance should not be nil")
XCTAssertNotNil(recreatedFactory, "Recreated BalanceRepositoryFactory instance should not be nil")
XCTAssertFalse(factory === recreatedFactory, "Factory instances should not be the same")
}
}
43 changes: 43 additions & 0 deletions BalanceRepository/Tests/Helper/BalanceRequestHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Copyright 2018 - Present Hyperwallet
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import Hippolyte
import HyperwalletSDK
import XCTest

class PrepaidCardBalanceRequestHelper {
static func setUpRequest(_ payload: Data,
_ error: NSError? = nil,
_ prepaidCardToken: String? = nil,
_ httpCode: Int = 200) -> StubRequest {
let response = HyperwalletTestHelper.setUpMockedResponse(payload: payload, error: error)
let balanceURL = "/prepaid-cards/\(prepaidCardToken!)/balances?"
let url = String(format: "%@%@", HyperwalletTestHelper.userRestURL, balanceURL)
return HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response)
}
}

class UserBalanceRequestHelper {
static func setUpRequest(_ payload: Data,
_ error: NSError? = nil,
_ httpCode: Int = 200) -> StubRequest {
let response = HyperwalletTestHelper.setUpMockedResponse(payload: payload, error: error)
let url = String(format: "%@/balances?", HyperwalletTestHelper.userRestURL)
return HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response)
}
}
22 changes: 22 additions & 0 deletions BalanceRepository/Tests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
Loading

0 comments on commit 643d88b

Please sign in to comment.