Smile-SA / magento2-module-store-locator

Magento 2 store locator module
50 stars 57 forks source link

Feature: Create repository API endpoints (webapi.xml) #138

Open FredericMartinez opened 2 years ago

FredericMartinez commented 2 years ago

To be managed by a external ETL, API are very useful by adding simple CRUD inside webapi.xml

I just wrote a example of webapi.xml

<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
    <route method="GET" url="/V1/storelocator/:entityId">
        <service class="Smile\StoreLocator\Api\StoreLocatorRepositoryInterface" method="get"/>
        <resources>
            <resource ref="anonymous"/>
        </resources>
    </route>
    <route method="GET" url="/V1/storelocator/search">
        <service class="Smile\StoreLocator\Api\StoreLocatorRepositoryInterface" method="getList"/>
        <resources>
            <resource ref="anonymous"/>
        </resources>
    </route>
    <route method="POST" url="/V1/storelocator">
        <service class="Smile\StoreLocator\Api\StoreLocatorRepositoryInterface" method="save"/>
        <resources>
            <resource ref="Smile_StoreLocator::StoreLocator_save"/>
        </resources>
    </route>
    <route method="PUT" url="/V1/storelocator/:entityId">
        <service class="Smile\StoreLocator\Api\StoreLocatorRepositoryInterface" method="save"/>
        <resources>
            <resource ref="Smile_StoreLocator::StoreLocator_update"/>
        </resources>
    </route>
    <route method="DELETE" url="/V1/storelocator/:entityId">
        <service class="Smile\StoreLocator\Api\StoreLocatorRepositoryInterface" method="deleteById"/>
        <resources>
            <resource ref="Smile_StoreLocator::StoreLocator_delete"/>
        </resources>
    </route>
</routes>