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

stripe / stripe-java / #16493

03 Oct 2024 07:15PM UTC coverage: 12.942% (+0.08%) from 12.864%
#16493

push

github

web-flow
Merge Stripe-java v27.0.0 to beta branch (#1888)

409 of 1651 new or added lines in 88 files covered. (24.77%)

31 existing lines in 7 files now uncovered.

18773 of 145050 relevant lines covered (12.94%)

0.13 hits per line

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

80.0
/src/main/java/com/stripe/model/v2/Event.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model.v2;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.model.HasId;
7
import com.stripe.model.StripeActiveObject;
8
import com.stripe.model.StripeObject;
9
import com.stripe.model.StripeRawJsonObject;
10
import com.stripe.net.ApiRequest;
11
import com.stripe.net.ApiResource;
12
import com.stripe.net.BaseAddress;
13
import com.stripe.net.RequestOptions;
14
import com.stripe.net.StripeResponseGetter;
15
import java.time.Instant;
16
import lombok.EqualsAndHashCode;
17
import lombok.Getter;
18
import lombok.Setter;
19

20
@Getter
21
@Setter
22
@EqualsAndHashCode(callSuper = false)
23
public class Event extends StripeObject implements HasId, StripeActiveObject {
1✔
24
  /** Authentication context needed to fetch the event or related object. */
25
  @SerializedName("context")
26
  String context;
27

28
  /** Time at which the object was created. */
29
  @SerializedName("created")
30
  Instant created;
31

32
  /** Unique identifier for the event. */
33
  @Getter(onMethod_ = {@Override})
34
  @SerializedName("id")
35
  String id;
36

37
  /**
38
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
39
   * object exists in test mode.
40
   */
41
  @SerializedName("livemode")
42
  Boolean livemode;
43

44
  /**
45
   * String representing the object's type. Objects of the same type share the same value of the
46
   * object field.
47
   *
48
   * <p>Equal to {@code v2.core.event}.
49
   */
50
  @SerializedName("object")
51
  String object;
52

53
  /** Reason for the event. */
54
  @SerializedName("reason")
55
  Reason reason;
56

57
  /** The type of the event. */
58
  @SerializedName("type")
59
  String type;
60

61
  StripeResponseGetter responseGetter;
62

63
  @Override
64
  public void setResponseGetter(StripeResponseGetter responseGetter) {
65
    this.responseGetter = responseGetter;
1✔
66
  }
1✔
67

68
  /** Retrieves the object associated with the event. */
69
  protected StripeObject fetchRelatedObject(RelatedObject relatedObject) throws StripeException {
70
    if (relatedObject == null) {
1✔
NEW
71
      return null;
×
72
    }
73
    if (relatedObject.getUrl() == null) {
1✔
NEW
74
      return null;
×
75
    }
76

77
    Class<? extends StripeObject> objectClass =
1✔
78
        EventDataClassLookup.classLookup.get(relatedObject.getType());
1✔
79
    if (objectClass == null) {
1✔
NEW
80
      objectClass = StripeRawJsonObject.class;
×
81
    }
82

83
    RequestOptions opts = null;
1✔
84

85
    if (context != null) {
1✔
NEW
86
      opts = new RequestOptions.RequestOptionsBuilder().setStripeAccount(context).build();
×
87
    }
88

89
    return this.responseGetter.request(
1✔
90
        new ApiRequest(
91
            BaseAddress.API, ApiResource.RequestMethod.GET, relatedObject.getUrl(), null, opts),
1✔
92
        objectClass);
93
  }
94

95
  /**
96
   * Returns an StripeEvent instance using the provided JSON payload. Throws a JsonSyntaxException
97
   * if the payload is not valid JSON.
98
   *
99
   * @param payload the payload sent by Stripe.
100
   * @return the StripeEvent instance
101
   */
102
  public static Event parse(String payload) {
103
    return ApiResource.GSON.fromJson(payload, Event.class);
1✔
104
  }
105

106
  @Getter
107
  @Setter
108
  @EqualsAndHashCode(callSuper = false)
109
  public static class RelatedObject extends StripeObject implements HasId {
1✔
110
    /** Unique identifier for the object relevant to the event. */
111
    @Getter(onMethod_ = {@Override})
112
    @SerializedName("id")
113
    String id;
114

115
    /** Type of the object relevant to the event. */
116
    @SerializedName("type")
117
    String type;
118

119
    /** Type of the object relevant to the event. */
120
    @SerializedName("url")
121
    String url;
122
  }
123

124
  @Getter
125
  @Setter
126
  @EqualsAndHashCode(callSuper = false)
127
  public static class Reason extends StripeObject {
1✔
128
    /** Information on the API request that instigated the event. */
129
    @SerializedName("request")
130
    Request request;
131

132
    /**
133
     * Event reason type.
134
     *
135
     * <p>Equal to {@code request}.
136
     */
137
    @SerializedName("type")
138
    String type;
139

140
    @Getter
141
    @Setter
142
    @EqualsAndHashCode(callSuper = false)
143
    public static class Request extends StripeObject implements HasId {
1✔
144
      /** ID of the API request that caused the event. */
145
      @Getter(onMethod_ = {@Override})
146
      @SerializedName("id")
147
      String id;
148

149
      /** The idempotency key transmitted during the request. */
150
      @SerializedName("idempotency_key")
151
      String idempotencyKey;
152
    }
153
  }
154
}
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

© 2026 Coveralls, Inc