Class: TecDoc::ArticleDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/tec_doc/article_document.rb

Direct Known Subclasses

ArticleThumbnail

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ArticleDocument

Returns a new instance of ArticleDocument.



24
25
26
27
28
29
30
31
# File 'lib/tec_doc/article_document.rb', line 24

def initialize(attributes = {})
  @id             = attributes[:doc_id].to_i
  @link_id        = attributes[:doc_link_id].to_i
  @file_name      = attributes[:doc_file_name].to_s
  @file_type_name = attributes[:doc_file_type_name].to_s
  @type_id        = attributes[:doc_type_id].to_i
  @type_name      = attributes[:doc_type_name].to_s
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def description
  @description
end

#file_nameObject

Returns the value of attribute file_name.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def file_name
  @file_name
end

#file_type_nameObject

Returns the value of attribute file_type_name.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def file_type_name
  @file_type_name
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def id
  @id
end

Returns the value of attribute link_id.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def link_id
  @link_id
end

#type_idObject

Returns the value of attribute type_id.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def type_id
  @type_id
end

#type_nameObject

Returns the value of attribute type_name.



3
4
5
# File 'lib/tec_doc/article_document.rb', line 3

def type_name
  @type_name
end

Class Method Details

.all(options = {}) ⇒ Array<TecDoc::ArticleDocument>

Find document descriptions to an article

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :article_id (Integer)

    article ID

  • :article_link_id (Integer)

    article link ID (optional)

  • :country (String)

    country code according to ISO 3166

  • :doc_type_id (Integer)

    document type (KT 141) (optional)

  • :lang (String)

    language code according to ISO 639

Returns:



13
14
15
16
17
18
19
20
21
22
# File 'lib/tec_doc/article_document.rb', line 13

def self.all(options = {})
  options = {
    :country => TecDoc.client.country,
    :lang => I18n.locale.to_s
  }.merge(options)
  response = TecDoc.client.request(:get_article_documents, options)
  response.map do |attributes|
    new attributes
  end
end

Instance Method Details

#contentObject



40
41
42
43
44
45
46
47
# File 'lib/tec_doc/article_document.rb', line 40

def content
  request = TecDoc.client.connection.http
  request.url = url
  request.body = nil
  request.headers = {}
  response = HTTPI.post(request)
  response.raw_body
end

#urlObject



33
34
35
36
37
38
# File 'lib/tec_doc/article_document.rb', line 33

def url
  base_url = TecDoc.client.connection.wsdl.endpoint.gsub("/services/TecdocToCatWL", "")
  provider = TecDoc.client.provider
  thumbnail_flag = self.is_a?(ArticleThumbnail) ? "1" : "0"
  "#{base_url}/documents/#{provider}/#{id}/#{thumbnail_flag}"
end