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

stripe / stripe-java / #16380

30 Aug 2024 07:54PM UTC coverage: 12.882% (-0.004%) from 12.886%
#16380

push

github

web-flow
Merge from master after the changes to not pass api_mode from individual methods (#1857)

* Generate SDK for OpenAPI spec version 1230 (#1856)

* Bump version to 26.9.0

* No need for APIMode to be passed around from individual API methods (#1855)

* Generated code

* Update the code around raw request

* Update the v2 tests to use v2 path

16 of 23 new or added lines in 7 files covered. (69.57%)

706 existing lines in 213 files now uncovered.

18468 of 143365 relevant lines covered (12.88%)

0.13 hits per line

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

72.22
/src/main/java/com/stripe/model/EphemeralKey.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.net.ApiRequest;
7
import com.stripe.net.ApiRequestParams;
8
import com.stripe.net.ApiResource;
9
import com.stripe.net.BaseAddress;
10
import com.stripe.net.RequestOptions;
11
import com.stripe.param.EphemeralKeyCreateParams;
12
import com.stripe.param.EphemeralKeyDeleteParams;
13
import java.util.Map;
14
import lombok.EqualsAndHashCode;
15
import lombok.Getter;
16
import lombok.Setter;
17

18
@Getter
19
@Setter
20
@EqualsAndHashCode(callSuper = false)
21
public class EphemeralKey extends ApiResource implements HasId {
1✔
22
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
23
  @SerializedName("created")
24
  Long created;
25

26
  /** Time at which the key will expire. Measured in seconds since the Unix epoch. */
27
  @SerializedName("expires")
28
  Long expires;
29

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

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

42
  /**
43
   * String representing the object's type. Objects of the same type share the same value.
44
   *
45
   * <p>Equal to {@code ephemeral_key}.
46
   */
47
  @SerializedName("object")
48
  String object;
49

50
  /** The key's secret. You can use this value to make authorized requests to the Stripe API. */
51
  @SerializedName("secret")
52
  String secret;
53

54
  transient String rawJson;
55

56
  /** Creates a short-lived API key for a given resource. */
57
  public static EphemeralKey create(Map<String, Object> params) throws StripeException {
58
    return create(params, (RequestOptions) null);
1✔
59
  }
60

61
  /** Creates a short-lived API key for a given resource. */
62
  public static EphemeralKey create(Map<String, Object> params, RequestOptions options)
63
      throws StripeException {
64
    final String versionOverride;
65
    if (!params.containsKey("stripe-version")) {
1✔
66
      throw new IllegalArgumentException(
1✔
67
          "`stripe-version` must be explicitly specified in "
68
              + "`params` as the stripe version of your mobile client.");
69
    }
70
    try {
71
      versionOverride = (String) params.get("stripe-version");
1✔
72
    } catch (ClassCastException e) {
×
73
      throw new IllegalArgumentException(
×
74
          "`stripe-version` must be explicitly specified in " + "`params` as a string");
75
    }
1✔
76
    if (options == null) {
1✔
77
      options = RequestOptions.getDefault();
1✔
78
    }
79
    // Take "stripe-version" from params and plug it into RequestOptions
80
    // so it will be sent in the Stripe-Version header
81
    final RequestOptions overriddenOptions =
1✔
82
        com.stripe.net.RequestOptions.RequestOptionsBuilder.unsafeSetStripeVersionOverride(
1✔
83
                options.toBuilderFullCopy(), versionOverride)
1✔
84
            .build();
1✔
85

86
    // Remove "stripe-version" from params so that it is not sent in the
87
    // request body.
88
    final Map<String, Object> overriddenParams = new java.util.HashMap<String, Object>(params);
1✔
89
    overriddenParams.remove("stripe-version");
1✔
90
    ApiRequest request =
1✔
91
        new ApiRequest(
92
            BaseAddress.API,
93
            ApiResource.RequestMethod.POST,
94
            "/v1/ephemeral_keys",
95
            overriddenParams,
96
            overriddenOptions);
97
    return getGlobalResponseGetter().request(request, EphemeralKey.class);
1✔
98
  }
99

100
  /** Creates a short-lived API key for a given resource. */
101
  public static EphemeralKey create(EphemeralKeyCreateParams params) throws StripeException {
102
    return create(params, (RequestOptions) null);
1✔
103
  }
104

105
  /** Creates a short-lived API key for a given resource. */
106
  public static EphemeralKey create(EphemeralKeyCreateParams params, RequestOptions options)
107
      throws StripeException {
108
    checkNullTypedParams("/v1/ephemeral_keys", params);
1✔
109
    Map<String, Object> paramMap = params.toMap();
1✔
110
    if (!paramMap.containsKey("stripe-version")) {
1✔
111
      throw new IllegalArgumentException(
1✔
112
          "You must .setStripeVersion on EphemeralKeyCreateParams.builder() with"
113
              + " the stripe version of your mobile client.");
114
    }
115
    return create(paramMap, options);
1✔
116
  }
117

118
  /** Invalidates a short-lived API key for a given resource. */
119
  public EphemeralKey delete() throws StripeException {
120
    return delete((Map<String, Object>) null, (RequestOptions) null);
1✔
121
  }
122

123
  /** Invalidates a short-lived API key for a given resource. */
124
  public EphemeralKey delete(RequestOptions options) throws StripeException {
125
    return delete((Map<String, Object>) null, options);
×
126
  }
127

128
  /** Invalidates a short-lived API key for a given resource. */
129
  public EphemeralKey delete(Map<String, Object> params) throws StripeException {
130
    return delete(params, (RequestOptions) null);
×
131
  }
132

133
  /** Invalidates a short-lived API key for a given resource. */
134
  public EphemeralKey delete(Map<String, Object> params, RequestOptions options)
135
      throws StripeException {
136
    String path = String.format("/v1/ephemeral_keys/%s", ApiResource.urlEncodeId(this.getId()));
1✔
137
    ApiRequest request =
1✔
138
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.DELETE, path, params, options);
139
    return getResponseGetter().request(request, EphemeralKey.class);
1✔
140
  }
141

142
  /** Invalidates a short-lived API key for a given resource. */
143
  public EphemeralKey delete(EphemeralKeyDeleteParams params) throws StripeException {
144
    return delete(params, (RequestOptions) null);
×
145
  }
146

147
  /** Invalidates a short-lived API key for a given resource. */
148
  public EphemeralKey delete(EphemeralKeyDeleteParams params, RequestOptions options)
149
      throws StripeException {
150
    String path = String.format("/v1/ephemeral_keys/%s", ApiResource.urlEncodeId(this.getId()));
×
151
    ApiResource.checkNullTypedParams(path, params);
×
152
    ApiRequest request =
×
153
        new ApiRequest(
154
            BaseAddress.API,
155
            ApiResource.RequestMethod.DELETE,
156
            path,
157
            ApiRequestParams.paramsToMap(params),
×
158
            options);
UNCOV
159
    return getResponseGetter().request(request, EphemeralKey.class);
×
160
  }
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

© 2026 Coveralls, Inc