-
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.
Merge pull request #2 from rubygitflow/ozon_market
Ozon market
- Loading branch information
Showing
98 changed files
with
4,131 additions
and
345 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,44 @@ | ||
# frozen_string_literal: true | ||
|
||
module Handles | ||
module OzonProductStatus | ||
# Product | ||
# enum :status, { | ||
# preliminary: 'preliminary', | ||
# on_moderation: 'on_moderation', | ||
# failed_moderation: 'failed_moderation', | ||
# published: 'published', | ||
# unpublished: 'unpublished', | ||
# archived: 'archived' | ||
# } | ||
|
||
# rubocop:disable Metrics/CyclomaticComplexity | ||
def take_ozon_card_status(item) | ||
visible = item[:visible] | ||
status = item[:status] || {} | ||
state_failed = status[:state_failed] || '' | ||
validation_state = status[:validation_state] || '' | ||
is_failed = status[:is_failed] || false | ||
|
||
case validation_state | ||
when 'success' | ||
visible ? 'published' : 'unpublished' | ||
when 'pending' | ||
case state_failed | ||
when 'imported' | ||
'failed_moderation' | ||
else | ||
case is_failed | ||
when true | ||
visible ? 'failed_moderation' : 'unpublished' | ||
else | ||
'on_moderation' | ||
end | ||
end | ||
else | ||
'unpublished' | ||
end | ||
end | ||
# rubocop:enable Metrics/CyclomaticComplexity | ||
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
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Handles | ||
module YandexProductStatus | ||
YANDEX_CARD_STATUS = { | ||
'PUBLISHED' => 'published', | ||
'CHECKING' => 'on_moderation', | ||
'DISABLED_BY_PARTNER' => 'unpublished', | ||
'DISABLED_AUTOMATICALLY' => 'unpublished', | ||
'REJECTED_BY_MARKET' => 'failed_moderation', | ||
'CREATING_CARD' => 'preliminary', | ||
'NO_CARD' => 'preliminary', | ||
'NO_STOCKS' => 'unpublished' | ||
}.freeze | ||
|
||
def take_yandex_card_status(offer) | ||
status = offer&.fetch(:campaigns, [])&.first&.fetch(:status, nil) | ||
YANDEX_CARD_STATUS.fetch(status, 'preliminary') | ||
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
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
18 changes: 18 additions & 0 deletions
18
app/jobs/marketplace_interaction/import_ozon_categories_job.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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module MarketplaceInteraction | ||
class ImportOzonCategoriesJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform | ||
mp_credential = MarketplaceCredential.ozon.valid.last | ||
back_time = Time.now | ||
Ozon::LoadCategories.new(mp_credential).call | ||
|
||
# TODO: To send a report on the successful update of the list of categories | ||
Rails.logger.info "download: :ozon_categories — OK (in #{(Time.now - back_time).round(3)} sec)" | ||
rescue StandardError => e | ||
ErrorLogger.push_trace e | ||
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
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
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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class OzonCategory < ApplicationRecord | ||
end |
Oops, something went wrong.