13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/fax_finder/send.rb', line 13
def construct_xml(recipient_fax, options={})
xml = ""
builder = Builder::XmlMarkup.new(:target => xml, :indent => 2 )
builder.instruct!(:xml, :version=>'1.0', :encoding=>'UTF-8')
time=options[:schedule_all_at]
time=time.utc if time && !time.utc?
formatted_time=time ? time.strftime(Request::TIME_FORMAT) : nil
external_url=options[:external_url]
if external_url.nil? && _content=options[:content]
if _content.is_a?(String)
content=_content
else
_content.rewind
_content.binmode
attachment_name = options[:attachment_name] || File.basename(_content.path)
content=Base64.encode64(_content.read).gsub(/\n/, '')
end
else
content=nil
end
builder.schedule_fax {
builder.cover_page do
builder.subject(options[:subject])
builder.(options[:comment])
builder.enabled('false')
end
builder.recipient do
builder.fax_number(recipient_fax)
builder.organization(options[:recipient_organization])
builder.phone_number(options[:recipient_phone_number])
builder.name(options[:recipient_name])
end
builder.sender do
builder.fax_number(options[:sender_fax_number])
builder.phone_number(options[:sender_phone_number])
builder.organization(options[:sender_organization])
builder.name(options[:sender_name])
end
builder.attachment do
if external_url
builder.location('external')
builder.url(external_url)
elsif content
builder.content(content)
builder.name(options[:filename])
builder.attachment_name(attachment_name)
builder.content_transfer_encoding('base64')
builder.location('inline')
builder.name(attachment_name)
builder.content_type(options[:content_type])
end
end
builder.try_interval(options[:try_interval])
builder.max_tries(options[:max_tries])
builder.schedule_all_at(formatted_fax_finder_time(options[:schedule_all_at]))
}
xml
end
|