1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- /**
17- * External dependencies
18- */
19- import { addQueryArgs } from '@googleforcreators/url' ;
2016
2117/**
2218 * WordPress dependencies
@@ -66,10 +62,10 @@ export function fetchSettings(apiPath) {
6662 * Update settings.
6763 *
6864 * @param {string } apiPath API path.
69- * @param {Object } queryParams Query parameters to apply to URL .
65+ * @param {Object } settingsParams Settings to update .
7066 * @return {Promise } Request promise.
7167 */
72- export function updateSettings ( apiPath , queryParams ) {
68+ export function updateSettings ( apiPath , settingsParams ) {
7369 const {
7470 googleAnalyticsId,
7571 usingLegacyAnalytics,
@@ -88,82 +84,81 @@ export function updateSettings(apiPath, queryParams) {
8884 autoAdvance,
8985 defaultPageDuration,
9086 googleAnalyticsHandler,
91- } = queryParams ;
87+ } = settingsParams ;
9288
93- const query = { } ;
89+ const settings = { } ;
9490
9591 if ( googleAnalyticsId !== undefined ) {
96- query . web_stories_ga_tracking_id = googleAnalyticsId ;
92+ settings . web_stories_ga_tracking_id = googleAnalyticsId ;
9793 }
9894
9995 if ( usingLegacyAnalytics !== undefined ) {
100- query . web_stories_using_legacy_analytics = usingLegacyAnalytics ;
96+ settings . web_stories_using_legacy_analytics = usingLegacyAnalytics ;
10197 }
10298
10399 if ( adSensePublisherId !== undefined ) {
104- query . web_stories_adsense_publisher_id = adSensePublisherId ;
100+ settings . web_stories_adsense_publisher_id = adSensePublisherId ;
105101 }
106102
107103 if ( adSenseSlotId !== undefined ) {
108- query . web_stories_adsense_slot_id = adSenseSlotId ;
104+ settings . web_stories_adsense_slot_id = adSenseSlotId ;
109105 }
110106
111107 if ( adManagerSlotId !== undefined ) {
112- query . web_stories_ad_manager_slot_id = adManagerSlotId ;
108+ settings . web_stories_ad_manager_slot_id = adManagerSlotId ;
113109 }
114110
115111 if ( mgidWidgetId !== undefined ) {
116- query . web_stories_mgid_widget_id = mgidWidgetId ;
112+ settings . web_stories_mgid_widget_id = mgidWidgetId ;
117113 }
118114
119115 if ( adNetwork !== undefined ) {
120- query . web_stories_ad_network = adNetwork ;
116+ settings . web_stories_ad_network = adNetwork ;
121117 }
122118
123119 if ( videoCache !== undefined ) {
124- query . web_stories_video_cache = Boolean ( videoCache ) ;
120+ settings . web_stories_video_cache = Boolean ( videoCache ) ;
125121 }
126122
127123 if ( dataRemoval !== undefined ) {
128- query . web_stories_data_removal = Boolean ( dataRemoval ) ;
124+ settings . web_stories_data_removal = Boolean ( dataRemoval ) ;
129125 }
130126
131127 if ( archive !== undefined ) {
132- query . web_stories_archive = archive ;
128+ settings . web_stories_archive = archive ;
133129 }
134130
135131 if ( archivePageId !== undefined ) {
136- query . web_stories_archive_page_id = archivePageId ;
132+ settings . web_stories_archive_page_id = archivePageId ;
137133 }
138134
139135 if ( shoppingProvider !== undefined ) {
140- query . web_stories_shopping_provider = shoppingProvider ;
136+ settings . web_stories_shopping_provider = shoppingProvider ;
141137 }
142138
143139 if ( shopifyHost !== undefined ) {
144- query . web_stories_shopify_host = shopifyHost ;
140+ settings . web_stories_shopify_host = shopifyHost ;
145141 }
146142
147143 if ( shopifyAccessToken !== undefined ) {
148- query . web_stories_shopify_access_token = shopifyAccessToken ;
144+ settings . web_stories_shopify_access_token = shopifyAccessToken ;
149145 }
150146
151147 if ( autoAdvance !== undefined ) {
152- query . web_stories_auto_advance = Boolean ( autoAdvance ) ;
148+ settings . web_stories_auto_advance = Boolean ( autoAdvance ) ;
153149 }
154150
155151 if ( defaultPageDuration !== undefined ) {
156- query . web_stories_default_page_duration = defaultPageDuration ;
152+ settings . web_stories_default_page_duration = defaultPageDuration ;
157153 }
158154
159155 if ( googleAnalyticsHandler !== undefined ) {
160- query . web_stories_ga_tracking_handler = googleAnalyticsHandler ;
156+ settings . web_stories_ga_tracking_handler = googleAnalyticsHandler ;
161157 }
162158
163- const path = addQueryArgs ( apiPath , query ) ;
164-
165159 return apiFetch ( {
166- path,
160+ path : apiPath ,
167161 method : 'POST' ,
162+ data : settings ,
168163 } ) . then ( transformSettingResponse ) ;
169164}
0 commit comments