Skip to content

Commit

Permalink
feat: add endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kuroweb committed Nov 9, 2024
1 parent e9881f3 commit c48fd79
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module Api
module V1
module Products
module YahooAuctionCrawlSettings
class YahooAuctionCrawlSettingExcludeKeywordsController < Api::ApplicationController
def create
exclude_keyword = product.yahoo_auction_crawl_setting
.yahoo_auction_crawl_setting_exclude_keywords
.create!(exclude_keyword_params)
inspect
render json: Api::YahooAuctionCrawlSettingExcludeKeywordSerializer.new(exclude_keyword).render_json,
status: :ok
end

def update
exclude_keyword.update!(exclude_keyword_params)
inspect
render json: Api::YahooAuctionCrawlSettingExcludeKeywordSerializer.new(exclude_keyword).render_json,
status: :ok
end

def destroy
if exclude_keyword.destroy
render json: {}, status: :ok
else
render json: { error: "Bad Request.", status: 400 }, status: :bad_request
end
end

private

def product
@product ||= Product.find(params[:product_id])
end

def exclude_keyword
@exclude_keyword ||= product.yahoo_auction_crawl_setting
.yahoo_auction_crawl_setting_exclude_keywords
.find(params[:id])
end

def exclude_keyword_params
params.permit(exclude_keyword_attributes)
end

def exclude_keyword_attributes
%i[keyword]
end

def inspect
::Products::Inspect::DeleteYahooAuctionProducts.call(product:)
::Products::Inspect::DeleteYahooFleamarketProducts.call(product:)
end
end
end
end
end
end
7 changes: 7 additions & 0 deletions volumes/backend/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
namespace :api do
namespace :v1 do
resources :products, only: %i[index show create update destroy]
namespace :products do
scope path: ":product_id" do
namespace :yahoo_auction_crawl_settings do
resources :yahoo_auction_crawl_setting_exclude_keywords, only: %i[create update destroy]
end
end
end
resources :categories, only: %i[index]
end
end
Expand Down

0 comments on commit c48fd79

Please sign in to comment.