diff --git a/CHANGELOG.md b/CHANGELOG.md
index 786049e..f4d6ac2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,20 @@ All notable changes to this project will be documented in this file.
- `0.10.x` Betas
- [0.10.0](#0100)
- [0.10.1](#0101)
+ - [0.10.2](#0102)
- `0.9.x` Betas
- [0.9.11](#0911)
+---
+## [0.10.2](https://github.com/omisego/ios-sdk/releases/tag/0.10.2)
+Released on 2018-7-5. All issues associated with this milestone can be found using this [filter](https://github.com/omisego/ios-sdk/issues?utf8=%E2%9C%93&q=milestone%3A0.10.2).
+
+#### Fixed
+- decoding optional parameters for accounts.
+ - Updated by [Mederic](https://github.com/mederic-p) in Pull Request [#66](https://github.com/omisego/ios-sdk/pull/66)
+
---
## [0.10.1](https://github.com/omisego/ios-sdk/releases/tag/0.10.1)
Released on 2018-6-27. All issues associated with this milestone can be found using this [filter](https://github.com/omisego/ios-sdk/issues?utf8=%E2%9C%93&q=milestone%3A0.10.1).
diff --git a/OmiseGO.podspec b/OmiseGO.podspec
index f1ed521..c954266 100644
--- a/OmiseGO.podspec
+++ b/OmiseGO.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'OmiseGO'
- s.version = '0.10.1'
+ s.version = '0.10.2'
s.license = 'Apache'
s.summary = 'The OmiseGO iOS SDK allows developers to easily interact with a node of the OmiseGO eWallet.'
s.homepage = 'https://github.com/omisego/ios-sdk'
diff --git a/OmiseGO.xcodeproj/project.pbxproj b/OmiseGO.xcodeproj/project.pbxproj
index b86eca3..e21ece4 100644
--- a/OmiseGO.xcodeproj/project.pbxproj
+++ b/OmiseGO.xcodeproj/project.pbxproj
@@ -716,7 +716,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "if which swiftlint >/dev/null; then\n swiftlint lint\n swiftlint lint --config .swiftlint-test.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\nif which swiftformat >/dev/null; then\n swiftformat . --commas false --self insert\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi";
+ shellScript = "if which swiftformat >/dev/null; then\n swiftformat . --commas false --self insert\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi\nif which swiftlint >/dev/null; then\n swiftlint lint\n swiftlint lint --config .swiftlint-test.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
66B9F6BC22AA32602097E785 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
diff --git a/OmiseGOTests/CodingTests/DecodeTests.swift b/OmiseGOTests/CodingTests/DecodeTests.swift
index 99d40b0..1838b8b 100644
--- a/OmiseGOTests/CodingTests/DecodeTests.swift
+++ b/OmiseGOTests/CodingTests/DecodeTests.swift
@@ -444,6 +444,8 @@ class DecodeTests: XCTestCase {
XCTAssertEqual(decodedData.createdAt, "2018-01-01T00:00:00Z".toDate(withFormat: "yyyy-MM-dd'T'HH:mm:ssZ"))
XCTAssertTrue(decodedData.metadata.isEmpty)
XCTAssertTrue(decodedData.encryptedMetadata.isEmpty)
+ XCTAssertNil(decodedData.errorCode)
+ XCTAssertNil(decodedData.errorDescription)
} catch let thrownError {
XCTFail(thrownError.localizedDescription)
}
diff --git a/OmiseGOTests/FixtureTests/Fixtures/fixture/me.get_transactions.json b/OmiseGOTests/FixtureTests/Fixtures/fixture/me.get_transactions.json
index cc011fd..95ca307 100644
--- a/OmiseGOTests/FixtureTests/Fixtures/fixture/me.get_transactions.json
+++ b/OmiseGOTests/FixtureTests/Fixtures/fixture/me.get_transactions.json
@@ -53,7 +53,9 @@
"status": "confirmed",
"metadata": {},
"encrypted_metadata": {},
- "created_at": "2018-01-01T00:00:00Z"
+ "created_at": "2018-01-01T00:00:00Z",
+ "error_code": null,
+ "error_description": null
}
],
diff --git a/OmiseGOTests/FixtureTests/Fixtures/objects/transaction.json b/OmiseGOTests/FixtureTests/Fixtures/objects/transaction.json
index e269523..23c427a 100644
--- a/OmiseGOTests/FixtureTests/Fixtures/objects/transaction.json
+++ b/OmiseGOTests/FixtureTests/Fixtures/objects/transaction.json
@@ -47,5 +47,7 @@
"status": "confirmed",
"metadata": {},
"encrypted_metadata": {},
- "created_at": "2018-01-01T00:00:00Z"
+ "created_at": "2018-01-01T00:00:00Z",
+ "error_code": null,
+ "error_description": null
}
diff --git a/OmiseGOTests/Helpers/StubGenerator.swift b/OmiseGOTests/Helpers/StubGenerator.swift
index c498c6f..824c265 100644
--- a/OmiseGOTests/Helpers/StubGenerator.swift
+++ b/OmiseGOTests/Helpers/StubGenerator.swift
@@ -215,7 +215,9 @@ class StubGenerator {
exchange: TransactionExchange? = nil,
metadata: [String: Any]? = nil,
encryptedMetadata: [String: Any]? = nil,
- createdAt: Date? = nil)
+ createdAt: Date? = nil,
+ errorCode: String? = nil,
+ errorDescription: String? = nil)
-> Transaction {
let v: Transaction = self.stub(forResource: "transaction")
return Transaction(
@@ -226,7 +228,9 @@ class StubGenerator {
exchange: exchange ?? v.exchange,
metadata: metadata ?? v.metadata,
encryptedMetadata: encryptedMetadata ?? v.encryptedMetadata,
- createdAt: createdAt ?? v.createdAt)
+ createdAt: createdAt ?? v.createdAt,
+ errorCode: errorCode ?? v.errorCode,
+ errorDescription: errorDescription ?? v.errorDescription)
}
class func transactionSource(
diff --git a/README.md b/README.md
index a06b742..db1527e 100644
--- a/README.md
+++ b/README.md
@@ -295,9 +295,9 @@ let params = TransactionCreateParams(fromAddress: "1e3982f5-4a27-498d-a91b-7bb2e
Transaction.create(using: client, params: params) { (result) in
switch result {
case .success(data: let transaction):
- // TODO: Do something with the transaction
+ // TODO: Do something with the transaction
case .fail(error: let error):
- XCTFail("\(error)")
+ //TODO: Handle the error
}
}
```
@@ -359,13 +359,13 @@ Where:
The previously created `transactionRequest` can then be consumed:
```swift
-guard let params = TransactionConsumptionParams(transactionRequest: transactionRequest,
- address: "an address",
- amount: 1337,
- idempotencyToken: "an idempotency token",
- correlationId: "a correlation id",
- metadata: [:],
- encryptedMetadata: [:])!
+let params = TransactionConsumptionParams(transactionRequest: transactionRequest,
+ address: "an address",
+ amount: 1337,
+ idempotencyToken: "an idempotency token",
+ correlationId: "a correlation id",
+ metadata: [:],
+ encryptedMetadata: [:])!
TransactionConsumption.consumeTransactionRequest(using: client, params: params) { (transactionConsumptionResult) in
switch transactionConsumptionResult {
case .success(data: let transactionConsumption):
@@ -475,7 +475,7 @@ let configuration = ClientConfiguration(baseURL: "wss://your.base.url/api/socket
apiKey: "apiKey",
authenticationToken: "authenticationToken",
debugLog: false)
-let client = SocketClient(config: configuration, delegate: self)
+let socketClient = SocketClient(config: configuration, delegate: self)
```
Where:
@@ -507,7 +507,7 @@ And for each of the listenable resource there is an other specific method to rec
When creating a `TransactionRequest` that requires a confirmation it is possible to listen for all incoming confirmation using:
-`transactionRequest.startListeningEvents(withClient: client, eventDelegate: self)`
+`transactionRequest.startListeningEvents(withClient: socketClient, eventDelegate: self)`
Where:
- `client` is a `SocketClient`
@@ -533,7 +533,7 @@ This method will be called if a `TransactionConsumption` fails to consume the re
Similarly to transaction request events, a `TransactionConsumption` can be listened for incoming confirmations using:
-`consumption.startListeningEvents(withClient: client, eventDelegate: self)`
+`consumption.startListeningEvents(withClient: socketClient, eventDelegate: self)`
Where:
- `client` is a `SocketClient`
@@ -553,7 +553,7 @@ This method will be called if the `TransactionConsumption` fails to consume the
A `User` can also be listened and will receive all events that are related to him:
-`user.startListeningEvents(withClient: self.socketClient, eventDelegate: self)`
+`user.startListeningEvents(withClient: socketClient, eventDelegate: self)`
Where:
- `client` is a `SocketClient`
@@ -566,7 +566,7 @@ This method will be called when any event regarding the user is received. `Webso
#### Stop listening for events
-When you don't need to receive events anymore, you should call `stopListening(withClient client: SocketClient)` for the corresponding `Listenable` object. This will leave the corresponding socket channel and close the connection if no other channel is active.
+When you don't need to receive events anymore, you should call `stopListening(withClient client: socketClient)` for the corresponding `Listenable` object. This will leave the corresponding socket channel and close the connection if no other channel is active.
---
diff --git a/Source/Info.plist b/Source/Info.plist
index c7bcb1e..91762d1 100644
--- a/Source/Info.plist
+++ b/Source/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 0.10.1
+ 0.10.2
CFBundleVersion
$(CURRENT_PROJECT_VERSION)
NSPrincipalClass
diff --git a/Source/Models/Account.swift b/Source/Models/Account.swift
index 433b7c2..18a9f39 100644
--- a/Source/Models/Account.swift
+++ b/Source/Models/Account.swift
@@ -11,7 +11,7 @@ public struct Account {
/// The unique identifier of the account
public let id: String
/// The id of the parent account
- public let parentId: String
+ public let parentId: String?
/// The name of the account
public let name: String
/// The description of the account
@@ -47,7 +47,7 @@ extension Account: Decodable {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(String.self, forKey: .id)
- parentId = try container.decode(String.self, forKey: .parentId)
+ parentId = try container.decodeIfPresent(String.self, forKey: .parentId)
name = try container.decode(String.self, forKey: .name)
description = try container.decode(String.self, forKey: .description)
isMaster = try container.decode(Bool.self, forKey: .isMaster)
diff --git a/Source/Models/Avatar.swift b/Source/Models/Avatar.swift
index ca7aac0..eb6a615 100644
--- a/Source/Models/Avatar.swift
+++ b/Source/Models/Avatar.swift
@@ -9,11 +9,11 @@
/// Represents an avatar containing urls of different sizes
public struct Avatar: Decodable {
/// The url of the original image
- public let original: String
+ public let original: String?
/// The url of the large image
- public let large: String
+ public let large: String?
/// The url of the small image
- public let small: String
+ public let small: String?
/// The url of the thumbnail image
- public let thumb: String
+ public let thumb: String?
}
diff --git a/Source/Models/Transaction.swift b/Source/Models/Transaction.swift
index 67c9136..2a3c608 100644
--- a/Source/Models/Transaction.swift
+++ b/Source/Models/Transaction.swift
@@ -35,6 +35,10 @@ public struct Transaction {
public let encryptedMetadata: [String: Any]
/// The creation date of the transaction
public let createdAt: Date
+ /// An error code if the transaction encountered an error
+ public let errorCode: String?
+ /// The description of the encountered error
+ public let errorDescription: String?
}
extension Transaction: Decodable {
@@ -47,6 +51,8 @@ extension Transaction: Decodable {
case metadata
case encryptedMetadata = "encrypted_metadata"
case createdAt = "created_at"
+ case errorCode = "error_code"
+ case errorDescription = "error_description"
}
public init(from decoder: Decoder) throws {
@@ -59,6 +65,8 @@ extension Transaction: Decodable {
createdAt = try container.decode(Date.self, forKey: .createdAt)
metadata = try container.decode([String: Any].self, forKey: .metadata)
encryptedMetadata = try container.decode([String: Any].self, forKey: .encryptedMetadata)
+ errorCode = try container.decodeIfPresent(String.self, forKey: .errorCode)
+ errorDescription = try container.decodeIfPresent(String.self, forKey: .errorDescription)
}
}