Skip to content

Commit

Permalink
Merge pull request #3649 from alphagov/pp-13332-return-exemption-object
Browse files Browse the repository at this point in the history
Add Exemption object to Ledger Specification
  • Loading branch information
marcotranchino authored Nov 22, 2024
2 parents 68b6e04 + c03945a commit f565c42
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 4 deletions.
10 changes: 7 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -121,14 +125,14 @@
"filename": "openapi/ledger_spec.yaml",
"hashed_secret": "9baeb3f7db14ddab5d172149762035c0c022d76d",
"is_verified": false,
"line_number": 1644
"line_number": 1652
},
{
"type": "Hex High Entropy String",
"filename": "openapi/ledger_spec.yaml",
"hashed_secret": "920734ed7628ef47739eed5571412e2c8271790f",
"is_verified": false,
"line_number": 1718
"line_number": 1728
}
],
"src/main/java/uk/gov/pay/ledger/event/model/Event.java": [
Expand Down Expand Up @@ -159,5 +163,5 @@
}
]
},
"generated_at": "2024-07-22T11:29:46Z"
"generated_at": "2024-11-21T09:40:02Z"
}
10 changes: 10 additions & 0 deletions openapi/ledger_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,14 @@ components:
wallet_type:
type: string
example: APPLE_PAY
Exemption:
type: object
properties:
requested:
type: boolean
description: It is set when the exemption has been requested or when we
know that it has not been requested.
example: true
ExternalTransactionState:
type: object
properties:
Expand Down Expand Up @@ -1655,6 +1663,8 @@ components:
evidence_due_date:
type: string
format: date-time
exemption:
$ref: '#/components/schemas/Exemption'
fee:
type: integer
format: int64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ public ZonedDateTime getCreatedDate() {
public PaymentInstrumentType getType() {
return type;
}
}
}
40 changes: 40 additions & 0 deletions src/main/java/uk/gov/pay/ledger/transaction/model/Exemption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package uk.gov.pay.ledger.transaction.model;

import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public class Exemption {

@Schema(
example = "true",
description = "It is set when the exemption has been requested or when we know that it has not been requested."
)
private boolean requested;

public Exemption(boolean requested) {
this.requested = requested;
}

@JsonProperty("requested")
public boolean getRequested() {
return requested;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Exemption)) return false;

Exemption exemption = (Exemption) o;

return requested == exemption.requested;
}

@Override
public int hashCode() {
return Objects.hash(requested);
}
}
12 changes: 12 additions & 0 deletions src/main/java/uk/gov/pay/ledger/transaction/model/Payment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Payment extends Transaction {
@JsonSerialize(using = ApiResponseDateTimeSerializer.class)
private ZonedDateTime createdDate;
private CardDetails cardDetails;
private Exemption exemption;
private Boolean delayedCapture;
private Map<String, Object> externalMetaData;
@JsonIgnore
Expand Down Expand Up @@ -75,6 +76,7 @@ public Payment(Builder builder) {
this.paymentProvider = builder.paymentProvider;
this.createdDate = builder.createdDate;
this.cardDetails = builder.cardDetails;
this.exemption = builder.exemption;
this.delayedCapture = builder.delayedCapture;
this.externalMetaData = builder.externalMetaData;
this.eventCount = builder.eventCount;
Expand Down Expand Up @@ -140,6 +142,10 @@ public CardDetails getCardDetails() {
return cardDetails;
}

public Exemption getExemption() {
return exemption;
}

public Boolean getDelayedCapture() {
return delayedCapture;
}
Expand Down Expand Up @@ -229,6 +235,7 @@ public static class Builder {
private String paymentProvider;
private ZonedDateTime createdDate;
private CardDetails cardDetails;
private Exemption exemption;
private Boolean delayedCapture;
private Map<String, Object> externalMetaData;
private Integer eventCount;
Expand Down Expand Up @@ -345,6 +352,11 @@ public Builder withCardDetails(CardDetails cardDetails) {
return this;
}

public Builder withExemption(Exemption exemption) {
this.exemption = exemption;
return this;
}

public Builder withDelayedCapture(Boolean delayedCapture) {
this.delayedCapture = delayedCapture;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import uk.gov.pay.ledger.transaction.model.AuthorisationSummary;
import uk.gov.pay.ledger.transaction.model.CardDetails;
import uk.gov.pay.ledger.transaction.model.Exemption;
import uk.gov.pay.ledger.transaction.model.Dispute;
import uk.gov.pay.ledger.transaction.model.Payment;
import uk.gov.pay.ledger.transaction.model.Refund;
Expand Down Expand Up @@ -66,6 +67,7 @@ public class TransactionView {
@Schema(example = "\"2016-01-21T17:15:00Z\"")
private ZonedDateTime createdDate;
private CardDetails cardDetails;
private Exemption exemption;
private Boolean delayedCapture;
@Schema(example = "fd21-1mdknkls1-2121-csdf")
private String gatewayTransactionId;
Expand Down Expand Up @@ -119,6 +121,7 @@ public TransactionView(Builder builder) {
this.paymentProvider = builder.paymentProvider;
this.createdDate = builder.createdDate;
this.cardDetails = builder.cardDetails;
this.exemption = builder.exemption;
this.delayedCapture = builder.delayedCapture;
this.gatewayTransactionId = builder.gatewayTransactionId;
this.refundSummary = builder.refundSummary;
Expand Down Expand Up @@ -167,6 +170,7 @@ public static TransactionView from(Transaction transaction, int statusVersion) {
.withPaymentProvider(payment.getPaymentProvider())
.withCreatedDate(payment.getCreatedDate())
.withCardDetails(payment.getCardDetails())
.withExemption(payment.getExemption())
.withDelayedCapture(payment.getDelayedCapture())
.withGatewayTransactionId(payment.getGatewayTransactionId())
.withRefundSummary(payment.getRefundSummary())
Expand Down Expand Up @@ -221,6 +225,7 @@ public static TransactionView from(Transaction transaction, int statusVersion) {
.withReference(payment.getReference())
.withEmail(payment.getEmail())
.withCardDetails(payment.getCardDetails())
.withExemption(payment.getExemption())
.withTransactionType(payment.getTransactionType());

disputeBuilder = disputeBuilder.withPaymentDetails(paymentBuilder.build());
Expand Down Expand Up @@ -320,6 +325,10 @@ public CardDetails getCardDetails() {
return cardDetails;
}

public Exemption getExemption() {
return exemption;
}

public Boolean getDelayedCapture() {
return delayedCapture;
}
Expand Down Expand Up @@ -448,6 +457,7 @@ public static class Builder {
private String paymentProvider;
private ZonedDateTime createdDate;
private CardDetails cardDetails;
private Exemption exemption;
private Boolean delayedCapture;
private String gatewayTransactionId;
private RefundSummary refundSummary;
Expand Down Expand Up @@ -569,6 +579,11 @@ public Builder withCardDetails(CardDetails cardDetails) {
return this;
}

public Builder withExemption(Exemption exemption) {
this.exemption = exemption;
return this;
}

public Builder withDelayedCapture(Boolean delayedCapture) {
this.delayedCapture = delayedCapture;
return this;
Expand Down

0 comments on commit f565c42

Please sign in to comment.