Class: AmazonMarketplace
Overview
== Schema Information
Table name: amazon_marketplaces
Database name: primary
id :bigint not null, primary key
marketplace_identifier :string(20) not null
name :string not null
url :string
country_id :integer not null
Indexes
index_amazon_marketplaces_on_marketplace_identifier (marketplace_identifier) UNIQUE
Foreign Keys
fk_rails_... (country_id => countries.id)
Constant Summary
collapse
- MARKETPLACE_ID_US =
'ATVPDKIKX0DER'
- MARKETPLACE_ID_CA =
'A2EUQ1WTGCTBG2'
- MARKETPLACE_IDS_NA =
[MARKETPLACE_ID_US, MARKETPLACE_ID_CA]
- FBA_CHANNEL_CODE_NA =
'AMAZON_NA'
- FBA_CHANNEL_CODE_EU =
'AMAZON_EU'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
#publish_event
Instance Attribute Details
#marketplace_identifier ⇒ Object
37
|
# File 'app/models/amazon_marketplace.rb', line 37
validates :marketplace_identifier, presence: true, uniqueness: true
|
#name ⇒ Object
36
|
# File 'app/models/amazon_marketplace.rb', line 36
validates :name, presence: true
|
Class Method Details
.ca_marketplace ⇒ Object
43
44
45
|
# File 'app/models/amazon_marketplace.rb', line 43
def self.ca_marketplace
find_by(marketplace_identifier: MARKETPLACE_ID_CA)
end
|
.north_american_marketplaces ⇒ ActiveRecord::Relation<AmazonMarketplace>
A relation of AmazonMarketplaces that are north american marketplaces. Active Record Scope
32
|
# File 'app/models/amazon_marketplace.rb', line 32
scope :north_american_marketplaces, -> { where(marketplace_identifier: MARKETPLACE_IDS_NA) }
|
.select_options ⇒ Object
47
48
49
|
# File 'app/models/amazon_marketplace.rb', line 47
def self.select_options
eager_load(:country).map { |am| [am.to_s, am.id] }
end
|
.us_marketplace ⇒ Object
39
40
41
|
# File 'app/models/amazon_marketplace.rb', line 39
def self.us_marketplace
find_by(marketplace_identifier: MARKETPLACE_ID_US)
end
|
Instance Method Details
#amazon_schemas ⇒ ActiveRecord::Relation<AmazonSchema>
29
|
# File 'app/models/amazon_marketplace.rb', line 29
has_many :amazon_schemas, dependent: :destroy, inverse_of: :amazon_marketplace
|
#catalogs ⇒ ActiveRecord::Relation<Catalog>
28
|
# File 'app/models/amazon_marketplace.rb', line 28
has_many :catalogs, dependent: :nullify, inverse_of: :amazon_marketplace
|
27
|
# File 'app/models/amazon_marketplace.rb', line 27
belongs_to :country
|
#fba_channel_code ⇒ Object
#supports_business_offer? ⇒ Boolean
55
56
57
|
# File 'app/models/amazon_marketplace.rb', line 55
def supports_business_offer?
marketplace_identifier.in?(MARKETPLACE_IDS_NA)
end
|
#to_s ⇒ Object
68
69
70
|
# File 'app/models/amazon_marketplace.rb', line 68
def to_s
"#{name} - #{marketplace_identifier}"
end
|
#url_for_asin(asin) ⇒ Object
51
52
53
|
# File 'app/models/amazon_marketplace.rb', line 51
def url_for_asin(asin)
"#{url}/dp/#{asin}"
end
|