• 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

75.0
/src/main/java/com/invoiced/entity/AbstractDocument.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 abstract class AbstractDocument<T extends AbstractDocument<T>> extends AbstractEntity<T> {
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("customer")
22
    public Long customer;
23

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

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

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

36
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
37
    @JsonProperty("draft")
38
    public Boolean draft;
39

40
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
41
    @JsonProperty("closed")
42
    public Boolean closed;
43

44
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
45
    @JsonProperty("voided")
46
    public Boolean voided;
47

48
    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
49
    public String status;
50

51
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
52
    @JsonProperty("date")
53
    public Long date;
54

55
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
56
    @JsonProperty("purchase_order")
57
    public String purchaseOrder;
58

59
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
60
    @JsonProperty("items")
61
    public LineItem[] items;
62

63
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
64
    @JsonProperty("notes")
65
    public String notes;
66

67
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
68
    @JsonProperty("subtotal")
69
    public Double subtotal;
70

71
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
72
    @JsonProperty("discounts")
73
    public Discount[] discounts;
74

75
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
76
    @JsonProperty("taxes")
77
    public Tax[] taxes;
78

79
    @JsonProperty(value = "total", access = JsonProperty.Access.WRITE_ONLY)
80
    public Double total;
81

82
    @JsonProperty(value = "url", access = JsonProperty.Access.WRITE_ONLY)
83
    public String url;
84

85
    @JsonProperty(value = "pdf_url", access = JsonProperty.Access.WRITE_ONLY)
86
    public String pdfUrl;
87

88
    @JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
89
    public Long createdAt;
90

91
    @JsonProperty(value = "updated_at", access = JsonProperty.Access.WRITE_ONLY)
92
    public Long updatedAt;
93

94
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
95
    @JsonProperty("metadata")
96
    public Object metadata;
97

98
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
99
    @JsonProperty("attachments")
100
    public Long[] attachments;
101

102
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
103
    @JsonProperty("calculate_taxes")
104
    public Boolean calculateTaxes;
105

106
    public AbstractDocument(Connection conn, Class aClass) {
107
        super(conn, aClass);
1✔
108
    }
1✔
109

110
    public AbstractDocument(Class aClass) {
111
        super(aClass);
1✔
112
    }
1✔
113

114
    @Override
115
    @JsonIgnore
116
    protected String getEntityId() {
117
        return String.valueOf(this.id);
1✔
118
    }
119

120
    @JsonIgnore
121
    public Email[] send(EmailRequest emailRequest) throws EntityException {
122
        String url = this.getEndpoint(true) + "/emails";
1✔
123

124
        try {
125
            String emailRequestJson = emailRequest.toJsonString();
1✔
126

127
            String response = this.getConnection().post(url, null, emailRequestJson);
1✔
128

129
            return Util.getMapper().readValue(response, Email[].class);
1✔
130
        } catch (Throwable c) {
×
131
            throw new EntityException(c);
×
132
        }
133
    }
134

135
    @JsonIgnore
136
    public Attachment[] listAttachments() throws EntityException {
137
        String url = this.getEndpoint(true) + "/attachments";
1✔
138

139
        try {
140
            String response = this.getConnection().post(url, null, "");
1✔
141

142
            return Util.getMapper().readValue(response, Attachment[].class);
1✔
143
        } catch (Throwable c) {
×
144
            throw new EntityException(c);
×
145
        }
146
    }
147

148
    @JsonIgnore
149
    public void voidDocument() throws EntityException {
150
        String url = this.getEndpoint(true) + "/void";
1✔
151

152
        try {
153
            String response = this.getConnection().post(url, null, "{}");
1✔
154

155
            Object document = Util.getMapper().readValue(response, tClass);
1✔
156
            setFields(document, this);
1✔
157
        } catch (Throwable c) {
×
158
            throw new EntityException(c);
×
159
        }
1✔
160
    }
1✔
161
}
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