Class: B2bCenterApi::WebService::Types::AttachmentName

Inherits:
BaseType
  • Object
show all
Defined in:
lib/b2b_center_api/web_service/types/attachment_name.rb

Overview

Файл для отправки

Constant Summary

Constants inherited from BaseType

BaseType::NO_INSPECT_ATTRS

Instance Attribute Summary collapse

Attributes inherited from BaseType

#date_fields, #soap_client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseType

#inspect, #to_h

Methods included from B2bCenterApi::WebService::TypeCast

included

Constructor Details

#initialize(file_path) ⇒ AttachmentName

Returns a new instance of AttachmentName.



15
16
17
18
19
# File 'lib/b2b_center_api/web_service/types/attachment_name.rb', line 15

def initialize(file_path)
  file = File.new(file_path)
  @filename = File.basename(file_path)
  @md5 = Digest::MD5.hexdigest(file.read)
end

Instance Attribute Details

#filenameString (readonly)

Returns Имя файла.

Returns:

  • (String)

    Имя файла



10
11
12
# File 'lib/b2b_center_api/web_service/types/attachment_name.rb', line 10

def filename
  @filename
end

#md5String (readonly)

Returns MD5 от содержимого файла.

Returns:

  • (String)

    MD5 от содержимого файла



13
14
15
# File 'lib/b2b_center_api/web_service/types/attachment_name.rb', line 13

def md5
  @md5
end

Class Method Details

.from_array(files_array) ⇒ Array

Подготовка массива AttachmentName для отправки

Parameters:

  • files_array (Array)

    Массив файлов

Returns:

  • (Array)

    Массив хешей для отправки по SOAP



24
25
26
27
28
# File 'lib/b2b_center_api/web_service/types/attachment_name.rb', line 24

def self.from_array(files_array)
  files_array.map do |file|
    { file: new(file).to_h }
  end
end