class Elibri::ONIX::Release_3_0::Product
Klasa reprezentująca produkt Niektóre pola mogą pozostać bez wartości - zależy to od formy produktu
Attributes
AdditionalInfo
dodatkowa informacja handlowa
miasto, w którym została wydana ksiażka
cn code
numer w cyklu
nazwa cyklu (częste przy komiksach, gdy seria jest częścią tytułu, np. Thorgal)
lista autorów, tłumaczy i innych, którzy mieli wkład w książkę, lista instancji Contributor
kraj produkcji
sugerowana cena detaliczna brutto produktu
typ okładki, np. ‘miękka ze skrzydełkami’
Status produktu - jedna z wartości: announced, :preorder, :published, :out_of_print, :deleted
Opis produktu, instancja TextContent
lista formatów, w jakich jest dostępny ebook (PDF, MOBI, EPUB)
czas trwania nagrania w audiobooku, w minutach
ean, jeśli jest inny, niż isbn13
informacja o numerze wydania
informacja o type wydanie, kod onix
informacje o fragmentach utworów (produkty cyfrowe)
informacje o plikach master (produkty cyfrowe)
pełen tytuł
wysokość w milimetrach
isbn z kreskami
Imprint
, jeśli wydawnictwo używa imprintów. Jeżeli wydawnictwo podało imprint, to ta wartość powinna zostać wyświetlona użytkownikowi w sklepie jako nazwa wydawnictwa.
isbn13 - bez kresek
lista języków, lista intancji Language
data końca licencji, jeśli licencja nie jest bezterminowa, instancja Date
data końca licencji, jeśli licencja nie jest bezterminowa, w formacie YYYYMMDD
liczba ilustracji
ilość stron w książce drukowanej
ilość elementów (puzzle, gry planszowe)
tytuł oryginału
PDWExclusiveness
PKWiU
min. ilość graczy - gry planszowe
max. ilość graczy - gry planszowe
min. czas gry - gry planszowe
max. czas gry - gry planszowe
kod ONIX
typu produktu, np. ‘BA’ - lista dostępna pod adresem github.com/elibri/elibri_onix_dict/blob/master/lib/elibri_onix_dict/onix_3_0/serialized/ProductFormCode.yml
nazwa typu produktu, małe litery, np. ‘book’ - patrz pełna lista pod adresem github.com/elibri/elibri_onix_dict/blob/master/lib/elibri_onix_dict/onix_3_0/serialized/ProductFormCode.yml
ID wydawnictwa w systemie elibri
nazwa wydawnictwa
Wiek czytelnika - od
Wiek czytelnika - do
record reference - wewnętrzny identyfikator rekordu, niezmienny i unikatowy
lista serii, w postaci [nazwa serii, numer w serii]
krótki opis, jeśli wydawca takowy zamieści, instancja TextContent
podtytuł
Spis treści - jeśli wydawca takowy umieścił, instancja TextContent
sposób zabezpieczania pliki (DRM, WATERMARK) - pliki dostępne w API transakcyjnym zawsze będą chronione watermarkiem
gruboś w milimetrach
tytuł ksiażki
reprezentacja xml dla produktu
stawka VAT
waga w gramach
szerokość w milimetrach
Public Class Methods
# File lib/elibri_onix/onix_3_0/product.rb, line 248 def initialize(data) @to_xml = data.to_s #initialize variables that need to be array ##descriptive_details @text_contents = [] @supporting_resources = [] ##collateral_details @measures = [] @title_details = [] @collections = [] @contributors = [] @languages = [] @extents = [] @thema_subjects = [] @publisher_subjects = [] @audience_ranges = [] ##publishing_details @sales_restrictions = [] @excerpt_infos = [] @cover_type = nil #moving to parsing attributes @record_reference = data.at_css('RecordReference').try(:text) @notification_type = data.at_css('NotificationType').try(:text) @deletion_text = data.at_css('DeletionText').try(:text) if data.namespaces.values.any? { |uri| uri =~ /elibri/ } @cover_type = data.at_xpath('elibri:CoverType').try(:text) @pkwiu = data.at_xpath('elibri:PKWiU').try(:text) @hyphenated_isbn = data.at_xpath('elibri:HyphenatedISBN').try(:text) @pdw_exclusiveness = data.at_xpath('elibri:PDWExclusiveness').try(:text) @additional_info = data.at_xpath('elibri:AdditionalInfo').try(:text) end @identifiers = data.children.find_all { |node| node.name == 'ProductIdentifier' }.map { |ident_data| ProductIdentifier.new(ident_data) } begin @related_products = data.at_css('RelatedMaterial').css('RelatedProduct').map { |related_data| RelatedProduct.new(related_data) } rescue @related_products = [] end begin @supply_details = data.at_css('ProductSupply').css('SupplyDetail').map { |supply_data| SupplyDetail.new(supply_data) } rescue @supply_details = [] end if data.namespaces.values.any? { |uri| uri =~ /elibri/ } && (data.at_xpath('elibri:Vat') || data.at_xpath('elibri:CoverPrice')) @cover_price = BigDecimal(data.at_xpath('elibri:CoverPrice').try(:text)) if data.at_xpath('elibri:CoverPrice') @vat = data.at_xpath('elibri:Vat').try(:text).try(:to_i) else #00 - Supplier role - Unspecified price_sd = @supply_details.find { |sd| sd.supplier && ["00", Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_TO_RET].include?(sd.supplier.role) } if price_sd && price_sd.price && price_sd.price && price_sd.price.type == Elibri::ONIX::Dict::Release_3_0::PriceTypeCode::RRP_WITH_TAX @vat = price_sd.price.tax_rate_percent.to_i @cover_price = price_sd.price.amount @additional_trade_information = price_sd.additional_trade_information end end descriptive_details_setup(data.at_css('DescriptiveDetail')) if data.at_css('DescriptiveDetail') collateral_details_setup(data.at_css('CollateralDetail')) if data.at_css('CollateralDetail') if data.namespaces.values.any? { |uri| uri =~ /elibri/ } && data.at_xpath('elibri:preview_exists') @preview_exists = (data.at_xpath('elibri:preview_exists').text == "true") else @preview_exists = @supporting_resources.find { |sr| sr.content_type_name == "widget" && sr.link =~ /p.elibri.com.pl/ }.present? end product_form_features_setup(data.css("ProductFormFeature")) publishing_details_setup(data.at_css('PublishingDetail')) if data.at_css('PublishingDetail') licence_information_setup(data) begin @excerpt_infos = data.at_xpath("elibri:excerpts").xpath("elibri:excerpt").map { |node| ExcerptInfo.new(node) } rescue demo = @supporting_resources.find { |sr| sr.content_type_name == "sample_content" } if demo @excerpt_infos = demo.data.css("ResourceVersion").map { |node| ExcerptInfo.new(node) } end end @file_infos = data.css("BodyResource").map { |node| FileInfo.new(node) } after_parse end
Public Instance Methods
# File lib/elibri_onix/onix_3_0/product.rb, line 433 def collateral_details_setup(data) @text_contents = data.css('TextContent').map { |text_detail| TextContent.new(text_detail) } @supporting_resources = data.css('SupportingResource').map { |supporting_data| SupportingResource.new(supporting_data) } end
# File lib/elibri_onix/onix_3_0/product.rb, line 373 def descriptive_details_setup(data) @country_of_manufacture = data.at_css("CountryOfManufacture").try(:text) @product_composition = data.at_css('ProductComposition').try(:text) @product_form = data.at_css('ProductForm').try(:text) if @product_form if @product_form.starts_with?("B") && !@cover_type @cover_type = Elibri::ONIX::Dict::CoverType.determine_cover_type(@product_form, data.at_css('ProductFormDetail').try(:text)) end if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(@product_form) @product_form_name = Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(@product_form).name(:en).downcase end simplified_product_form = @product_form.starts_with?("B") ? "BA" : @product_form if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(simplified_product_form).try!(:digital?) @digital_formats = [] data.css("ProductFormDetail").each do |format| format_name = Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::find_by_onix_code(format.text).try(:name) @digital_formats << format_name.upcase.gsub("MOBIPOCKET", "MOBI") if format_name end end end data.css('ProductClassification').each do |cl| cl_type = cl.at_css('ProductClassificationType').text cl_value = cl.at_css('ProductClassificationCode').text if cl_type == Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::PKWIU @pkwiu = cl_value elsif cl_type == Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::CN @cn_code = cl_value end end @measures = data.css('Measure').map { |measure_data| Measure.new(measure_data) } @title_details = data.children.find_all { |node| node.name == 'TitleDetail' }.map { |title_data| TitleDetail.new(title_data) } @collections = data.css('Collection').map { |collection_data| Collection.new(collection_data) } @contributors = data.css('Contributor').map { |contributor_data| Contributor.new(contributor_data) } @no_contributor = !!data.at_css('NoContributor') @languages = data.css('Language').map { |language_data| Language.new(language_data) } @extents = data.css('Extent').map { |extent_data| Extent.new(extent_data) } @publisher_subjects = data.css('Subject').find_all { |sd| %w{24}.include?(sd.at_css('SubjectSchemeIdentifier').try(:text)) }.map { |sd| PublisherSubject.new(sd) } @thema_subjects = data.css('Subject').find_all { |sd| %w{93 94 95 96 97 98 99}.include?(sd.at_css('SubjectSchemeIdentifier').try(:text)) }.map { |sd| ThemaSubject.new(sd) } @audience_ranges = data.css('AudienceRange').map { |audience_data| AudienceRange.new(audience_data) } #zabezpiecznie pliku if protection = data.at_css("EpubTechnicalProtection").try(:text) @technical_protection = Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::find_by_onix_code(protection).try(:name) @technical_protection_onix_code = protection end @edition_statement = data.at_css('EditionStatement').try(:text) if Elibri::ONIX::Dict::Release_3_0::EditionType.find_by_onix_code(data.at_css('EditionType').try(:text)) @edition_type_onix_code = data.at_css('EditionType').try(:text) end @number_of_illustrations = data.at_css('NumberOfIllustrations').try(:text).try(:to_i) end
# File lib/elibri_onix/onix_3_0/product.rb, line 459 def exclusive_distributor_onix_code if @sales_restrictions.size > 0 @sales_restrictions[0].outlet_code end end
okładka ksiązki, instance SupportingResource
# File lib/elibri_onix/onix_3_0/product.rb, line 512 def front_cover @supporting_resources.find { |resource| resource.content_type_name == "front_cover" } end
# File lib/elibri_onix/onix_3_0/product.rb, line 333 def licence_information_setup(data) if data.namespaces.values.any? { |uri| uri =~ /elibri/ } && (data.at_xpath("elibri:SaleNotRestricted") || data.at_xpath("elibri:SaleRestrictedTo")) if data.at_xpath("elibri:SaleNotRestricted") @unlimited_licence = true elsif date = data.at_xpath("elibri:SaleRestrictedTo").try(:text) @unlimited_licence = false @licence_limited_to_before_type_cast = date @licence_limited_to = _parse_date(date) end else daten = data.css('PublishingDate').find { |d| d.at_css("PublishingDateRole") && d.at_css("PublishingDateRole").text == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::OUT_OF_PRINT_DATE } if daten date = daten.at_css('Date').text @licence_limited_to_before_type_cast = date @licence_limited_to = _parse_date(date) @unlimited_licence = false else @unlimited_licence = true end end end
flaga - true, jeśli produkt nie ma żadnego autora
# File lib/elibri_onix/onix_3_0/product.rb, line 480 def no_contributor? @no_contributor end
data premiery, jako instancja Date (tylko wtedy, gdy dokładna data jest znana)
# File lib/elibri_onix/onix_3_0/product.rb, line 522 def premiere Date.new(*parsed_publishing_date) if parsed_publishing_date.size == 3 rescue ArgumentError nil end
flaga, czy istnieje podgląd produktu
# File lib/elibri_onix/onix_3_0/product.rb, line 490 def preview_exists? @preview_exists end
# File lib/elibri_onix/onix_3_0/product.rb, line 356 def product_form_features_setup(data) data.each do |feature| ftype = feature.at_css("ProductFormFeatureType").inner_text v1, v2 = feature.at_css("ProductFormFeatureValue, ProductFormFeatureDescription").inner_text.split("-").map(&:to_i) if ftype == Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::NUMBER_OF_GAME_PIECES @number_of_pieces = v1 elsif ftype == Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::GAME_PLAYERS @players_number_from = v1 @players_number_to = v2 elsif ftype == Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::GAME_PLAY_TIME @playing_time_from = v1 @playing_time_to = v2 end end end
# File lib/elibri_onix/onix_3_0/product.rb, line 438 def publishing_details_setup(data) @imprint = Imprint.new(data.at_css('Imprint')) if data.at_css('Imprint') @publisher = Publisher.new(data.at_css('Publisher')) if data.at_css('Publisher') @publishing_status = data.at_css('PublishingStatus').try(:text) @city_of_publication = data.at_css("CityOfPublication").try(:text) publication_dates = data.css('PublishingDate').map do |node| PublishingDate.new(node) end @publishing_date = publication_dates.find { |date| date.role == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PUBLICATION_DATE } preorder_embargo_date_as_object = publication_dates.find { |date| date.role == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PREORDER_EMBARGO_DATE } @preorder_embargo_date = Date.new(*preorder_embargo_date_as_object.parsed) if preorder_embargo_date_as_object @sales_restrictions = data.css('SalesRestriction').map { |restriction_data| SalesRestriction.new(restriction_data) } #ograniczenia terytorialne if data.at_css("CountriesIncluded").try(:text) == "PL" @sale_restricted_to_poland = true else @sale_restricted_to_poland = false end end
flaga, czy sprzedaż książki jest ograniczona do Polski
# File lib/elibri_onix/onix_3_0/product.rb, line 470 def sale_restricted_to_poland? @sale_restricted_to_poland end
# File lib/elibri_onix/onix_3_0/product.rb, line 465 def sales_restrictions? @sales_restrictions.size > 0 end
lista nazwa serii, do których należy produkt
# File lib/elibri_onix/onix_3_0/product.rb, line 517 def series_names @series.map { |series| series[0] } end
flaga informująca, czy licencja jest bezterminowa
# File lib/elibri_onix/onix_3_0/product.rb, line 475 def unlimited_licence? @unlimited_licence end
flaga, czy książka to praca zbiorowa?
# File lib/elibri_onix/onix_3_0/product.rb, line 485 def unnamed_persons? @contributors.size == 1 && contributors[0].unnamed_persons.present? end