• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Invoiced / invoiced-java / #255

02 Feb 2024 11:00PM CUT coverage: 81.958%. Remained the same
#255

push

github

jaredtking
Add publish action

695 of 848 relevant lines covered (81.96%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.68
/src/main/java/com/invoiced/entity/Refund.java
1
package com.invoiced.entity;
2

3
import com.fasterxml.jackson.annotation.JsonFilter;
4
import com.fasterxml.jackson.annotation.JsonIgnore;
5
import com.fasterxml.jackson.annotation.JsonInclude;
6
import com.fasterxml.jackson.annotation.JsonProperty;
7
import com.invoiced.exception.EntityException;
8
import com.invoiced.util.Util;
9

10
@JsonFilter("customFilter")
11
public final class Refund extends AbstractEntity<Refund> {
12

13
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
14
    @JsonProperty("id")
15
    public Long id;
16

17
    @JsonProperty(value = "object", access = JsonProperty.Access.WRITE_ONLY)
18
    public String object;
19

20
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
21
    @JsonProperty("charge")
22
    public Long charge;
23

24
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
25
    @JsonProperty("status")
26
    public String status;
27

28
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
29
    @JsonProperty("gateway")
30
    public String gateway;
31

32
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
33
    @JsonProperty("gateway_id")
34
    public String gatewayId;
35

36
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
37
    @JsonProperty("currency")
38
    public String currency;
39

40
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
41
    @JsonProperty("amount")
42
    public Double amount;
43

44
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
45
    @JsonProperty("failure_message")
46
    public String failureMessage;
47

48
    @JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
49
    public Long createdAt;
50

51
    @JsonProperty(value = "updated_at", access = JsonProperty.Access.WRITE_ONLY)
52
    public Long updatedAt;
53

54
    public Refund(Connection conn) {
55
        super(conn, Refund.class);
1✔
56
        this.entityName = "/refunds";
1✔
57
    }
1✔
58

59
    Refund() {
60
        super(Refund.class);
1✔
61
        this.entityName = "/refunds";
1✔
62
    }
1✔
63

64
    @Override
65
    @JsonIgnore
66
    protected String getEntityId() {
67
        return String.valueOf(this.id);
×
68
    }
69

70
    @Override
71
    @JsonIgnore
72
    protected String[] getCreateExclusions() {
73
        return new String[]{
×
74
                "id", "failure_reason", "created_at"
75
        };
76
    }
77

78
    @Override
79
    @JsonIgnore
80
    protected String[] getSaveExclusions() {
81
        return new String[]{
×
82
                "id",
83
                "created_at"
84
        };
85
    }
86

87
    @JsonIgnore
88
    public void create(long chargeId, double amount) throws EntityException {
89
        String url = "/charges/" + chargeId + "/refunds";
1✔
90

91
        RefundRequest refundRequest = new RefundRequest(amount);
1✔
92

93
        try {
94
            String refundRequestJson = refundRequest.toJsonString();
1✔
95

96
            String response = this.getConnection().post(url, null, refundRequestJson);
1✔
97

98
            Refund refund = Util.getMapper().readValue(response, Refund.class);
1✔
99
            setFields(refund, this);
1✔
100
        } catch (Throwable c) {
×
101
            throw new EntityException(c);
×
102
        }
1✔
103
    }
1✔
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc