Class: AmazonAPlusContent
Overview
== Schema Information
Table name: amazon_a_plus_contents
Database name: primary
id :bigint not null, primary key
amazon_status :string
asin :string(10) not null
content_data :jsonb not null
content_reference_key :string
content_sub_type :string
content_type :string
last_status_check_at :datetime
locale :string not null
page_name :string
status :string default("draft")
created_at :datetime not null
updated_at :datetime not null
amazon_content_id :string
amazon_marketplace_id :bigint
catalog_item_id :bigint
marketplace_id :string not null
Indexes
index_amazon_a_plus_contents_on_amazon_marketplace_id (amazon_marketplace_id)
index_amazon_a_plus_contents_on_asin_marketplace_locale (asin,marketplace_id,locale) UNIQUE
index_amazon_a_plus_contents_on_catalog_item_id (catalog_item_id)
index_amazon_a_plus_contents_on_content_reference_key (content_reference_key)
index_amazon_a_plus_contents_on_content_type (content_type)
index_amazon_a_plus_contents_on_status (status)
Foreign Keys
fk_rails_... (amazon_marketplace_id => amazon_marketplaces.id)
fk_rails_... (catalog_item_id => catalog_items.id)
Constant Summary
collapse
- AMAZON_LOCALE_MAPPING =
Amazon locale to our locale mapping
{
'en_US' => 'en-US',
'en_CA' => 'en-CA',
'fr_CA' => 'fr-CA',
'en_GB' => 'en-GB',
'de_DE' => 'de-DE',
'fr_FR' => 'fr-FR',
'es_ES' => 'es-ES',
'it_IT' => 'it-IT',
'nl_NL' => 'nl-NL',
'pl_PL' => 'pl-PL',
'sv_SE' => 'sv-SE',
'ja_JP' => 'ja-JP',
'pt_BR' => 'pt-BR',
'ar_SA' => 'ar-SA',
'tr_TR' => 'tr-TR',
'hi_IN' => 'hi-IN',
'en_AU' => 'en-AU',
'en_AE' => 'en-AE'
}.freeze
Models::Auditable::ALWAYS_IGNORED
Instance Attribute Summary collapse
#creator, #updater
Class Method Summary
collapse
Instance Method Summary
collapse
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
#publish_event
Instance Attribute Details
#asin ⇒ Object
45
|
# File 'app/models/amazon_a_plus_content.rb', line 45
validates :asin, presence: true, length: { is: 10 }
|
#content_data ⇒ Object
48
|
# File 'app/models/amazon_a_plus_content.rb', line 48
validates :content_data, presence: true
|
#content_reference_key ⇒ Object
49
|
# File 'app/models/amazon_a_plus_content.rb', line 49
validates :content_reference_key, presence: true
|
#content_type ⇒ Object
50
|
# File 'app/models/amazon_a_plus_content.rb', line 50
validates :content_type, presence: true
|
#locale ⇒ Object
47
|
# File 'app/models/amazon_a_plus_content.rb', line 47
validates :locale, presence: true
|
#marketplace_id ⇒ Object
46
|
# File 'app/models/amazon_a_plus_content.rb', line 46
validates :marketplace_id, presence: true
|
Class Method Details
A relation of AmazonAPlusContents that are active. Active Record Scope
65
|
# File 'app/models/amazon_a_plus_content.rb', line 65
scope :active, -> { where(status: %w[submitted approved]) }
|
.amazon_to_our_locale(amazon_locale) ⇒ Object
89
90
91
|
# File 'app/models/amazon_a_plus_content.rb', line 89
def self.amazon_to_our_locale(amazon_locale)
AMAZON_LOCALE_MAPPING[amazon_locale] || amazon_locale
end
|
.available_locales_for_marketplace(marketplace_id) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'app/models/amazon_a_plus_content.rb', line 97
def self.available_locales_for_marketplace(marketplace_id)
case marketplace_id
when 'ATVPDKIKX0DER' %w[en_US]
when 'A2EUQ1WTGCTBG2' %w[en_CA fr_CA]
when 'A1F83G8C2ARO7P' %w[en_GB]
when 'A1PA6795UKMFR9' %w[de_DE]
when 'A13V1IB3VIYZZH' %w[fr_FR]
when 'A1RKKUPIHCS9HS' %w[es_ES]
when 'APJ6JRA9NG5V4' %w[it_IT]
when 'A1805IZSGTT6HS' %w[nl_NL]
when 'A1C3SOZRARQ6R3' %w[pl_PL]
when 'A2NODRKZPJ5A4Y' %w[sv_SE]
when 'A1VC38T7YXB528' %w[ja_JP]
when 'A2Q3Y263D00KWC' %w[pt_BR]
when 'AMEN7PMS3EDWL' %w[fr_FR nl_NL]
else
%w[en_US]
end
end
|
A relation of AmazonAPlusContents that are for asin. Active Record Scope
63
|
# File 'app/models/amazon_a_plus_content.rb', line 63
scope :for_asin, ->(asin) { where(asin: asin) }
|
.for_locale ⇒ ActiveRecord::Relation<AmazonAPlusContent>
A relation of AmazonAPlusContents that are for locale. Active Record Scope
64
|
# File 'app/models/amazon_a_plus_content.rb', line 64
scope :for_locale, ->(locale) { where(locale: locale) }
|
.for_marketplace ⇒ ActiveRecord::Relation<AmazonAPlusContent>
A relation of AmazonAPlusContents that are for marketplace. Active Record Scope
62
|
# File 'app/models/amazon_a_plus_content.rb', line 62
scope :for_marketplace, ->(marketplace_id) { where(marketplace_id: marketplace_id) }
|
.our_to_amazon_locale(our_locale) ⇒ Object
93
94
95
|
# File 'app/models/amazon_a_plus_content.rb', line 93
def self.our_to_amazon_locale(our_locale)
AMAZON_LOCALE_MAPPING.key(our_locale) || our_locale
end
|
Instance Method Details
#amazon_locale ⇒ Object
146
147
148
|
# File 'app/models/amazon_a_plus_content.rb', line 146
def amazon_locale
locale
end
|
43
|
# File 'app/models/amazon_a_plus_content.rb', line 43
belongs_to :amazon_marketplace, optional: true
|
42
|
# File 'app/models/amazon_a_plus_content.rb', line 42
belongs_to :catalog_item, optional: true
|
#catalog_item_name ⇒ Object
138
139
140
|
# File 'app/models/amazon_a_plus_content.rb', line 138
def catalog_item_name
catalog_item&.name || "ASIN: #{asin}"
end
|
#has_content? ⇒ Boolean
130
131
132
|
# File 'app/models/amazon_a_plus_content.rb', line 130
def has_content?
content_reference_key.present?
end
|
#marketplace_name ⇒ Object
134
135
136
|
# File 'app/models/amazon_a_plus_content.rb', line 134
def marketplace_name
amazon_marketplace&.name || marketplace_id
end
|
#our_locale ⇒ Object
142
143
144
|
# File 'app/models/amazon_a_plus_content.rb', line 142
def our_locale
self.class.amazon_to_our_locale(locale)
end
|