diff --git a/src/main/java/com/twilio/type/InboundCallPrice.java b/src/main/java/com/twilio/type/InboundCallPrice.java index 306b3cbb33..c4bd337435 100644 --- a/src/main/java/com/twilio/type/InboundCallPrice.java +++ b/src/main/java/com/twilio/type/InboundCallPrice.java @@ -6,6 +6,7 @@ import com.twilio.converter.Promoter; import lombok.ToString; +import java.math.BigDecimal; import java.util.Objects; /** @@ -41,8 +42,8 @@ public static Type forValue(final String value) { } } - private final double basePrice; - private final double currentPrice; + private final BigDecimal basePrice; + private final BigDecimal currentPrice; private final Type type; /** @@ -53,19 +54,57 @@ public static Type forValue(final String value) { * @param type type of phone number */ @JsonCreator - public InboundCallPrice(@JsonProperty("base_price") final double basePrice, - @JsonProperty("current_price") final double currentPrice, + public InboundCallPrice(@JsonProperty("base_price") final BigDecimal basePrice, + @JsonProperty("current_price") final BigDecimal currentPrice, @JsonProperty("number_type") final Type type) { this.basePrice = basePrice; this.currentPrice = currentPrice; this.type = type; } + /** + * Returns the retail price per minute to receive a call to this phone number type. The value returned by this + * method is represented as a {@code double}, which may result in loss of precision. + * + * @return the retail price per minute to receive a call to this phone number type + * + * @deprecated please use {{@link #getBasePriceDecimal()}} instead for a lossless representation of the price + */ + @Deprecated public double getBasePrice() { + return basePrice.doubleValue(); + } + + /** + * Returns the retail price per minute to receive a call to this phone number type. + * + * @return the retail price per minute to receive a call to this phone number type + */ + public BigDecimal getBasePriceDecimal() { return basePrice; } + /** + * Returns the current price per minute (which accounts for any volume or custom price discounts) to receive a call + * to this phone number type. The value returned by this method is represented as a {@code double}, which may result + * in loss of precision. + * + * @return the current price per minute to receive a call to this phone number type + * + * @deprecated please use {{@link #getCurrentPriceDecimal()} instead for a lossless representation of the price + */ + @Deprecated public double getCurrentPrice() { + return currentPrice.doubleValue(); + } + + /** + * Returns the current price per minute (which accounts for any volume or custom price discounts) to receive a call + * to this phone number type. + * + * @return the current price per minute to receive a call to this phone number type + */ + public BigDecimal getCurrentPriceDecimal() { return currentPrice; } diff --git a/src/main/java/com/twilio/type/InboundSmsPrice.java b/src/main/java/com/twilio/type/InboundSmsPrice.java index 326aa16010..e004058d6b 100644 --- a/src/main/java/com/twilio/type/InboundSmsPrice.java +++ b/src/main/java/com/twilio/type/InboundSmsPrice.java @@ -6,6 +6,7 @@ import com.twilio.converter.Promoter; import lombok.ToString; +import java.math.BigDecimal; import java.util.Objects; /** @@ -42,8 +43,8 @@ public static Type forValue(final String value) { } } - private final double basePrice; - private final double currentPrice; + private final BigDecimal basePrice; + private final BigDecimal currentPrice; private final Type type; /** @@ -54,19 +55,55 @@ public static Type forValue(final String value) { * @param type type of phone number */ @JsonCreator - public InboundSmsPrice(@JsonProperty("base_price") final double basePrice, - @JsonProperty("current_price") final double currentPrice, + public InboundSmsPrice(@JsonProperty("base_price") final BigDecimal basePrice, + @JsonProperty("current_price") final BigDecimal currentPrice, @JsonProperty("number_type") final Type type) { this.basePrice = basePrice; this.currentPrice = currentPrice; this.type = type; } + /** + * Returns the retail price to receive a message. The value returned by this method is represented as a + * {@code double}, which may result in loss of precision. + * + * @return the retail price to receive a message + * + * @deprecated please use {{@link #getBasePriceDecimal()}} instead for a lossless representation of the price + */ + @Deprecated public double getBasePrice() { + return basePrice.doubleValue(); + } + + /** + * Returns the retail price to receive a message. + * + * @return the retail price to receive a message + */ + public BigDecimal getBasePriceDecimal() { return basePrice; } + /** + * Returns the current price (which accounts for any volume or custom price discounts) to receive a message. The + * value returned by this method is represented as a {@code double}, which may result in loss of precision. + * + * @return the current price to receive a message + * + * @deprecated please use {{@link #getCurrentPriceDecimal()} instead for a lossless representation of the price + */ + @Deprecated public double getCurrentPrice() { + return currentPrice.doubleValue(); + } + + /** + * Returns the current price (which accounts for any volume or custom price discounts) to receive a message. + * + * @return the current price to receive a message + */ + public BigDecimal getCurrentPriceDecimal() { return currentPrice; } diff --git a/src/main/java/com/twilio/type/OutboundCallPrice.java b/src/main/java/com/twilio/type/OutboundCallPrice.java index e4db9a1410..a61686b3e1 100644 --- a/src/main/java/com/twilio/type/OutboundCallPrice.java +++ b/src/main/java/com/twilio/type/OutboundCallPrice.java @@ -5,26 +5,65 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.ToString; +import java.math.BigDecimal; import java.util.Objects; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class OutboundCallPrice { - private final double basePrice; - private final double currentPrice; + private final BigDecimal basePrice; + private final BigDecimal currentPrice; @JsonCreator - public OutboundCallPrice(@JsonProperty("base_price") final double basePrice, - @JsonProperty("current_price") final double currentPrice) { + public OutboundCallPrice(@JsonProperty("base_price") final BigDecimal basePrice, + @JsonProperty("current_price") final BigDecimal currentPrice) { this.basePrice = basePrice; this.currentPrice = currentPrice; } + /** + * Returns the retail price per minute to make a call from this phone number type. The value returned by this + * method is represented as a {@code double}, which may result in loss of precision. + * + * @return the retail price per minute to make a call from this phone number type + * + * @deprecated please use {{@link #getBasePriceDecimal()}} instead for a lossless representation of the price + */ + @Deprecated public double getBasePrice() { + return basePrice.doubleValue(); + } + + /** + * Returns the retail price per minute to make a call from this phone number type. + * + * @return the retail price per minute to make a call from this phone number type + */ + public BigDecimal getBasePriceDecimal() { return basePrice; } + /** + * Returns the current price per minute (which accounts for any volume or custom price discounts) to make a call + * from this phone number type. The value returned by this method is represented as a {@code double}, which may + * result in loss of precision. + * + * @return the current price per minute to make a call from this phone number type + * + * @deprecated please use {{@link #getCurrentPriceDecimal()} instead for a lossless representation of the price + */ + @Deprecated public double getCurrentPrice() { + return currentPrice.doubleValue(); + } + + /** + * Returns the current price per minute (which accounts for any volume or custom price discounts) to make a call + * from this phone number type. + * + * @return the current price per minute to make a call from this phone number type + */ + public BigDecimal getCurrentPriceDecimal() { return currentPrice; } diff --git a/src/main/java/com/twilio/type/OutboundPrefixPrice.java b/src/main/java/com/twilio/type/OutboundPrefixPrice.java index 0a42eaccb9..426c74ba37 100644 --- a/src/main/java/com/twilio/type/OutboundPrefixPrice.java +++ b/src/main/java/com/twilio/type/OutboundPrefixPrice.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.ToString; +import java.math.BigDecimal; import java.util.List; import java.util.Objects; @@ -22,8 +23,8 @@ public class OutboundPrefixPrice { private final List prefixes; private final String friendlyName; - private final double basePrice; - private final double currentPrice; + private final BigDecimal basePrice; + private final BigDecimal currentPrice; /** * Initialize an OutboundPrefixPrice. @@ -36,8 +37,8 @@ public class OutboundPrefixPrice { @JsonCreator public OutboundPrefixPrice(@JsonProperty("prefixes") final List prefixes, @JsonProperty("friendly_name") final String friendlyName, - @JsonProperty("base_price") final double basePrice, - @JsonProperty("current_price") final double currentPrice) { + @JsonProperty("base_price") final BigDecimal basePrice, + @JsonProperty("current_price") final BigDecimal currentPrice) { this.prefixes = prefixes; this.friendlyName = friendlyName; this.basePrice = basePrice; @@ -52,11 +53,49 @@ public String getFriendlyName() { return friendlyName; } + /** + * Returns the retail price per minute to make a call to numbers matching this prefix list. The value returned by + * this method is represented as a {@code double}, which may result in loss of precision. + * + * @return the retail price per minute to make a call to numbers matching this prefix list + * + * @deprecated please use {{@link #getBasePriceDecimal()}} instead for a lossless representation of the price + */ + @Deprecated public double getBasePrice() { + return basePrice.doubleValue(); + } + + /** + * Returns the retail price per minute to make a call to numbers matching this prefix list. + * + * @return the retail price per minute to make a call to numbers matching this prefix list + */ + public BigDecimal getBasePriceDecimal() { return basePrice; } + /** + * Returns the current price per minute (which accounts for any volume or custom price discounts) to make a call to + * numbers matching this prefix list. The value returned by this method is represented as a {@code double}, which + * may result in loss of precision. + * + * @return the current price per minute to make a call to numbers matching this prefix list + * + * @deprecated please use {{@link #getCurrentPriceDecimal()} instead for a lossless representation of the price + */ + @Deprecated public double getCurrentPrice() { + return currentPrice.doubleValue(); + } + + /** + * Returns the current price per minute (which accounts for any volume or custom price discounts) to make a call to + * numbers matching this prefix list. + * + * @return the current price per minute to make a call to numbers matching this prefix list + */ + public BigDecimal getCurrentPriceDecimal() { return currentPrice; } diff --git a/src/main/java/com/twilio/type/PhoneNumberPrice.java b/src/main/java/com/twilio/type/PhoneNumberPrice.java index 7f7f2b29df..61117a7726 100644 --- a/src/main/java/com/twilio/type/PhoneNumberPrice.java +++ b/src/main/java/com/twilio/type/PhoneNumberPrice.java @@ -6,6 +6,7 @@ import com.twilio.converter.Promoter; import lombok.ToString; +import java.math.BigDecimal; import java.util.Objects; /** @@ -56,8 +57,8 @@ public static Type forValue(final String value) { } } - private final double basePrice; - private final double currentPrice; + private final BigDecimal basePrice; + private final BigDecimal currentPrice; private final Type type; /** @@ -68,8 +69,8 @@ public static Type forValue(final String value) { * @param type type of phone number */ @JsonCreator - public PhoneNumberPrice(@JsonProperty("base_price") final double basePrice, - @JsonProperty("current_price") final double currentPrice, + public PhoneNumberPrice(@JsonProperty("base_price") final BigDecimal basePrice, + @JsonProperty("current_price") final BigDecimal currentPrice, @JsonProperty("number_type") final Type type) { this.basePrice = basePrice; this.currentPrice = currentPrice; @@ -77,20 +78,45 @@ public PhoneNumberPrice(@JsonProperty("base_price") final double basePrice, } /** - * Returns the base price of the phone number. + * Returns the base price of the phone number. The value returned by this method is represented as a {@code double}, + * which may result in loss of precision. * * @return the base price of the phone number + * + * @deprecated please use {{@link #getBasePriceDecimal()} instead for a lossless representation of the price */ + @Deprecated public double getBasePrice() { + return basePrice.doubleValue(); + } + + /** + * Returns the base price of the phone number. + * + * @return the base price of the phone number + */ + public BigDecimal getBasePriceDecimal() { return basePrice; } /** - * Returns the current price of the phone number. + * Returns the current price of the phone number. The value returned by this method is represented as a + * {@code double}, which may result in loss of precision. * * @return the current price of the phone number + * + * @deprecated please use {{@link #getCurrentPriceDecimal()} instead for a lossless representation of the price */ + @Deprecated public double getCurrentPrice() { + return currentPrice.doubleValue(); + } + + /** + * Returns the current price of the phone number. + * + * @return the current price of the phone number + */ public BigDecimal getCurrentPriceDecimal() { return currentPrice; } diff --git a/src/test/java/com/twilio/type/InboundCallPriceTest.java b/src/test/java/com/twilio/type/InboundCallPriceTest.java index 8a86d6a57d..8ac59aa928 100644 --- a/src/test/java/com/twilio/type/InboundCallPriceTest.java +++ b/src/test/java/com/twilio/type/InboundCallPriceTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.IOException; +import java.math.BigDecimal; /** * Test class for {@link InboundCallPrice}. @@ -21,6 +22,8 @@ public void testFromJson() throws IOException { InboundCallPrice icp = fromJson(json, InboundCallPrice.class); Assert.assertEquals(1.00, icp.getBasePrice(), 0.00); Assert.assertEquals(2.00, icp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), icp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), icp.getCurrentPriceDecimal()); Assert.assertEquals(InboundCallPrice.Type.MOBILE, icp.getType()); } @@ -35,6 +38,8 @@ public void testFromJsonTollFree() throws IOException { InboundCallPrice icp = fromJson(json, InboundCallPrice.class); Assert.assertEquals(1.00, icp.getBasePrice(), 0.00); Assert.assertEquals(2.00, icp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), icp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), icp.getCurrentPriceDecimal()); Assert.assertEquals(InboundCallPrice.Type.TOLLFREE, icp.getType()); } @@ -50,6 +55,8 @@ public void testFromJsonExtraField() throws IOException { InboundCallPrice icp = fromJson(json, InboundCallPrice.class); Assert.assertEquals(1.00, icp.getBasePrice(), 0.00); Assert.assertEquals(2.00, icp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), icp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), icp.getCurrentPriceDecimal()); Assert.assertEquals(InboundCallPrice.Type.TOLLFREE, icp.getType()); } } diff --git a/src/test/java/com/twilio/type/InboundSmsPriceTest.java b/src/test/java/com/twilio/type/InboundSmsPriceTest.java index b4f9da2aed..d76ae1e1cd 100644 --- a/src/test/java/com/twilio/type/InboundSmsPriceTest.java +++ b/src/test/java/com/twilio/type/InboundSmsPriceTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.IOException; +import java.math.BigDecimal; /** * Test class for {@link InboundSmsPrice}. @@ -21,6 +22,8 @@ public void testFromJson() throws IOException { InboundSmsPrice icp = fromJson(json, InboundSmsPrice.class); Assert.assertEquals(1.00, icp.getBasePrice(), 0.00); Assert.assertEquals(2.00, icp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), icp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), icp.getCurrentPriceDecimal()); Assert.assertEquals(InboundSmsPrice.Type.MOBILE, icp.getType()); } @@ -35,6 +38,8 @@ public void testFromJsonTollFree() throws IOException { InboundSmsPrice icp = fromJson(json, InboundSmsPrice.class); Assert.assertEquals(1.00, icp.getBasePrice(), 0.00); Assert.assertEquals(2.00, icp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), icp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), icp.getCurrentPriceDecimal()); Assert.assertEquals(InboundSmsPrice.Type.TOLLFREE, icp.getType()); } } diff --git a/src/test/java/com/twilio/type/OutboundCallPriceTest.java b/src/test/java/com/twilio/type/OutboundCallPriceTest.java index 387728adc0..66cb1659da 100644 --- a/src/test/java/com/twilio/type/OutboundCallPriceTest.java +++ b/src/test/java/com/twilio/type/OutboundCallPriceTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.IOException; +import java.math.BigDecimal; /** * Test class for {@link OutboundCallPrice}. @@ -20,5 +21,7 @@ public void testFromJson() throws IOException { OutboundCallPrice ocp = fromJson(json, OutboundCallPrice.class); Assert.assertEquals(1.00, ocp.getBasePrice(), 0.00); Assert.assertEquals(2.00, ocp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), ocp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), ocp.getCurrentPriceDecimal()); } } diff --git a/src/test/java/com/twilio/type/OutboundPrefixPriceTest.java b/src/test/java/com/twilio/type/OutboundPrefixPriceTest.java index c80ce156d9..933929e22a 100644 --- a/src/test/java/com/twilio/type/OutboundPrefixPriceTest.java +++ b/src/test/java/com/twilio/type/OutboundPrefixPriceTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.IOException; +import java.math.BigDecimal; import java.util.Arrays; /** @@ -28,5 +29,8 @@ public void testFromJson() throws IOException { Assert.assertEquals("name", opp.getFriendlyName()); Assert.assertEquals(1.00, opp.getBasePrice(), 0.00); Assert.assertEquals(2.00, opp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), opp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), opp.getCurrentPriceDecimal()); + } } diff --git a/src/test/java/com/twilio/type/OutboundSmsPriceTest.java b/src/test/java/com/twilio/type/OutboundSmsPriceTest.java index 63bfd16981..1721336e18 100644 --- a/src/test/java/com/twilio/type/OutboundSmsPriceTest.java +++ b/src/test/java/com/twilio/type/OutboundSmsPriceTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.IOException; +import java.math.BigDecimal; import java.util.Collections; /** @@ -29,7 +30,7 @@ public void testFromJson() throws IOException { Assert.assertEquals("mnc", osp.getMnc()); Assert.assertEquals("att", osp.getCarrier()); Assert.assertEquals(Collections.singletonList( - new InboundSmsPrice(1.00, 2.00, InboundSmsPrice.Type.LOCAL) + new InboundSmsPrice(new BigDecimal("1.00"), new BigDecimal("2.00"), InboundSmsPrice.Type.LOCAL) ), osp.getPrices()); } } diff --git a/src/test/java/com/twilio/type/PhoneNumberPriceTest.java b/src/test/java/com/twilio/type/PhoneNumberPriceTest.java index e8b34e62bd..3b66fc6c32 100644 --- a/src/test/java/com/twilio/type/PhoneNumberPriceTest.java +++ b/src/test/java/com/twilio/type/PhoneNumberPriceTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.IOException; +import java.math.BigDecimal; /** * Test class for {@link PhoneNumberPrice}. @@ -21,6 +22,8 @@ public void testFromJson() throws IOException { PhoneNumberPrice pnp = fromJson(json, PhoneNumberPrice.class); Assert.assertEquals(1.00, pnp.getBasePrice(), 0.00); Assert.assertEquals(2.00, pnp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), pnp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), pnp.getCurrentPriceDecimal()); Assert.assertEquals(PhoneNumberPrice.Type.MOBILE, pnp.getType()); } @@ -35,6 +38,8 @@ public void testFromJsonTollFreeType() throws IOException { PhoneNumberPrice pnp = fromJson(json, PhoneNumberPrice.class); Assert.assertEquals(1.00, pnp.getBasePrice(), 0.00); Assert.assertEquals(2.00, pnp.getCurrentPrice(), 0.00); + Assert.assertEquals(new BigDecimal("1.00"), pnp.getBasePriceDecimal()); + Assert.assertEquals(new BigDecimal("2.00"), pnp.getCurrentPriceDecimal()); Assert.assertEquals(PhoneNumberPrice.Type.TOLLFREE, pnp.getType()); }