Class: Taxii::Messages::PollRequest

Inherits:
Hashie::Dash
  • Object
show all
Includes:
Hashie::Extensions::Coercion
Defined in:
lib/taxii/messages/poll_request.rb

Instance Method Summary collapse

Instance Method Details

#requested_beginObject



20
21
22
23
24
25
26
# File 'lib/taxii/messages/poll_request.rb', line 20

def requested_begin
  if exclusive_begin_timestamp.nil?
    {}
  else
    {'Exclusive_Begin_Timestamp': exclusive_begin_timestamp.strftime(TS_FORMAT)}
  end
end

#requested_endObject



28
29
30
31
32
33
34
# File 'lib/taxii/messages/poll_request.rb', line 28

def requested_end
  if inclusive_end_timestamp.nil?
    {}
  else
    {'Inclusive_End_Timestamp': inclusive_end_timestamp.strftime(TS_FORMAT)}
  end
end

#requested_infoObject



35
36
37
38
39
40
41
# File 'lib/taxii/messages/poll_request.rb', line 35

def requested_info
  if subscription_id.nil?
    {'taxii_11:Poll_Parameters': poll_parameters.to_h}
  else
    {'taxii_11:Subscription_ID': subscription_id}
  end
end

#to_hObject



43
44
45
46
47
48
49
50
# File 'lib/taxii/messages/poll_request.rb', line 43

def to_h
  NAMESPACE_ATTRIBUTES.merge({
    '@message_id':      message_id,
    '@collection_name': collection_name
  }).merge(requested_begin)
    .merge(requested_end)
    .merge(requested_info)
end

#to_xmlObject



52
53
54
# File 'lib/taxii/messages/poll_request.rb', line 52

def to_xml
  Gyoku.xml({'taxii_11:Poll_Request': to_h}, key_converter: :none)
end