Skip to content

Commit

Permalink
expandUnits -> mailable (#331)
Browse files Browse the repository at this point in the history
* change to mailable

* keep expandUnits as optional param

* Update comment and add autocomplete calls

* bump to 3.8.19

* bump minor version

* Update MIGRATION.md

* Update MIGRATION.md
  • Loading branch information
york-wei authored Jan 10, 2024
1 parent 5c5df9c commit 5b9e813
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Migration guides

## 3.8.x to 3.9.0
- The `Radar.autocomplete(query, near, layers, limit, country, expandUnits, callback)` method is now `Radar.autocomplete(query, near, layers, limit, country, expandUnits, mailable, callback)`.
- `expandUnits` has been deprecated and will always be true regardless of value passed in.

## 3.6.x to 3.7.0
- Custom events have been renamed to conversions.
- `Radar.sendEvent(customType, metadata, callback)` is now `Radar.logConversion(name, metadata, callback)`.
Expand Down
22 changes: 22 additions & 0 deletions example/src/main/java/io/radar/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,28 @@ class MainActivity : AppCompatActivity() {
destination.latitude = 40.70390
destination.longitude = -73.98670

Radar.autocomplete(
"brooklyn",
origin,
arrayOf("locality"),
10,
"US",
true,
) { status, addresses ->
Log.v("example", "Autocomplete: status = $status; address = ${addresses?.get(0)?.formattedAddress}")
}

Radar.autocomplete(
"brooklyn",
origin,
arrayOf("locality"),
10,
"US",
mailable = true
) { status, addresses ->
Log.v("example", "Autocomplete: status = $status; address = ${addresses?.get(0)?.formattedAddress}")
}

Radar.autocomplete(
"brooklyn",
origin,
Expand Down
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.8.18'
radarVersion = '3.9.0'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
9 changes: 8 additions & 1 deletion sdk/src/main/java/io/radar/sdk/Radar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,8 @@ object Radar {
* @param[layers] Optional layer filters.
* @param[limit] The max number of addresses to return. A number between 1 and 100.
* @param[country] An optional country filter. A string, the unique 2-letter country code.
* @param[expandUnits] (Deprecated) This is always true, regardless of the value passed here.
* @param[mailable] Whether to only include mailable addresses.
* @param[callback] A callback.
*/
@JvmStatic
Expand All @@ -2288,6 +2290,7 @@ object Radar {
limit: Int? = null,
country: String? = null,
expandUnits: Boolean? = null,
mailable: Boolean? = null,
callback: RadarGeocodeCallback
) {
if (!initialized) {
Expand All @@ -2296,7 +2299,7 @@ object Radar {
return
}

apiClient.autocomplete(query, near, layers, limit, country, expandUnits, object : RadarApiClient.RadarGeocodeApiCallback {
apiClient.autocomplete(query, near, layers, limit, country, mailable, object : RadarApiClient.RadarGeocodeApiCallback {
override fun onComplete(status: RadarStatus, res: JSONObject?, addresses: Array<RadarAddress>?) {
handler.post {
callback.onComplete(status, addresses)
Expand All @@ -2315,6 +2318,8 @@ object Radar {
* @param[layers] Optional layer filters.
* @param[limit] The max number of addresses to return. A number between 1 and 100.
* @param[country] An optional country filter. A string, the unique 2-letter country code.
* @param[expandUnits] (Deprecated) This is always true, regardless of the value passed here.
* @param[mailable] Whether to only include mailable addresses
* @param[block] A block callback.
*/

Expand All @@ -2325,6 +2330,7 @@ object Radar {
limit: Int? = null,
country: String? = null,
expandUnits: Boolean? = null,
mailable: Boolean? = null,
block: (status: RadarStatus, addresses: Array<RadarAddress>?) -> Unit
) {
autocomplete(
Expand All @@ -2334,6 +2340,7 @@ object Radar {
limit,
country,
expandUnits,
mailable,
object : RadarGeocodeCallback {
override fun onComplete(status: RadarStatus, addresses: Array<RadarAddress>?) {
block(status, addresses)
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/main/java/io/radar/sdk/RadarApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ internal class RadarApiClient(
layers: Array<String>? = null,
limit: Int? = null,
country: String? = null,
expandUnits: Boolean? = null,
mailable: Boolean? = null,
callback: RadarGeocodeApiCallback
) {
val publishableKey = RadarSettings.getPublishableKey(context)
Expand All @@ -861,8 +861,8 @@ internal class RadarApiClient(
if (country != null) {
queryParams.append("&country=${country}")
}
if (expandUnits != null) {
queryParams.append("&expandUnits=${expandUnits}")
if (mailable != null) {
queryParams.append("&mailable=${mailable}")
}

val path = "v1/search/autocomplete?${queryParams}"
Expand Down

0 comments on commit 5b9e813

Please sign in to comment.