Skip to content

Commit

Permalink
Release 1.0.0-beta11 (#111)
Browse files Browse the repository at this point in the history
- Support Paper Check as a transfer method
- Support update transfer method
- Enhancements
  • Loading branch information
ddhar-hw authored Jan 27, 2021
1 parent a97c2ce commit ce8c7c6
Show file tree
Hide file tree
Showing 38 changed files with 3,467 additions and 195 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

[1.0.0-beta11](https://github.com/hyperwallet/hyperwallet-ios-sdk/releases/tag/1.0.0-beta11)
-------------------
- Support Paper Check as a transfer method
- Support update transfer method
- Enhancements


[1.0.0-beta10](https://github.com/hyperwallet/hyperwallet-ios-sdk/releases/tag/1.0.0-beta10)
-------------------
- Added Venmo as a Transfer method
Expand Down
2 changes: 1 addition & 1 deletion HyperwalletSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'HyperwalletSDK'
spec.version = '1.0.0-beta10'
spec.version = '1.0.0-beta11'
spec.summary = 'Hyperwallet Core SDK for iOS to integrate with Hyperwallet Platform'
spec.homepage = 'https://github.com/hyperwallet/hyperwallet-ios-sdk'
spec.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
74 changes: 70 additions & 4 deletions HyperwalletSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

99 changes: 96 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Hyperwallet iOS Core SDK

[![Platforms](https://img.shields.io/cocoapods/p/HyperwalletSDK.svg?)](https://cocoapods.org/pods/HyperwalletSDK)
[![Build Status](https://travis-ci.org/hyperwallet/hyperwallet-ios-sdk.svg?branch=master)](https://travis-ci.org/hyperwallet/hyperwallet-ios-sdk)
[![Build Status](https://travis-ci.com/hyperwallet/hyperwallet-ios-sdk.svg?branch=master)](https://travis-ci.com/hyperwallet/hyperwallet-ios-sdk)
[![Coverage Status](https://coveralls.io/repos/github/hyperwallet/hyperwallet-ios-sdk/badge.svg?branch=master)](https://coveralls.io/github/hyperwallet/hyperwallet-ios-sdk?branch=master)

[![CocoaPods](https://img.shields.io/cocoapods/v/HyperwalletSDK.svg?color=lightgray)](https://cocoapods.org/pods/HyperwalletSDK)
Expand All @@ -27,13 +27,13 @@ Use [Carthage](https://github.com/Carthage/Carthage) or [CocoaPods](https://coco
### Carthage
Specify it in your Cartfile:
```ogdl
github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta10"
github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta11"
```

### CocoaPods
Specify it in your Podfile:
```ruby
pod 'HyperwalletSDK', '~> 1.0.0-beta10'
pod 'HyperwalletSDK', '~> 1.0.0-beta11'
```

## Initialization
Expand Down Expand Up @@ -318,6 +318,81 @@ Hyperwallet.shared.listBankAccounts(queryParam: bankAccountQueryParam) { (result
}
```

### Create Paper Check

```swift
let paperCheck = HyperwalletPaperCheck.Builder(transferMethodCountry: "US",
transferMethodCurrency: "USD",
transferMethodProfileType: "INDIVIDUAL")
.shippingMethod("STANDARD")
.build()

Hyperwallet.shared.createPaperCheck(account: paperCheck, completion: { (result, error) in
// In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account creation
guard error == nil else {
print(error?.getHyperwalletErrors()?.errorList?)
return
}

// On successful creation, response (HyperwalletPaperCheck in this case) payload will contain information about the paper check created
print(result)
})
```
### Get Paper Check
```swift
Hyperwallet.shared.getPaperCheck(transferMethodToken: "123123", completion: { (result, error) in
// On success, response (HyperwalletPaperCheck? in this case) will contain information about the user’s paper check or nil if not exist.
// In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})
```

### Update Paper Check

```swift
let paperCheck = HyperwalletPaperCheck
.Builder(token: "12345")
.shippingMethod("STANDARD")
.build()

Hyperwallet.shared.updatePaperCheck(account: paperCheck, completion: { (response, error) in
// Code to handle successful response or error
// On successful update, response (HyperwalletPaperCheck in this case) payload will contain information about the paper check updated
// In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure while updating
})
```

### Deactivate Paper Check

```swift
Hyperwallet.shared.deactivatePaperCheck(transferMethodToken: "trm-12345", notes: "deactivate paper check", completion: { (result, error) in
// Code to handle successful response or error
// On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition
// In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})
```

### List Paper Check
```swift
let paperCheckQueryParam = HyperwalletPaperCheckQueryParam()
paperCheckQueryParam.status = HyperwalletPaperCheckQueryParam.QueryStatus.activated.rawValue
paperCheckQueryParam.sortBy = HyperwalletPaperCheckQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listPaperChecks(queryParam: paperCheckQueryParam) { (result, error) in
// In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
guard error == nil else {
print(error?.getHyperwalletErrors()?.errorList?)
return
}

// On success, response (HyperwalletPageList<HyperwalletPaperCheck>? in this case) will contain information about or nil if not exist.
if let paperChecks = result?.data {
for paperCheck in paperChecks {
print(paperCheck.token ?? "")
}
}
}
```

### Create Bank Card
```swift
let bankCard = HyperwalletBankCard.Builder(transferMethodCountry: "US",
Expand Down Expand Up @@ -638,5 +713,23 @@ Hyperwallet.shared.retrieveTransferMethodConfigurationFields(request: fieldQuery
}
```

### Get fields for updating transfer method
```swift
let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000001")

Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in
guard error == nil else {
print(error?.getHyperwalletErrors()?.errorList)
return
}

guard let result = result else { return }

print(result.transferMethodUpdateConfiguration()?.fieldGroups?.nodes)
print(result.transferMethodUpdateConfiguration()?.transferMethodType)
}
```


## License
The Hyperwallet iOS SDK is open source and available under the [MIT](https://github.com/hyperwallet/hyperwallet-ios-sdk/blob/master/LICENSE) license
169 changes: 167 additions & 2 deletions Sources/Hyperwallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,28 @@ public final class Hyperwallet: NSObject {
completionHandler: completion)
}

/// Creates a `HyperwalletPaperCheck` for the User associated with the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
///
/// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void`
/// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck)
/// or error(HyperwalletErrorType) from processing the request.
///
/// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
/// if the current one is expired or is about to expire.
///
/// - Parameters:
/// - account: the `HyperwalletPaperCheck` to be created
/// - completion: the callback handler of responses from the Hyperwallet platform
public func createPaperCheck(
account: HyperwalletPaperCheck,
completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) {
httpTransaction.performRest(httpMethod: .post,
urlPath: "users/%@/paper-checks",
payload: account,
completionHandler: completion)
}

/// Creates a `HyperwalletBankCard` for the User associated with the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
///
Expand Down Expand Up @@ -233,6 +255,34 @@ public final class Hyperwallet: NSObject {
completionHandler: completion)
}

/// Deactivates the `HyperwalletPaperCheck` linked to the transfer method token specified. The
/// `HyperwalletPaperCheck` being deactivated must belong to the User that is associated with the
/// authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
///
/// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
/// this method invocation will receive the successful response(HyperwalletStatusTransition) or
/// error(HyperwalletErrorType) from processing the request.
///
/// This function will request a new authentication token via HyperwalletAuthenticationTokenProvider`
/// if the current one is expired or is about to expire.
///
/// - Parameters:
/// - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPaperCheck`
/// being deactivated
/// - notes: a note regarding the status change
/// - completion: the callback handler of responses from the Hyperwallet platform
public func deactivatePaperCheck(transferMethodToken: String,
notes: String? = nil,
completion: @escaping (HyperwalletStatusTransition?,
HyperwalletErrorType?) -> Void) {
let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build()
httpTransaction.performRest(httpMethod: .post,
urlPath: "users/%@/paper-checks/\(transferMethodToken)/status-transitions",
payload: statusTransition,
completionHandler: completion)
}

/// Deactivates the `HyperwalletBankCard` linked to the transfer method token specified. The
/// `HyperwalletBankCard` being deactivated must belong to the User that is associated with the
/// authentication token returned from
Expand Down Expand Up @@ -359,6 +409,25 @@ public final class Hyperwallet: NSObject {
completionHandler: completion)
}

/// Returns the `HyperwalletPaperCheck` linked to the transfer method token specified, or nil if none exists.
///
/// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void`
/// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck)
/// or error(HyperwalletErrorType) from processing the request.
///
/// - Parameters:
/// - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPaperCheck`
/// being requested
/// - completion: the callback handler of responses from the Hyperwallet platform
public func getPaperCheck(
transferMethodToken: String,
completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) {
httpTransaction.performRest(httpMethod: .get,
urlPath: "users/%@/paper-checks/\(transferMethodToken)",
payload: "",
completionHandler: completion)
}

/// Returns the `HyperwalletBankCard` linked to the transfer method token specified, or nil if none exists.
///
/// The `completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void` that is passed in to
Expand Down Expand Up @@ -493,6 +562,44 @@ public final class Hyperwallet: NSObject {
completionHandler: completion)
}

/// Returns the list of `HyperwalletPaperCheck`s for the User associated with the authentication token
/// returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
/// or nil if non exist.
///
/// The ordering and filtering of `HyperwalletPaperCheck`s will be based on the criteria specified within
/// the `HyperwalletPaperCheckQueryParam` object, if it is not nil. Otherwise the default ordering and
/// filtering will be applied:
///
/// * Offset: 0
/// * Limit: 10
/// * Created Before: N/A
/// * Created After: N/A
/// * Type: Paper Check
/// * Status: All
/// * Sort By: Created On
///
/// The `completion: @escaping (HyperwalletPageList<HyperwalletPaperCheck>?, HyperwalletErrorType?) -> Void`
/// that is passed in to this method invocation will receive the successful
/// response(HyperwalletPageList<HyperwalletPaperCheck>?) or error(HyperwalletErrorType) from processing the
/// request.
///
/// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
/// if the current one is expired or is about to expire.
///
/// - Parameters:
/// - queryParam: the ordering and filtering criteria
/// - completion: the callback handler of responses from the Hyperwallet platform
public func listPaperChecks(queryParam: HyperwalletPaperCheckQueryParam? = nil,
completion: @escaping (HyperwalletPageList<HyperwalletPaperCheck>?,
HyperwalletErrorType?) -> Void) {
httpTransaction.performRest(httpMethod: .get,
urlPath: "users/%@/paper-checks",
payload: "",
queryParam: queryParam,
completionHandler: completion)
}

/// Returns the `HyperwalletBankCard` for the User associated with the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
/// or nil if non exist.
Expand Down Expand Up @@ -800,6 +907,28 @@ public final class Hyperwallet: NSObject {
completionHandler: transferMethodConfigurationFieldResponseHandler(completion))
}

/// Returns the transfer method update configuration fields set for the User that is associated with
/// the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
///
/// The `completion: @escaping (HyperwalletTransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void`
/// that is passed in to this method invocation will receive the successful
/// response(HyperwalletTransferMethodUpdateConfigurationField) or error(HyperwalletErrorType) from processing the
/// request.
///
/// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
/// if the current one is expired or is about to expire.
///
/// - Parameters:
/// - request: GraphQL query containing transfer method token and required configuration fields
/// - completion: the callback handler of responses from the Hyperwallet platform
public func retrieveTransferMethodUpdateConfigurationFields(
request: HyperwalletTransferMethodUpdateConfigurationFieldQuery,
completion: @escaping (HyperwalletTransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void) {
httpTransaction.performGraphQl(request, completionHandler:
transferMethodUpdateConfigurationFiledResponseHandler(completion))
}

/// Returns the transfer method configuration key set, processing times, and fees for the User that is associated
/// with the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
Expand Down Expand Up @@ -846,6 +975,31 @@ public final class Hyperwallet: NSObject {
completionHandler: completion)
}

/// Updates the `HyperwalletPaperCheck` for the User associated with the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
///
/// To identify the `HyperwalletPaperCheck` that is going to be updated, the transfer method token must be
/// set as part of the `HyperwalletPaperCheck` object passed in.
///
/// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void`
/// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck)
/// or error(HyperwalletErrorType) from processing the request.
///
/// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
/// if the current one is expired or is about to expire.
///
/// - parameters: account: the `HyperwalletPaperCheck` to be updated
/// - parameters: completion: the callback handler of responses from the Hyperwallet platform
public func updatePaperCheck(
account: HyperwalletPaperCheck,
completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) {
let token = account.token ?? ""
httpTransaction.performRest(httpMethod: .put,
urlPath: "users/%@/paper-checks/\(token)",
payload: account,
completionHandler: completion)
}

/// Updates the `HyperwalletBankCard` for the User associated with the authentication token returned from
/// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
///
Expand Down Expand Up @@ -989,8 +1143,19 @@ public final class Hyperwallet: NSObject {
private func transferMethodConfigurationFieldResponseHandler(_ completionHandler:
@escaping (TransferMethodConfigurationFieldResult?, HyperwalletErrorType?) -> Void)
-> (TransferMethodConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in
let result = TransferMethodConfigurationFieldResult(response?.transferMethodUIConfigurations?.nodes,
response?.countries?.nodes?.first)
let result =
TransferMethodConfigurationFieldResult(response?.transferMethodCreateUIConfigurations?.nodes,
response?.countries?.nodes?.first)
completionHandler(result, error)
}
}

private func transferMethodUpdateConfigurationFiledResponseHandler(_ completionHandler:
@escaping (TransferMethodUpdateConfigurationFieldResult?, HyperwalletErrorType?) -> Void)
-> (TransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in
let result = TransferMethodUpdateConfigurationFieldResult(response?
.transferMethodUpdateUIConfigurations?
.nodes)
completionHandler(result, error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>TAG_VERSION</key>
<string>1.0.0-beta10</string>
<string>1.0.0-beta11</string>
</dict>
</plist>
Loading

0 comments on commit ce8c7c6

Please sign in to comment.