• 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

50.85
/src/main/java/com/stripe/model/ShippingRate.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.net.StripeResponseGetter;
12
import com.stripe.param.ShippingRateCreateParams;
13
import com.stripe.param.ShippingRateListParams;
14
import com.stripe.param.ShippingRateRetrieveParams;
15
import com.stripe.param.ShippingRateUpdateParams;
16
import java.util.Map;
17
import lombok.EqualsAndHashCode;
18
import lombok.Getter;
19
import lombok.Setter;
20

21
/**
22
 * Shipping rates describe the price of shipping presented to your customers and applied to a
23
 * purchase. For more information, see <a
24
 * href="https://stripe.com/docs/payments/during-payment/charge-shipping">Charge for shipping</a>.
25
 */
26
@Getter
27
@Setter
28
@EqualsAndHashCode(callSuper = false)
29
public class ShippingRate extends ApiResource implements HasId, MetadataStore<ShippingRate> {
1✔
30
  /** Whether the shipping rate can be used for new purchases. Defaults to {@code true}. */
31
  @SerializedName("active")
32
  Boolean active;
33

34
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
35
  @SerializedName("created")
36
  Long created;
37

38
  /**
39
   * The estimated range for how long shipping will take, meant to be displayable to the customer.
40
   * This will appear on CheckoutSessions.
41
   */
42
  @SerializedName("delivery_estimate")
43
  DeliveryEstimate deliveryEstimate;
44

45
  /**
46
   * The name of the shipping rate, meant to be displayable to the customer. This will appear on
47
   * CheckoutSessions.
48
   */
49
  @SerializedName("display_name")
50
  String displayName;
51

52
  @SerializedName("fixed_amount")
53
  FixedAmount fixedAmount;
54

55
  /** Unique identifier for the object. */
56
  @Getter(onMethod_ = {@Override})
57
  @SerializedName("id")
58
  String id;
59

60
  /**
61
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
62
   * object exists in test mode.
63
   */
64
  @SerializedName("livemode")
65
  Boolean livemode;
66

67
  /**
68
   * Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
69
   * to an object. This can be useful for storing additional information about the object in a
70
   * structured format.
71
   */
72
  @Getter(onMethod_ = {@Override})
73
  @SerializedName("metadata")
74
  Map<String, String> metadata;
75

76
  /**
77
   * String representing the object's type. Objects of the same type share the same value.
78
   *
79
   * <p>Equal to {@code shipping_rate}.
80
   */
81
  @SerializedName("object")
82
  String object;
83

84
  /**
85
   * Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of
86
   * {@code inclusive}, {@code exclusive}, or {@code unspecified}.
87
   */
88
  @SerializedName("tax_behavior")
89
  String taxBehavior;
90

91
  /**
92
   * A <a href="https://stripe.com/docs/tax/tax-categories">tax code</a> ID. The Shipping tax code
93
   * is {@code txcd_92010001}.
94
   */
95
  @SerializedName("tax_code")
96
  @Getter(lombok.AccessLevel.NONE)
97
  @Setter(lombok.AccessLevel.NONE)
98
  ExpandableField<TaxCode> taxCode;
99

100
  /**
101
   * The type of calculation to use on the shipping rate.
102
   *
103
   * <p>Equal to {@code fixed_amount}.
104
   */
105
  @SerializedName("type")
106
  String type;
107

108
  /** Get ID of expandable {@code taxCode} object. */
109
  public String getTaxCode() {
110
    return (this.taxCode != null) ? this.taxCode.getId() : null;
×
111
  }
112

113
  public void setTaxCode(String id) {
114
    this.taxCode = ApiResource.setExpandableFieldId(id, this.taxCode);
×
115
  }
×
116

117
  /** Get expanded {@code taxCode}. */
118
  public TaxCode getTaxCodeObject() {
119
    return (this.taxCode != null) ? this.taxCode.getExpanded() : null;
×
120
  }
121

122
  public void setTaxCodeObject(TaxCode expandableObject) {
123
    this.taxCode = new ExpandableField<TaxCode>(expandableObject.getId(), expandableObject);
×
124
  }
×
125

126
  /** Creates a new shipping rate object. */
127
  public static ShippingRate create(Map<String, Object> params) throws StripeException {
128
    return create(params, (RequestOptions) null);
×
129
  }
130

131
  /** Creates a new shipping rate object. */
132
  public static ShippingRate create(Map<String, Object> params, RequestOptions options)
133
      throws StripeException {
134
    String path = "/v1/shipping_rates";
×
135
    ApiRequest request =
×
136
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
137
    return getGlobalResponseGetter().request(request, ShippingRate.class);
×
138
  }
139

140
  /** Creates a new shipping rate object. */
141
  public static ShippingRate create(ShippingRateCreateParams params) throws StripeException {
142
    return create(params, (RequestOptions) null);
1✔
143
  }
144

145
  /** Creates a new shipping rate object. */
146
  public static ShippingRate create(ShippingRateCreateParams params, RequestOptions options)
147
      throws StripeException {
148
    String path = "/v1/shipping_rates";
1✔
149
    ApiResource.checkNullTypedParams(path, params);
1✔
150
    ApiRequest request =
1✔
151
        new ApiRequest(
152
            BaseAddress.API,
153
            ApiResource.RequestMethod.POST,
154
            path,
155
            ApiRequestParams.paramsToMap(params),
1✔
156
            options);
157
    return getGlobalResponseGetter().request(request, ShippingRate.class);
1✔
158
  }
159

160
  /** Returns a list of your shipping rates. */
161
  public static ShippingRateCollection list(Map<String, Object> params) throws StripeException {
162
    return list(params, (RequestOptions) null);
×
163
  }
164

165
  /** Returns a list of your shipping rates. */
166
  public static ShippingRateCollection list(Map<String, Object> params, RequestOptions options)
167
      throws StripeException {
168
    String path = "/v1/shipping_rates";
×
169
    ApiRequest request =
×
170
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
UNCOV
171
    return getGlobalResponseGetter().request(request, ShippingRateCollection.class);
×
172
  }
173

174
  /** Returns a list of your shipping rates. */
175
  public static ShippingRateCollection list(ShippingRateListParams params) throws StripeException {
176
    return list(params, (RequestOptions) null);
1✔
177
  }
178

179
  /** Returns a list of your shipping rates. */
180
  public static ShippingRateCollection list(ShippingRateListParams params, RequestOptions options)
181
      throws StripeException {
182
    String path = "/v1/shipping_rates";
1✔
183
    ApiResource.checkNullTypedParams(path, params);
1✔
184
    ApiRequest request =
1✔
185
        new ApiRequest(
186
            BaseAddress.API,
187
            ApiResource.RequestMethod.GET,
188
            path,
189
            ApiRequestParams.paramsToMap(params),
1✔
190
            options);
191
    return getGlobalResponseGetter().request(request, ShippingRateCollection.class);
1✔
192
  }
193

194
  /** Returns the shipping rate object with the given ID. */
195
  public static ShippingRate retrieve(String shippingRateToken) throws StripeException {
196
    return retrieve(shippingRateToken, (Map<String, Object>) null, (RequestOptions) null);
1✔
197
  }
198

199
  /** Returns the shipping rate object with the given ID. */
200
  public static ShippingRate retrieve(String shippingRateToken, RequestOptions options)
201
      throws StripeException {
202
    return retrieve(shippingRateToken, (Map<String, Object>) null, options);
×
203
  }
204

205
  /** Returns the shipping rate object with the given ID. */
206
  public static ShippingRate retrieve(
207
      String shippingRateToken, Map<String, Object> params, RequestOptions options)
208
      throws StripeException {
209
    String path =
1✔
210
        String.format("/v1/shipping_rates/%s", ApiResource.urlEncodeId(shippingRateToken));
1✔
211
    ApiRequest request =
1✔
212
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
213
    return getGlobalResponseGetter().request(request, ShippingRate.class);
1✔
214
  }
215

216
  /** Returns the shipping rate object with the given ID. */
217
  public static ShippingRate retrieve(
218
      String shippingRateToken, ShippingRateRetrieveParams params, RequestOptions options)
219
      throws StripeException {
220
    String path =
×
221
        String.format("/v1/shipping_rates/%s", ApiResource.urlEncodeId(shippingRateToken));
×
222
    ApiResource.checkNullTypedParams(path, params);
×
223
    ApiRequest request =
×
224
        new ApiRequest(
225
            BaseAddress.API,
226
            ApiResource.RequestMethod.GET,
227
            path,
228
            ApiRequestParams.paramsToMap(params),
×
229
            options);
UNCOV
230
    return getGlobalResponseGetter().request(request, ShippingRate.class);
×
231
  }
232

233
  /** Updates an existing shipping rate object. */
234
  @Override
235
  public ShippingRate update(Map<String, Object> params) throws StripeException {
236
    return update(params, (RequestOptions) null);
×
237
  }
238

239
  /** Updates an existing shipping rate object. */
240
  @Override
241
  public ShippingRate update(Map<String, Object> params, RequestOptions options)
242
      throws StripeException {
243
    String path = String.format("/v1/shipping_rates/%s", ApiResource.urlEncodeId(this.getId()));
×
244
    ApiRequest request =
×
245
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
246
    return getResponseGetter().request(request, ShippingRate.class);
×
247
  }
248

249
  /** Updates an existing shipping rate object. */
250
  public ShippingRate update(ShippingRateUpdateParams params) throws StripeException {
251
    return update(params, (RequestOptions) null);
1✔
252
  }
253

254
  /** Updates an existing shipping rate object. */
255
  public ShippingRate update(ShippingRateUpdateParams params, RequestOptions options)
256
      throws StripeException {
257
    String path = String.format("/v1/shipping_rates/%s", ApiResource.urlEncodeId(this.getId()));
1✔
258
    ApiResource.checkNullTypedParams(path, params);
1✔
259
    ApiRequest request =
1✔
260
        new ApiRequest(
261
            BaseAddress.API,
262
            ApiResource.RequestMethod.POST,
263
            path,
264
            ApiRequestParams.paramsToMap(params),
1✔
265
            options);
266
    return getResponseGetter().request(request, ShippingRate.class);
1✔
267
  }
268

269
  @Getter
270
  @Setter
271
  @EqualsAndHashCode(callSuper = false)
272
  public static class DeliveryEstimate extends StripeObject {
×
273
    /**
274
     * The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite.
275
     */
276
    @SerializedName("maximum")
277
    Maximum maximum;
278

279
    /** The lower bound of the estimated range. If empty, represents no lower bound. */
280
    @SerializedName("minimum")
281
    Minimum minimum;
282

283
    @Getter
284
    @Setter
285
    @EqualsAndHashCode(callSuper = false)
286
    public static class Maximum extends StripeObject {
×
287
      /**
288
       * A unit of time.
289
       *
290
       * <p>One of {@code business_day}, {@code day}, {@code hour}, {@code month}, or {@code week}.
291
       */
292
      @SerializedName("unit")
293
      String unit;
294

295
      /** Must be greater than 0. */
296
      @SerializedName("value")
297
      Long value;
298
    }
299

300
    @Getter
301
    @Setter
302
    @EqualsAndHashCode(callSuper = false)
303
    public static class Minimum extends StripeObject {
×
304
      /**
305
       * A unit of time.
306
       *
307
       * <p>One of {@code business_day}, {@code day}, {@code hour}, {@code month}, or {@code week}.
308
       */
309
      @SerializedName("unit")
310
      String unit;
311

312
      /** Must be greater than 0. */
313
      @SerializedName("value")
314
      Long value;
315
    }
316
  }
317

318
  @Getter
319
  @Setter
320
  @EqualsAndHashCode(callSuper = false)
321
  public static class FixedAmount extends StripeObject {
1✔
322
    /** A non-negative integer in cents representing how much to charge. */
323
    @SerializedName("amount")
324
    Long amount;
325

326
    /**
327
     * Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency
328
     * code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported
329
     * currency</a>.
330
     */
331
    @SerializedName("currency")
332
    String currency;
333

334
    /**
335
     * Shipping rates defined in each available currency option. Each key must be a three-letter <a
336
     * href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a> and a <a
337
     * href="https://stripe.com/docs/currencies">supported currency</a>.
338
     */
339
    @SerializedName("currency_options")
340
    Map<String, ShippingRate.FixedAmount.CurrencyOption> currencyOptions;
341

342
    @Getter
343
    @Setter
344
    @EqualsAndHashCode(callSuper = false)
345
    public static class CurrencyOption extends StripeObject {
×
346
      /** A non-negative integer in cents representing how much to charge. */
347
      @SerializedName("amount")
348
      Long amount;
349

350
      /**
351
       * Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of
352
       * {@code inclusive}, {@code exclusive}, or {@code unspecified}.
353
       */
354
      @SerializedName("tax_behavior")
355
      String taxBehavior;
356
    }
357
  }
358

359
  @Override
360
  public void setResponseGetter(StripeResponseGetter responseGetter) {
361
    super.setResponseGetter(responseGetter);
1✔
362
    trySetResponseGetter(deliveryEstimate, responseGetter);
1✔
363
    trySetResponseGetter(fixedAmount, responseGetter);
1✔
364
    trySetResponseGetter(taxCode, responseGetter);
1✔
365
  }
1✔
366
}
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