@marvalt/wadapter 2.3.2 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -326,22 +326,32 @@ class GravityFormsClient {
326
326
  }
327
327
  }
328
328
  async getForm(id) {
329
- // proxy: use enhanced gf-api/v1; direct: use official GF REST v2 (under /wp-json)
330
- const endpoint = this.config.authMode === 'cloudflare_proxy'
331
- ? `/gf-api/v1/forms/${id}`
332
- : `/wp-json/gf/v2/forms/${id}`;
329
+ // If using custom endpoint (gf-api plugin), use it for both modes
330
+ // Otherwise: proxy uses gf-api/v1, direct uses official gf/v2
331
+ const useCustom = this.config.useCustomEndpoint;
332
+ const endpoint = useCustom
333
+ ? `/forms/${id}` // apiUrl already includes /wp-json/gf-api/v1
334
+ : (this.config.authMode === 'cloudflare_proxy'
335
+ ? `/gf-api/v1/forms/${id}`
336
+ : `/wp-json/gf/v2/forms/${id}`);
333
337
  return this.makeRequest(endpoint);
334
338
  }
335
339
  async getForms() {
336
- const endpoint = this.config.authMode === 'cloudflare_proxy'
337
- ? '/gf-api/v1/forms'
338
- : '/wp-json/gf/v2/forms';
340
+ const useCustom = this.config.useCustomEndpoint;
341
+ const endpoint = useCustom
342
+ ? '/forms' // apiUrl already includes /wp-json/gf-api/v1
343
+ : (this.config.authMode === 'cloudflare_proxy'
344
+ ? '/gf-api/v1/forms'
345
+ : '/wp-json/gf/v2/forms');
339
346
  return this.makeRequest(endpoint);
340
347
  }
341
348
  async getFormConfig(id) {
342
- const endpoint = this.config.authMode === 'cloudflare_proxy'
343
- ? `/gf-api/v1/forms/${id}/config`
344
- : `/wp-json/gf/v2/forms/${id}`; // v2 returns full form including settings
349
+ const useCustom = this.config.useCustomEndpoint;
350
+ const endpoint = useCustom
351
+ ? `/forms/${id}/config` // apiUrl already includes /wp-json/gf-api/v1
352
+ : (this.config.authMode === 'cloudflare_proxy'
353
+ ? `/gf-api/v1/forms/${id}/config`
354
+ : `/wp-json/gf/v2/forms/${id}`); // v2 returns full form including settings
345
355
  return this.makeRequest(endpoint);
346
356
  }
347
357
  async submitForm(formId, submission) {