Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change amount and subunitToUnit to BigInt (#61)
* Add BigInt dependency * Add tests / Handle encoding and decoding * Update readme * Change subunitToUnit to BigInt * tmp pod update for travis * Update the way to parse decimal (temporary bug workaround) * Update codable * Fix wrong target name
- Loading branch information
Showing
28 changed files
with
676 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"value": 2147483647, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"value": 922337203685400, | ||
} |
3 changes: 3 additions & 0 deletions
3
OmiseGOTests/FixtureTests/Fixtures/objects/bigint_invalid.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"value": 999999999999999999999999999999999999991 | ||
} |
3 changes: 3 additions & 0 deletions
3
OmiseGOTests/FixtureTests/Fixtures/objects/bigint_over_int64.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"value": 99999999999999999999999999999999999998, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// BigIntDummy.swift | ||
// OmiseGOTests | ||
// | ||
// Created by Mederic Petit on 18/6/18. | ||
// Copyright © 2017-2018 Omise Go Pte. Ltd. All rights reserved. | ||
// | ||
|
||
@testable import OmiseGO | ||
import BigInt | ||
|
||
struct BigIntDummy { | ||
let value: BigInt | ||
} | ||
|
||
extension BigIntDummy: Codable { | ||
private enum CodingKeys: String, CodingKey { | ||
case value | ||
} | ||
|
||
func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(value, forKey: .value) | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
value = try container.decode(BigInt.self, forKey: .value) | ||
} | ||
} |
Oops, something went wrong.