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

@bboxlab/mosel-sdk

v0.1.23

Published

This package is currently a work in progress version.

Downloads

54

Readme

Mosel Node SDK for BT Open Apis

This package is currently a work in progress version.

How to install

npm i @bboxlab/mosel-sdk

Add a check email route inside a Node Project

After installing the package, you need to create a SDK object.

Skd needs

  • credentials
  • configuration

You can import all this object from mosel-sdk.

const credentials = new Credentials("clientId", "secret");

// configuration contains all the endpoints urls, etc.
// you can add the value of confguration manually
const configuration = new Configuration();
// here you need to add manually all the urls

// or you can add a preexisting configuration, for exemple, a staging conf
const configuration = new ConfigurationCreator().createApConfig();

const sdk = new Sdk(credentials, configuration);

Don't forget to replace the credentials by real ones.

After creating the sdk, you just need to add the service you need. In this example, it is checkEmail()

Check email needs an email input. EmailInput is a JS object containing an emailAddress property.

const input = new EmailCheckerInput("[email protected]");
sdk.checkEmail(input);

With some refacto:

const checkEmailResponse = new Sdk(
  new Credentials("clientId", "secret"), // create the credentials
  new ConfigurationCreator().createApConfig() // generate the by defaut config
).checkEmail(new EmailCheckerInput("[email protected]")); // input is {"emailAddress": "[email protected]"}

Or an example of integration in a Standard Nest Controller

import {
  [...],
  EmailCheckerInput,
  Sdk,
  ConfigurationCreator,
  Credentials,
  CheckEmailInput
} from '@bboxlab/mosel-sdk';

  [...]

  @Post('/emails/check')
  async checkEmail(@Body() checkEmailInput: CheckEmailInput): Promise<string> {
    // check the email by creating an sdk with credentials and defaut config
    return await new Sdk(
        // new Credentials(process.env.BT_API_LOGIN, process.env.BT_API_PWD),
        new Credentials('clientId', 'secret'),
        new ConfigurationCreator().createApConfig(), // generate the by defaut config
      ).checkEmail(new EmailCheckerInput(checkEmailInput.emailAddress)); // input is {"emailAddress": "[email protected]"}
    }

How to build the project

The project will be build with rollup.

npm run build

Tutorial: integrating the mosel-sdk package in a common js app

Requirements:

  • node
  • npm

Creating a cjs simple project

First, create a folder with a js file.

mdkir common-js-app
cd common-js-app
touch app.js

Add a minimal code in app.js.

console.log("hello world");

Run it with the following command to get the "hello world" message in console.

node app.js

We will add npm configuration (and validate all default responses).

npm init

In package json, we add a script for start : "start": "node app.js"

{
  "name": "common-js-app",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "author": "",
  "license": "ISC"
}

Installing mosel sdk

npm i @bboxlab/mosel-sdk

Replace code in app.js by with real credentials:

const Mosel = require("@bboxlab/mosel-sdk");

const checkEmailResponse = new Mosel.Sdk(
  new Mosel.Credentials(
    "partner.tocomplete.bouyguestelecom.fr",
    "somePassword"
  ), // replace with the correct credentials
  new Mosel.ConfigurationCreator().createApConfig() // generate the by defaut config
).checkEmail(new Mosel.EmailCheckerInput("[email protected]")); // input is {"emailAddress": "[email protected]"}

// a way to display the response returned by the sdk
checkEmailResponse.then((data) => console.log(data));

Start the app with "npm run start", to get a response like the following in your console:

Response {
  token: Token {
    access_token: 'at-58734b17-386b-47e9-b942-43b1227fc361',
    expires_in: 3600,
    token_type: 'Bearer',
    refresh_credit: 0,
    scope: 'EXT_SalesPartnerContext EXT_ShoppingCartManage openid roles profile EXT_CustomerAccountManage EXT_OrderManage EXT_PostalAddressConsult EXT_IbanConsult DocumentConsult EXT_EmailAddressConsult EXT_PortabilityConsult email',
    created_at: 2022-10-20T09:28:44.665Z,
    new: true
  },
  content: { contactEmailAddress: false, validEmailAddress: true }
}

About require

If you use cjs and "require" to import module, you need to add the reference to Mosel before all imported objects. For exemple "new Mosel.Sdk()" and "new Sdk()".

Help

If it doesn't work, have you replace the credentials by real ones?