NumminorihSF / ami-io

Use node.js or io.js to manage Asterisk through AMI
MIT License
30 stars 16 forks source link

Cannot read property 'Originate' of undefined #10

Closed ikerib closed 7 years ago

ikerib commented 7 years ago

Hi, I have this code:

const AmiIo = require("ami-io"),
    SilentLogger = new AmiIo.SilentLogger(), //use SilentLogger if you just want remove logs
    amiio = AmiIo.createClient({port:PORT, host:SERVER, login:USER, password:PASSWD,logger: SilentLogger});

const action = new amiio.Action.Originate();
action.Channel = 'sip/123';
action.Context = 'default';
action.Exten = '456';
action.Priority = 1;
action.Async = true;
action.WaitEvent = true;

amiio.send(action, function(err, data){
    if (err){
        //err will be event like OriginateResponse if (#response !== 'Success')
    }
    else {
        //data is event like OriginateResponse if (#response === 'Success')
    }
});

On phpStorm I'm getting "unresolved type Originate". If I look into amiio.Action symbols it founds 2 declarations:

On node console I see this :

TypeError: Cannot read property 'Originate' of undefined

any help?

NumminorihSF commented 7 years ago

Hi. You just should use

const AmiIo = require("ami-io");
const action = new AmiIo.Action.Originate(); //AmiIo here is the variable's name there you store required ami-io
ikerib commented 7 years ago

yep! thanks! My bad