megaport.js

1.0.4 • Public • Published

Megaport JS Wrapper functions

Initilising the wrapper

Staging Url 'https://api-staging.i.megaport.com'

megaport = new mp('https://api-staging.i.megaport.com/v2/');

Authenticating a User

megaport.auth({
  username: 'wsmithers',
  password: 'password'
});

If you have a valid token you can pass that instead, { token: 'tokenstring' }

Once Authenticated

######megaport.ready(callback)

Callback is run once a megaport wrapper has been authenticated.

megaport.ready(
  function(credentials) {
    console.log(credentials);
  }
);

On Authentication Failure

megaport.failauth(callback)

Callback is run once a megaport wrapper has failed an auth.

megaport.failauth(function () {
  console.log('Authentication Failed');
});

Menu Stats

Returning current authenicated profile account stats/notifications

megaport.menuStats().then(
  function (menustats) {
    console.log(menustats);
  }
);

Dashboard Info

Returning current authenicated profile dashboard information

megaport.dashboard().then(
  function (menustats) {
    console.log(menustats);
  }
);

User Profile

Returning current authenicated profile information

megaport.profile().then(
  function (profileObj) {
    output(profileObj);
  }
);

Updating current authenicated profile information

megaport.profile().update({
  firstName: "Pat",
}).then(
  function (response) {
    output(response);
  }
);

Company Profile

Returning current users company

megaport.company().then(
  function (profileObj) {
    console.log(profileObj);
  }
);

Updating current users company

megaport.company().update({
  www: 'http://www.megaport.com',
}).then(
  function (response) {
    console.log(response);
  }
);

Tickets

Listing open tickets.

megaport.tickets().then(
  function (list) {
    output(list);
  }
);

TicketStatus: OPEN, CLOSED, ANY

megaport.tickets().filter('CLOSED').then(
  function (list) {
    output(list);
  }
);

Returning specific ticket.

megaport.tickets(ticketId).then(
 function (t) {
   output(t);
 }
);

Commenting on a ticket

megaport.tickets(ticketId).comment('Comment String').then(
 function (response) {
   output(response);
 }
);

Closing a ticket

megaport.tickets(ticketId).close().then(
 function (response) {
   output(response);
 }
);

Creating a ticket

megaport.tickets().create({
 subject: 'Ticket 101',
 description: 'Ticket Description',
 queue: '',
 serviceId: '',
 companyId: ''
}).close().then(
 function (response) {
   output(response);
 }
);

Markets

List of markets the current auth users company is registered in.

megaport.markets().then(
  function (m) {
    output(m);
  }
);

Market registration information by market id

megaport.markets(121).then(
 function (m) {
   output(m); 
 }
);

Update market registration

megaport.markets(121).update({
 "billingContactName": "112",
 "billingContactEmail": "112@asdasd.com",
 "billingContactPhone": "112",
 "address1": "112",
 "address2": "112",
 "postcode": "12",
 "country": "Australia",
 "city": "112",
 "state": "12",
 "web": "112"
}).then(
 function (m) {
   console.log(m);
 }
);

Managing Services

Return all megaport and thier assossiated services.

megaport.ports().then(function(megaports){
    output(megaports);
});

Update Service Details by productId

megaport.product(productUid)

works for both megaport, vxc, ix

megaport.product(productUid).then(
  function (product) {
    console.log(product);
  }
);

Update product (if changing rateLimit be sure to use .checkPrice() first)

megaport.product(productUid).update({
name: 'name change'
}).then(
  function (response) {
    output(response);
  }
);

Checking price on rateLimit changes

megaport.product(productUid).checkPrice(1000).then(
  function (response) {
    output(response);
  }
);

Price Book

megaport.priceBook()
  .megaport({
    locationId: 2, //int
    speed: 1000, //int
    term: 1 // months (not required)
  }).then(function(priceobj){
    output(priceobj);
  });
megaport.priceBook()
  .vxc({
    aLocationId: 2,
    bLocationId: 3,
    speed: 1000
  }).then(function(priceobj){
    output(priceobj);
  });
megaport.priceBook()
  .ix({
    portLocationId: 6,
    ixType: "Brisbane IX",
    speed: 1000
  }).then(function(priceobj){
    output(priceobj);
  });

Agencies

megaport.agency()
  .createAgent(
    {
      "firstName":"agent",
      "lastName":"agent",
      "email":"agent2@test.com",
      "securityRoles":["agentMarketingAdmin"] "companyAdmin", "agentAdmin", "agentMarketingAdmin"
    }
  );
megaport.agency()
  .createSubAgency({
    "companyDto":
      {
        "legalName":"sub agency 1"
      },
      "userDto": {
        "firstName":"test",
        "lastName":"test",
        "email":"test@test.com"
      }
    }).then(function(res){
    output(res);
  });

Readme

Keywords

none

Package Sidebar

Install

npm i megaport.js

Weekly Downloads

2

Version

1.0.4

License

ISC

Last publish

Collaborators

  • cokeeffekt