-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...s/yahoo_auction_crawl_settings/yahoo_auction_crawl_setting_exclude_keywords_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters