Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 294ab24

Browse files
authored
Merge pull request #3087 from wordpress-mobile/blaze/fix-date-formatting
[Blaze] Fix date formatting on the ad forecast endpoint
2 parents fdb14e9 + 188b375 commit 294ab24

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/blaze/BlazeCreationRestClient.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.wordpress.android.fluxc.network.rest.wpcom.blaze
22

3-
import android.annotation.SuppressLint
43
import com.google.gson.JsonObject
54
import com.google.gson.annotations.SerializedName
65
import org.wordpress.android.fluxc.Payload
@@ -30,6 +29,8 @@ import javax.inject.Inject
3029
class BlazeCreationRestClient @Inject constructor(
3130
private val wpComNetwork: WPComNetwork
3231
) {
32+
private val dateFormatter by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ROOT) }
33+
3334
suspend fun fetchTargetingLocations(
3435
site: SiteModel,
3536
query: String,
@@ -142,7 +143,6 @@ class BlazeCreationRestClient @Inject constructor(
142143
}
143144

144145
@Suppress("LongParameterList")
145-
@SuppressLint("SimpleDateFormat")
146146
suspend fun fetchAdForecast(
147147
site: SiteModel,
148148
startDate: Date,
@@ -152,7 +152,6 @@ class BlazeCreationRestClient @Inject constructor(
152152
targetingParameters: BlazeTargetingParameters?
153153
): BlazePayload<BlazeAdForecast> {
154154
val url = WPCOMV2.sites.site(site.siteId).wordads.dsp.api.v1_1.forecast.url
155-
val dateFormatter = SimpleDateFormat("yyyy-MM-dd")
156155

157156
val response = wpComNetwork.executePostGsonRequest(
158157
url = url,
@@ -197,7 +196,6 @@ class BlazeCreationRestClient @Inject constructor(
197196
site: SiteModel,
198197
request: BlazeCampaignCreationRequest
199198
): BlazePayload<BlazeCampaignModel> {
200-
val dateFormatter = SimpleDateFormat("yyyy-MM-dd", Locale.ROOT)
201199
val body = mutableMapOf(
202200
"origin" to request.origin,
203201
"origin_version" to request.originVersion,

0 commit comments

Comments
 (0)