Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T209 update transaction request and consumption params #31

Merged
merged 2 commits into from Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion OmiseGOTests/CodingTests/EncodeTests.swift
Expand Up @@ -260,7 +260,6 @@ class EncodeTests: XCTestCase {
amount: nil,
idempotencyToken: "123",
correlationId: "321",
expirationDate: Date(timeIntervalSince1970: 0),
metadata: [:])
let encodedData = try self.encoder.encode(transactionConsumptionParams)
let encodedPayload = try! transactionConsumptionParams!.encodedPayload()
Expand Down
Expand Up @@ -29,7 +29,6 @@ class TransactionConsumptionFixtureTests: FixtureTestCase {
amount: nil,
idempotencyToken: "123",
correlationId: nil,
expirationDate: nil,
metadata: [:])!
let request =
TransactionConsumption.consumeTransactionRequest(using: self.testCustomClient, params: params) { (result) in
Expand Down
1 change: 0 additions & 1 deletion OmiseGOTests/Helpers/StubGenerator.swift
Expand Up @@ -256,7 +256,6 @@ class StubGenerator {
amount: amount,
idempotencyToken: idempotencyToken,
correlationId: correlationId,
expirationDate: expirationDate,
metadata: metadata
)!
}
Expand Down
1 change: 0 additions & 1 deletion OmiseGOTests/LiveTests/TransactionRequestLiveTests.swift
Expand Up @@ -198,7 +198,6 @@ extension TransactionRequestLiveTests {
amount: nil,
idempotencyToken: idempotencyToken,
correlationId: consumeCorrelationId,
expirationDate: nil,
metadata: ["a_key": "a_value"])
var transactionConsumptionResult: TransactionConsumption?
let consumeRequest = TransactionConsumption.consumeTransactionRequest(
Expand Down
Expand Up @@ -20,7 +20,6 @@ class TransactionConsumptionParamsTest: XCTestCase {
amount: nil,
idempotencyToken: "123",
correlationId: nil,
expirationDate: Date(timeIntervalSince1970: 0),
metadata: [:]))
}

Expand All @@ -47,7 +46,6 @@ class TransactionConsumptionParamsTest: XCTestCase {
amount: nil,
idempotencyToken: "123",
correlationId: nil,
expirationDate: nil,
metadata: [:]))
}

Expand All @@ -74,7 +72,6 @@ class TransactionConsumptionParamsTest: XCTestCase {
amount: 3000,
idempotencyToken: "123",
correlationId: nil,
expirationDate: nil,
metadata: [:])!
XCTAssertEqual(params.amount, 3000)
}
Expand All @@ -87,7 +84,6 @@ class TransactionConsumptionParamsTest: XCTestCase {
amount: 3000,
idempotencyToken: "123",
correlationId: nil,
expirationDate: nil,
metadata: [:])!
XCTAssertEqual(params.amount, 3000)
}
Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -320,7 +320,6 @@ guard let params = TransactionConsumptionParams(transactionRequest: transactionR
mintedTokenId: "a minted token",
amount: 1337,
idempotencyToken: "an idempotency token",
expirationDate: nil,
correlationId: "a correlation id",
metadata: [:])!
TransactionConsumption.consumeTransactionRequest(using: client, params: params) { (transactionConsumptionResult) in
Expand All @@ -342,7 +341,6 @@ Where `params` is a `TransactionConsumptionParams` struct constructed using:
> Note that if the `amount` was not specified in the transaction request it needs to be specified here, otherwise the init will fail and return `nil`.

- `idempotencyToken`: The idempotency token used to ensure that the transaction will be executed one time only on the server. If the network call fails, you should reuse the same `idempotencyToken` when retrying the request.
- `expirationDate`: (optional) The date when the consumption will expire.
- `correlationId`: (optional) An id that can uniquely identify a transaction. Typically an order id from a provider.
- `metadata`: A dictionary of additional data to be stored for this transaction consumption.

Expand Down
5 changes: 0 additions & 5 deletions Source/Models/TransactionConsumptionParams.swift
Expand Up @@ -23,8 +23,6 @@ public struct TransactionConsumptionParams {
public let idempotencyToken: String
/// An id that can uniquely identify a transaction. Typically an order id from a provider.
public let correlationId: String?
/// The date when the consumption will expire
public let expirationDate: Date?
/// Additional metadata for the consumption
public let metadata: [String: Any]

Expand All @@ -40,15 +38,13 @@ public struct TransactionConsumptionParams {
/// - amount: The amount of minted token to transfer (down to subunit to unit)
/// - idempotencyToken: The idempotency token to use for the consumption
/// - correlationId: An id that can uniquely identify a transaction. Typically an order id from a provider.
/// - expirationDate: The date when the consumption will expire
/// - metadata: Additional metadata for the consumption
public init?(transactionRequest: TransactionRequest,
address: String?,
mintedTokenId: String?,
amount: Double?,
idempotencyToken: String,
correlationId: String?,
expirationDate: Date?,
metadata: [String: Any]) {
guard transactionRequest.amount != nil || amount != nil else { return nil }
self.transactionRequestId = transactionRequest.id
Expand All @@ -57,7 +53,6 @@ public struct TransactionConsumptionParams {
self.mintedTokenId = mintedTokenId
self.idempotencyToken = idempotencyToken
self.correlationId = correlationId
self.expirationDate = expirationDate
self.metadata = metadata
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Models/TransactionRequest.swift
Expand Up @@ -39,7 +39,7 @@ public struct TransactionRequest {
/// This amount needs to be either specified by the requester or the consumer
public let amount: Double?
/// The address from which to send or receive the minted tokens
public let address: String?
public let address: String
/// An id that can uniquely identify a transaction. Typically an order id from a provider.
public let correlationId: String?
/// The status of the request (valid or expired)
Expand Down Expand Up @@ -94,7 +94,7 @@ extension TransactionRequest: Decodable {
type = try container.decode(TransactionRequestType.self, forKey: .type)
mintedToken = try container.decode(MintedToken.self, forKey: .mintedToken)
amount = try container.decodeIfPresent(Double.self, forKey: .amount)
address = try container.decodeIfPresent(String.self, forKey: .address)
address = try container.decode(String.self, forKey: .address)
correlationId = try container.decodeIfPresent(String.self, forKey: .correlationId)
status = try container.decode(TransactionRequestStatus.self, forKey: .status)
socketTopic = try container.decode(String.self, forKey: .socketTopic)
Expand Down