• 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

42.86
/src/main/java/com/stripe/model/ExchangeRate.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.ExchangeRateListParams;
12
import com.stripe.param.ExchangeRateRetrieveParams;
13
import java.math.BigDecimal;
14
import java.util.Map;
15
import lombok.EqualsAndHashCode;
16
import lombok.Getter;
17
import lombok.Setter;
18

19
/**
20
 * {@code ExchangeRate} objects allow you to determine the rates that Stripe is currently using to
21
 * convert from one currency to another. Since this number is variable throughout the day, there are
22
 * various reasons why you might want to know the current rate (for example, to dynamically price an
23
 * item for a user with a default payment in a foreign currency).
24
 *
25
 * <p>Please refer to our <a href="https://stripe.com/docs/fx-rates">Exchange Rates API</a> guide
26
 * for more details.
27
 *
28
 * <p><em>[Note: this integration path is supported but no longer recommended]</em> Additionally,
29
 * you can guarantee that a charge is made with an exchange rate that you expect is current. To do
30
 * so, you must pass in the exchange_rate to charges endpoints. If the value is no longer up to
31
 * date, the charge won't go through. Please refer to our <a
32
 * href="https://stripe.com/docs/exchange-rates">Using with charges</a> guide for more details.
33
 *
34
 * <p>-----
35
 *
36
 * <p>
37
 *
38
 * <p><em>This Exchange Rates API is a Beta Service and is subject to Stripe's terms of service. You
39
 * may use the API solely for the purpose of transacting on Stripe. For example, the API may be
40
 * queried in order to:</em>
41
 *
42
 * <p>- <em>localize prices for processing payments on Stripe</em> - <em>reconcile Stripe
43
 * transactions</em> - <em>determine how much money to send to a connected account</em> -
44
 * <em>determine app fees to charge a connected account</em>
45
 *
46
 * <p><em>Using this Exchange Rates API beta for any purpose other than to transact on Stripe is
47
 * strictly prohibited and constitutes a violation of Stripe's terms of service.</em>
48
 */
49
@Getter
50
@Setter
51
@EqualsAndHashCode(callSuper = false)
52
public class ExchangeRate extends ApiResource implements HasId {
1✔
53
  /**
54
   * Unique identifier for the object. Represented as the three-letter <a
55
   * href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a> in lowercase.
56
   */
57
  @Getter(onMethod_ = {@Override})
58
  @SerializedName("id")
59
  String id;
60

61
  /**
62
   * String representing the object's type. Objects of the same type share the same value.
63
   *
64
   * <p>Equal to {@code exchange_rate}.
65
   */
66
  @SerializedName("object")
67
  String object;
68

69
  /**
70
   * Hash where the keys are supported currencies and the values are the exchange rate at which the
71
   * base id currency converts to the key currency.
72
   */
73
  @SerializedName("rates")
74
  Map<String, BigDecimal> rates;
75

76
  /**
77
   * Returns a list of objects that contain the rates at which foreign currencies are converted to
78
   * one another. Only shows the currencies for which Stripe supports.
79
   */
80
  public static ExchangeRateCollection list(Map<String, Object> params) throws StripeException {
81
    return list(params, (RequestOptions) null);
1✔
82
  }
83

84
  /**
85
   * Returns a list of objects that contain the rates at which foreign currencies are converted to
86
   * one another. Only shows the currencies for which Stripe supports.
87
   */
88
  public static ExchangeRateCollection list(Map<String, Object> params, RequestOptions options)
89
      throws StripeException {
90
    String path = "/v1/exchange_rates";
1✔
91
    ApiRequest request =
1✔
92
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
93
    return getGlobalResponseGetter().request(request, ExchangeRateCollection.class);
1✔
94
  }
95

96
  /**
97
   * Returns a list of objects that contain the rates at which foreign currencies are converted to
98
   * one another. Only shows the currencies for which Stripe supports.
99
   */
100
  public static ExchangeRateCollection list(ExchangeRateListParams params) throws StripeException {
101
    return list(params, (RequestOptions) null);
×
102
  }
103

104
  /**
105
   * Returns a list of objects that contain the rates at which foreign currencies are converted to
106
   * one another. Only shows the currencies for which Stripe supports.
107
   */
108
  public static ExchangeRateCollection list(ExchangeRateListParams params, RequestOptions options)
109
      throws StripeException {
110
    String path = "/v1/exchange_rates";
×
111
    ApiResource.checkNullTypedParams(path, params);
×
112
    ApiRequest request =
×
113
        new ApiRequest(
114
            BaseAddress.API,
115
            ApiResource.RequestMethod.GET,
116
            path,
117
            ApiRequestParams.paramsToMap(params),
×
118
            options);
UNCOV
119
    return getGlobalResponseGetter().request(request, ExchangeRateCollection.class);
×
120
  }
121

122
  /** Retrieves the exchange rates from the given currency to every supported currency. */
123
  public static ExchangeRate retrieve(String rateId) throws StripeException {
124
    return retrieve(rateId, (Map<String, Object>) null, (RequestOptions) null);
1✔
125
  }
126

127
  /** Retrieves the exchange rates from the given currency to every supported currency. */
128
  public static ExchangeRate retrieve(String rateId, RequestOptions options)
129
      throws StripeException {
130
    return retrieve(rateId, (Map<String, Object>) null, options);
×
131
  }
132

133
  /** Retrieves the exchange rates from the given currency to every supported currency. */
134
  public static ExchangeRate retrieve(
135
      String rateId, Map<String, Object> params, RequestOptions options) throws StripeException {
136
    String path = String.format("/v1/exchange_rates/%s", ApiResource.urlEncodeId(rateId));
1✔
137
    ApiRequest request =
1✔
138
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
139
    return getGlobalResponseGetter().request(request, ExchangeRate.class);
1✔
140
  }
141

142
  /** Retrieves the exchange rates from the given currency to every supported currency. */
143
  public static ExchangeRate retrieve(
144
      String rateId, ExchangeRateRetrieveParams params, RequestOptions options)
145
      throws StripeException {
146
    String path = String.format("/v1/exchange_rates/%s", ApiResource.urlEncodeId(rateId));
×
147
    ApiResource.checkNullTypedParams(path, params);
×
148
    ApiRequest request =
×
149
        new ApiRequest(
150
            BaseAddress.API,
151
            ApiResource.RequestMethod.GET,
152
            path,
153
            ApiRequestParams.paramsToMap(params),
×
154
            options);
UNCOV
155
    return getGlobalResponseGetter().request(request, ExchangeRate.class);
×
156
  }
157
}
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