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

additional_info[R]

AdditionalInfo

additional_trade_information[R]

dodatkowa informacja handlowa

city_of_publication[R]

miasto, w którym została wydana ksiażka

cn_code[R]

cn code

collection_part[R]

numer w cyklu

collection_title[R]

nazwa cyklu (częste przy komiksach, gdy seria jest częścią tytułu, np. Thorgal)

contributors[R]

lista autorów, tłumaczy i innych, którzy mieli wkład w książkę, lista instancji Contributor

country_of_manufacture[R]

kraj produkcji

cover_price[R]

sugerowana cena detaliczna brutto produktu

cover_type[R]

typ okładki, np. ‘miękka ze skrzydełkami’

current_state[R]

Status produktu - jedna z wartości: announced, :preorder, :published, :out_of_print, :deleted

description[R]

Opis produktu, instancja TextContent

digital_formats[R]

lista formatów, w jakich jest dostępny ebook (PDF, MOBI, EPUB)

duration[R]

czas trwania nagrania w audiobooku, w minutach

ean[R]

ean, jeśli jest inny, niż isbn13

edition_statement[R]

informacja o numerze wydania

edition_type_onix_code[R]

informacja o type wydanie, kod onix

excerpt_infos[R]

informacje o fragmentach utworów (produkty cyfrowe)

file_infos[R]

informacje o plikach master (produkty cyfrowe)

full_title[R]

pełen tytuł

height[R]

wysokość w milimetrach

hyphenated_isbn[R]

isbn z kreskami

imprint_name[R]

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[R]

isbn13 - bez kresek

languages[R]

lista języków, lista intancji Language

licence_limited_to[R]

data końca licencji, jeśli licencja nie jest bezterminowa, instancja Date

licence_limited_to_before_type_cast[R]

data końca licencji, jeśli licencja nie jest bezterminowa, w formacie YYYYMMDD

number_of_illustrations[R]

liczba ilustracji

number_of_pages[R]

ilość stron w książce drukowanej

number_of_pieces[R]

ilość elementów (puzzle, gry planszowe)

original_title[R]

tytuł oryginału

pdw_exclusiveness[R]

PDWExclusiveness

pkwiu[R]

PKWiU

players_number_from[R]

min. ilość graczy - gry planszowe

players_number_to[R]

max. ilość graczy - gry planszowe

playing_time_from[R]

min. czas gry - gry planszowe

playing_time_to[R]

max. czas gry - gry planszowe

product_form[R]
product_form_name[R]

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

publisher_id[R]

ID wydawnictwa w systemie elibri

publisher_name[R]

nazwa wydawnictwa

reading_age_from[R]

Wiek czytelnika - od

reading_age_to[R]

Wiek czytelnika - do

record_reference[R]

record reference - wewnętrzny identyfikator rekordu, niezmienny i unikatowy

series[R]

lista serii, w postaci [nazwa serii, numer w serii]

short_description[R]

krótki opis, jeśli wydawca takowy zamieści, instancja TextContent

subtitle[R]

podtytuł

table_of_contents[R]

Spis treści - jeśli wydawca takowy umieścił, instancja TextContent

technical_protection[R]

sposób zabezpieczania pliki (DRM, WATERMARK) - pliki dostępne w API transakcyjnym zawsze będą chronione watermarkiem

technical_protection_onix_code[R]
thickness[R]

gruboś w milimetrach

title[R]

tytuł ksiażki

to_xml[R]

reprezentacja xml dla produktu

vat[R]

stawka VAT

weight[R]

waga w gramach

width[R]

szerokość w milimetrach

Public Class Methods

new(data) click to toggle source
# 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

authors() click to toggle source
# File lib/elibri_onix/onix_3_0/product.rb, line 494
def authors
  unnamed_persons? ? ["praca zbiorowa"] : @contributors.find_all { |c| c.role_name == "author" }.map(&:person_name)
end
collateral_details_setup(data) click to toggle source
# 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
descriptive_details_setup(data) click to toggle source
# 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
exclusive_distributor_onix_code() click to toggle source
# 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
front_cover() click to toggle source

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
licence_information_setup(data) click to toggle source
# 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
no_contributor?() click to toggle source

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
premiere() click to toggle source

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
preview_exists?() click to toggle source

flaga, czy istnieje podgląd produktu

# File lib/elibri_onix/onix_3_0/product.rb, line 490
def preview_exists?
  @preview_exists
end
product_form_features_setup(data) click to toggle source
# 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
publishing_details_setup(data) click to toggle source
# 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
sale_restricted_to_poland?() click to toggle source

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
sales_restrictions?() click to toggle source
# File lib/elibri_onix/onix_3_0/product.rb, line 465
def sales_restrictions?
  @sales_restrictions.size > 0
end
series_names() click to toggle source

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
unlimited_licence?() click to toggle source

flaga informująca, czy licencja jest bezterminowa

# File lib/elibri_onix/onix_3_0/product.rb, line 475
def unlimited_licence?
  @unlimited_licence
end
unnamed_persons?() click to toggle source

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