npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

megaport.js

v1.0.4

Published

megaport js wrapper

Downloads

9

Readme

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": "[email protected]",
 "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":"[email protected]",
      "securityRoles":["agentMarketingAdmin"] "companyAdmin", "agentAdmin", "agentMarketingAdmin"
    }
  );
megaport.agency()
  .createSubAgency({
    "companyDto":
      {
        "legalName":"sub agency 1"
      },
      "userDto": {
        "firstName":"test",
        "lastName":"test",
        "email":"[email protected]"
      }
    }).then(function(res){
    output(res);
  });