Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
SD-1471 Geo API - Zones endpoint Platform API (#11468)
Aleksandar Petrushevab425a118068
diff --git a/api/app/controllers/spree/api/v2/platform/zones_controller.rb b/api/app/controllers/spree/api/v2/platform/zones_controller.rbnew file mode 100644index 0000000000..4cf8b87318--- /dev/null+++ b/api/app/controllers/spree/api/v2/platform/zones_controller.rb@@ -0,0 +1,19 @@+module Spree+ module Api+ module V2+ module Platform+ class ZonesController < ResourceController+ private++ def model_class+ Spree::Zone+ end++ def scope_includes+ [:zone_members]+ end+ end+ end+ end+ end+enddiff --git a/api/spec/integration/api/v2/platform/zones_spec.rb b/api/spec/integration/api/v2/platform/zones_spec.rbnew file mode 100644index 0000000000..0e346e229c--- /dev/null+++ b/api/spec/integration/api/v2/platform/zones_spec.rb@@ -0,0 +1,29 @@+require 'swagger_helper'++describe 'Zones API', swagger: true do+ include_context 'Platform API v2'++ resource_name = 'Zone'+ options = {+ include_example: 'zone_members',+ filter_examples: [{ name: 'filter[description_eq]', example: 'The zone containing all EU countries' }]+ }++ let(:id) { create(:zone).id }+ let(:records_list) { create_list(:zone, 2) }+ let(:valid_create_param_value) { build(:zone).attributes }+ let(:valid_update_param_value) do+ {+ name: 'EU',+ description: 'The zone containing all EU countries'+ }+ end+ let(:invalid_param_value) do+ {+ name: '',+ description: ''+ }+ end++ include_examples 'CRUD examples', resource_name, options+enddiff --git a/api/spec/swagger_helper.rb b/api/spec/swagger_helper.rbindex c62cf13bb0..b29b26af1d 100644--- a/api/spec/swagger_helper.rb+++ b/api/spec/swagger_helper.rb@@ -66,7 +66,8 @@ RSpec.configure do |config|{ name: 'Webhook Subscribers' },{ name: 'Wishlists' },{ name: 'Wished Items' },- { name: 'Variants' }+ { name: 'Variants' },+ { name: 'Zones' }],components: {securitySchemes: {@@ -1487,6 +1488,41 @@ RSpec.configure do |config|'x-internal': true},+ # Zones+ create_zone_params: {+ type: :object,+ properties: {+ zone: {+ type: :object,+ required: %w[name],+ properties: {+ name: { type: :string, example: 'EU' },+ description: { type: :string, example: 'All countries in the EU' },+ default_tax: { type: :boolean },+ kind: { type: :string, example: 'state', enum: %w[state country] }+ }+ }+ },+ required: %w[zone],+ 'x-internal': true+ },+ update_zone_params: {+ type: :object,+ properties: {+ address: {+ type: :object,+ properties: {+ name: { type: :string, example: 'EU' },+ description: { type: :string, example: 'All countries in the EU' },+ default_tax: { type: :boolean },+ kind: { type: :string, example: 'state', enum: %w[state country] }+ }+ }+ },+ required: %w[zone],+ 'x-internal': true+ },+# Nested Parametersamount_param: {type: :object,