• 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

0.0
/src/main/java/com/stripe/model/billing/Alert.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model.billing;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.model.Customer;
7
import com.stripe.model.ExpandableField;
8
import com.stripe.model.HasId;
9
import com.stripe.model.StripeObject;
10
import com.stripe.net.ApiRequest;
11
import com.stripe.net.ApiRequestParams;
12
import com.stripe.net.ApiResource;
13
import com.stripe.net.BaseAddress;
14
import com.stripe.net.RequestOptions;
15
import com.stripe.net.StripeResponseGetter;
16
import com.stripe.param.billing.AlertActivateParams;
17
import com.stripe.param.billing.AlertArchiveParams;
18
import com.stripe.param.billing.AlertCreateParams;
19
import com.stripe.param.billing.AlertDeactivateParams;
20
import com.stripe.param.billing.AlertListParams;
21
import com.stripe.param.billing.AlertRetrieveParams;
22
import java.util.List;
23
import java.util.Map;
24
import lombok.EqualsAndHashCode;
25
import lombok.Getter;
26
import lombok.Setter;
27

28
/**
29
 * A billing alert is a resource that notifies you when a certain usage threshold on a meter is
30
 * crossed. For example, you might create a billing alert to notify you when a certain user made 100
31
 * API requests.
32
 */
33
@Getter
34
@Setter
35
@EqualsAndHashCode(callSuper = false)
36
public class Alert extends ApiResource implements HasId {
×
37
  /**
38
   * Defines the type of the alert.
39
   *
40
   * <p>Equal to {@code usage_threshold}.
41
   */
42
  @SerializedName("alert_type")
43
  String alertType;
44

45
  /** Unique identifier for the object. */
46
  @Getter(onMethod_ = {@Override})
47
  @SerializedName("id")
48
  String id;
49

50
  /**
51
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
52
   * object exists in test mode.
53
   */
54
  @SerializedName("livemode")
55
  Boolean livemode;
56

57
  /**
58
   * String representing the object's type. Objects of the same type share the same value.
59
   *
60
   * <p>Equal to {@code billing.alert}.
61
   */
62
  @SerializedName("object")
63
  String object;
64

65
  /**
66
   * Status of the alert. This can be active, inactive or archived.
67
   *
68
   * <p>One of {@code active}, {@code archived}, or {@code inactive}.
69
   */
70
  @SerializedName("status")
71
  String status;
72

73
  /** Title of the alert. */
74
  @SerializedName("title")
75
  String title;
76

77
  /**
78
   * Encapsulates configuration of the alert to monitor usage on a specific <a
79
   * href="https://stripe.com/docs/api/billing/meter">Billing Meter</a>.
80
   */
81
  @SerializedName("usage_threshold")
82
  UsageThreshold usageThreshold;
83

84
  /** Reactivates this alert, allowing it to trigger again. */
85
  public Alert activate() throws StripeException {
86
    return activate((Map<String, Object>) null, (RequestOptions) null);
×
87
  }
88

89
  /** Reactivates this alert, allowing it to trigger again. */
90
  public Alert activate(RequestOptions options) throws StripeException {
91
    return activate((Map<String, Object>) null, options);
×
92
  }
93

94
  /** Reactivates this alert, allowing it to trigger again. */
95
  public Alert activate(Map<String, Object> params) throws StripeException {
96
    return activate(params, (RequestOptions) null);
×
97
  }
98

99
  /** Reactivates this alert, allowing it to trigger again. */
100
  public Alert activate(Map<String, Object> params, RequestOptions options) throws StripeException {
101
    String path =
×
102
        String.format("/v1/billing/alerts/%s/activate", ApiResource.urlEncodeId(this.getId()));
×
103
    ApiRequest request =
×
104
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
105
    return getResponseGetter().request(request, Alert.class);
×
106
  }
107

108
  /** Reactivates this alert, allowing it to trigger again. */
109
  public Alert activate(AlertActivateParams params) throws StripeException {
110
    return activate(params, (RequestOptions) null);
×
111
  }
112

113
  /** Reactivates this alert, allowing it to trigger again. */
114
  public Alert activate(AlertActivateParams params, RequestOptions options) throws StripeException {
115
    String path =
×
116
        String.format("/v1/billing/alerts/%s/activate", ApiResource.urlEncodeId(this.getId()));
×
117
    ApiResource.checkNullTypedParams(path, params);
×
118
    ApiRequest request =
×
119
        new ApiRequest(
120
            BaseAddress.API,
121
            ApiResource.RequestMethod.POST,
122
            path,
123
            ApiRequestParams.paramsToMap(params),
×
124
            options);
125
    return getResponseGetter().request(request, Alert.class);
×
126
  }
127

128
  /** Archives this alert, removing it from the list view and APIs. This is non-reversible. */
129
  public Alert archive() throws StripeException {
130
    return archive((Map<String, Object>) null, (RequestOptions) null);
×
131
  }
132

133
  /** Archives this alert, removing it from the list view and APIs. This is non-reversible. */
134
  public Alert archive(RequestOptions options) throws StripeException {
135
    return archive((Map<String, Object>) null, options);
×
136
  }
137

138
  /** Archives this alert, removing it from the list view and APIs. This is non-reversible. */
139
  public Alert archive(Map<String, Object> params) throws StripeException {
140
    return archive(params, (RequestOptions) null);
×
141
  }
142

143
  /** Archives this alert, removing it from the list view and APIs. This is non-reversible. */
144
  public Alert archive(Map<String, Object> params, RequestOptions options) throws StripeException {
145
    String path =
×
146
        String.format("/v1/billing/alerts/%s/archive", ApiResource.urlEncodeId(this.getId()));
×
147
    ApiRequest request =
×
148
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
149
    return getResponseGetter().request(request, Alert.class);
×
150
  }
151

152
  /** Archives this alert, removing it from the list view and APIs. This is non-reversible. */
153
  public Alert archive(AlertArchiveParams params) throws StripeException {
154
    return archive(params, (RequestOptions) null);
×
155
  }
156

157
  /** Archives this alert, removing it from the list view and APIs. This is non-reversible. */
158
  public Alert archive(AlertArchiveParams params, RequestOptions options) throws StripeException {
159
    String path =
×
160
        String.format("/v1/billing/alerts/%s/archive", ApiResource.urlEncodeId(this.getId()));
×
161
    ApiResource.checkNullTypedParams(path, params);
×
162
    ApiRequest request =
×
163
        new ApiRequest(
164
            BaseAddress.API,
165
            ApiResource.RequestMethod.POST,
166
            path,
167
            ApiRequestParams.paramsToMap(params),
×
168
            options);
169
    return getResponseGetter().request(request, Alert.class);
×
170
  }
171

172
  /** Creates a billing alert. */
173
  public static Alert create(Map<String, Object> params) throws StripeException {
174
    return create(params, (RequestOptions) null);
×
175
  }
176

177
  /** Creates a billing alert. */
178
  public static Alert create(Map<String, Object> params, RequestOptions options)
179
      throws StripeException {
180
    String path = "/v1/billing/alerts";
×
181
    ApiRequest request =
×
182
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
183
    return getGlobalResponseGetter().request(request, Alert.class);
×
184
  }
185

186
  /** Creates a billing alert. */
187
  public static Alert create(AlertCreateParams params) throws StripeException {
188
    return create(params, (RequestOptions) null);
×
189
  }
190

191
  /** Creates a billing alert. */
192
  public static Alert create(AlertCreateParams params, RequestOptions options)
193
      throws StripeException {
194
    String path = "/v1/billing/alerts";
×
195
    ApiResource.checkNullTypedParams(path, params);
×
196
    ApiRequest request =
×
197
        new ApiRequest(
198
            BaseAddress.API,
199
            ApiResource.RequestMethod.POST,
200
            path,
201
            ApiRequestParams.paramsToMap(params),
×
202
            options);
203
    return getGlobalResponseGetter().request(request, Alert.class);
×
204
  }
205

206
  /** Deactivates this alert, preventing it from triggering. */
207
  public Alert deactivate() throws StripeException {
208
    return deactivate((Map<String, Object>) null, (RequestOptions) null);
×
209
  }
210

211
  /** Deactivates this alert, preventing it from triggering. */
212
  public Alert deactivate(RequestOptions options) throws StripeException {
213
    return deactivate((Map<String, Object>) null, options);
×
214
  }
215

216
  /** Deactivates this alert, preventing it from triggering. */
217
  public Alert deactivate(Map<String, Object> params) throws StripeException {
218
    return deactivate(params, (RequestOptions) null);
×
219
  }
220

221
  /** Deactivates this alert, preventing it from triggering. */
222
  public Alert deactivate(Map<String, Object> params, RequestOptions options)
223
      throws StripeException {
224
    String path =
×
225
        String.format("/v1/billing/alerts/%s/deactivate", ApiResource.urlEncodeId(this.getId()));
×
226
    ApiRequest request =
×
227
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
228
    return getResponseGetter().request(request, Alert.class);
×
229
  }
230

231
  /** Deactivates this alert, preventing it from triggering. */
232
  public Alert deactivate(AlertDeactivateParams params) throws StripeException {
233
    return deactivate(params, (RequestOptions) null);
×
234
  }
235

236
  /** Deactivates this alert, preventing it from triggering. */
237
  public Alert deactivate(AlertDeactivateParams params, RequestOptions options)
238
      throws StripeException {
239
    String path =
×
240
        String.format("/v1/billing/alerts/%s/deactivate", ApiResource.urlEncodeId(this.getId()));
×
241
    ApiResource.checkNullTypedParams(path, params);
×
242
    ApiRequest request =
×
243
        new ApiRequest(
244
            BaseAddress.API,
245
            ApiResource.RequestMethod.POST,
246
            path,
247
            ApiRequestParams.paramsToMap(params),
×
248
            options);
249
    return getResponseGetter().request(request, Alert.class);
×
250
  }
251

252
  /** Lists billing active and inactive alerts. */
253
  public static AlertCollection list(Map<String, Object> params) throws StripeException {
254
    return list(params, (RequestOptions) null);
×
255
  }
256

257
  /** Lists billing active and inactive alerts. */
258
  public static AlertCollection list(Map<String, Object> params, RequestOptions options)
259
      throws StripeException {
260
    String path = "/v1/billing/alerts";
×
261
    ApiRequest request =
×
262
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
263
    return getGlobalResponseGetter().request(request, AlertCollection.class);
×
264
  }
265

266
  /** Lists billing active and inactive alerts. */
267
  public static AlertCollection list(AlertListParams params) throws StripeException {
268
    return list(params, (RequestOptions) null);
×
269
  }
270

271
  /** Lists billing active and inactive alerts. */
272
  public static AlertCollection list(AlertListParams params, RequestOptions options)
273
      throws StripeException {
274
    String path = "/v1/billing/alerts";
×
275
    ApiResource.checkNullTypedParams(path, params);
×
276
    ApiRequest request =
×
277
        new ApiRequest(
278
            BaseAddress.API,
279
            ApiResource.RequestMethod.GET,
280
            path,
281
            ApiRequestParams.paramsToMap(params),
×
282
            options);
283
    return getGlobalResponseGetter().request(request, AlertCollection.class);
×
284
  }
285

286
  /** Retrieves a billing alert given an ID. */
287
  public static Alert retrieve(String id) throws StripeException {
288
    return retrieve(id, (Map<String, Object>) null, (RequestOptions) null);
×
289
  }
290

291
  /** Retrieves a billing alert given an ID. */
292
  public static Alert retrieve(String id, RequestOptions options) throws StripeException {
293
    return retrieve(id, (Map<String, Object>) null, options);
×
294
  }
295

296
  /** Retrieves a billing alert given an ID. */
297
  public static Alert retrieve(String id, Map<String, Object> params, RequestOptions options)
298
      throws StripeException {
299
    String path = String.format("/v1/billing/alerts/%s", ApiResource.urlEncodeId(id));
×
300
    ApiRequest request =
×
301
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
302
    return getGlobalResponseGetter().request(request, Alert.class);
×
303
  }
304

305
  /** Retrieves a billing alert given an ID. */
306
  public static Alert retrieve(String id, AlertRetrieveParams params, RequestOptions options)
307
      throws StripeException {
308
    String path = String.format("/v1/billing/alerts/%s", ApiResource.urlEncodeId(id));
×
309
    ApiResource.checkNullTypedParams(path, params);
×
310
    ApiRequest request =
×
311
        new ApiRequest(
312
            BaseAddress.API,
313
            ApiResource.RequestMethod.GET,
314
            path,
315
            ApiRequestParams.paramsToMap(params),
×
316
            options);
317
    return getGlobalResponseGetter().request(request, Alert.class);
×
318
  }
319

320
  /**
321
   * The usage threshold alert configuration enables setting up alerts for when a certain usage
322
   * threshold on a specific meter is crossed.
323
   */
324
  @Getter
325
  @Setter
326
  @EqualsAndHashCode(callSuper = false)
NEW
327
  public static class UsageThreshold extends StripeObject {
×
328
    /**
329
     * The filters allow limiting the scope of this usage alert. You can only specify up to one
330
     * filter at this time.
331
     */
332
    @SerializedName("filters")
333
    List<Alert.UsageThreshold.Filter> filters;
334

335
    /** The value at which this alert will trigger. */
336
    @SerializedName("gte")
337
    Long gte;
338

339
    /**
340
     * The <a href="https://stripe.com/api/billing/meter">Billing Meter</a> ID whose usage is
341
     * monitored.
342
     */
343
    @SerializedName("meter")
344
    @Getter(lombok.AccessLevel.NONE)
345
    @Setter(lombok.AccessLevel.NONE)
346
    ExpandableField<Meter> meter;
347

348
    /**
349
     * Defines how the alert will behave.
350
     *
351
     * <p>Equal to {@code one_time}.
352
     */
353
    @SerializedName("recurrence")
354
    String recurrence;
355

356
    /** Get ID of expandable {@code meter} object. */
357
    public String getMeter() {
358
      return (this.meter != null) ? this.meter.getId() : null;
×
359
    }
360

361
    public void setMeter(String id) {
362
      this.meter = ApiResource.setExpandableFieldId(id, this.meter);
×
363
    }
×
364

365
    /** Get expanded {@code meter}. */
366
    public Meter getMeterObject() {
367
      return (this.meter != null) ? this.meter.getExpanded() : null;
×
368
    }
369

370
    public void setMeterObject(Meter expandableObject) {
371
      this.meter = new ExpandableField<Meter>(expandableObject.getId(), expandableObject);
×
372
    }
×
373

374
    @Getter
375
    @Setter
376
    @EqualsAndHashCode(callSuper = false)
NEW
377
    public static class Filter extends StripeObject {
×
378
      /** Limit the scope of the alert to this customer ID. */
379
      @SerializedName("customer")
380
      @Getter(lombok.AccessLevel.NONE)
381
      @Setter(lombok.AccessLevel.NONE)
382
      ExpandableField<Customer> customer;
383

384
      @SerializedName("type")
385
      String type;
386

387
      /** Get ID of expandable {@code customer} object. */
388
      public String getCustomer() {
NEW
389
        return (this.customer != null) ? this.customer.getId() : null;
×
390
      }
391

392
      public void setCustomer(String id) {
NEW
393
        this.customer = ApiResource.setExpandableFieldId(id, this.customer);
×
NEW
394
      }
×
395

396
      /** Get expanded {@code customer}. */
397
      public Customer getCustomerObject() {
NEW
398
        return (this.customer != null) ? this.customer.getExpanded() : null;
×
399
      }
400

401
      public void setCustomerObject(Customer expandableObject) {
NEW
402
        this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
×
NEW
403
      }
×
404
    }
405
  }
406

407
  @Override
408
  public void setResponseGetter(StripeResponseGetter responseGetter) {
409
    super.setResponseGetter(responseGetter);
×
NEW
410
    trySetResponseGetter(usageThreshold, responseGetter);
×
411
  }
×
412
}
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