adhearsion / ruby_ami

MIT License
22 stars 25 forks source link

Sending Status action with multiple variables only shows one Variable value. #42

Open ssether-usinternet opened 6 years ago

ssether-usinternet commented 6 years ago

The Asterisk Status command allows you to send multiple requests for channel variables, separated by commas. So something like this sent to the AMI console:

Action: Status
ActionID: 2
Variables: CDR(ds_type),from_user,companyID

Returning something like this:

Event: Status
 (irrelevant details removed)
Variable: CDR(ds_type)=Test-INT
Variable: from_user=ssether
Variable: companyID=Test
ActionID: 2

When I use RubyAMI to do this, I only get only one of the Variables in the repsonse

      def status(variables="")
        headers = { 'Variables' => variables }
        return @ami.send_action('status', headers)
      end

response = status('CDR(ds_type),from_user,companyID')
puts response.events[0].headers

returns a map, but with only one value in the map for Variable:

{ (irrelevant details removed)
"CallerIDNum"=>"123", "CallerIDName"=>"Steve Sether", "ConnectedLineNum"=>"124", "Variable"=>"companyID=Test", "ActionID"=>"898b7636-3d99-40d3-aaa2-bd955fa920c1"}

I'd expect the Variable key to itself contain a map with key/values. Instead it returns just a single String value "companyID=Test". I expect when this was designed, multiple headers with the same key weren't taken into account.

I did try briefly to fix this myself, but quickly realized the lexer took more effort in understanding that I wanted to try to understand in an hour or two.

Is there some way to get this to work properly (i.e. I'm using the send_action command or the resultant response incorrectly), or is this a bug?

benlangfeld commented 6 years ago

You are correct that multiple headers with the same name are not currently supported. Someone will need to contribute that support.