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

@kloutit/kloutit-sdk

v1.0.2

Published

Kloutit SDK API for client integrations

Downloads

18

Readme

Kloutit SDK

Kloutit is an AI-powered B2B SaaS that enables online merchants to effectively and efficiently defend and prevent chargebacks.

This SDK allows your organization to integrate with Kloutit, so your cases could be automatically created into our system to take profit of all the following profits.

Installation

To install Kloutit SDK you can run the following npm command.

npm install @kloutit/kloutit-sdk@latest

Prerequisites

To be able to use any Kloutit SDK function, your organization must be registered into our system and SDK client keys for the organization must be created. You can register your organization by following a few simple steps from https://app.kloutit.com.

Once your organization is successfully registered, you will be able to configure the SDK connection from the menu My organization > Kloutit SDK. You will need to create new client credentials.

Usage

To use the Kloutit SDK client, you will need to instantiate the KloutitLoginApi to obtain a valid accessToken (expires at 30m, then you can generate a new one). With this accessToken you will be able to instantiate the rest of the available APIs and make your actions.

Sample code Login

import { KloutitLoginApi, KloutitLoginResponse } from '@kloutit/kloutit-sdk';
import { Logger } from '@nestjs/common';
import { AxiosResponse } from 'axios';

// Define your secret values (it should come from an .env or similar)
const CLIENT_ID = '22311cca-9951-42dd-bc9b-bd0574335b55';
const CLIENT_SECRET = '6#.n3dcm-x4hc3Y0SrA/UR?DzggfM;';
const ORGANIZATION_ID = '660055bca25e9c2da9b87944';

// Create the login api instance
const kloutitLogin = new KloutitLoginApi();

let accessToken: string;
let expiresAt: number;
let expiresIn: number;

try {
  Logger.log(
    `Getting Kloutit access token for organization ${ORGANIZATION_ID}`,
  );
  const loginResponse: AxiosResponse<KloutitLoginResponse> =
    await kloutitLogin.login(
      ORGANIZATION_ID,
      {
        grant_type: 'client_credentials',
      },
      {
        auth: {
          username: CLIENT_ID,
          password: CLIENT_SECRET,
        },
      }
    );

  accessToken = loginResponse.data.accessToken;
  expiresIn = loginResponse.data.expiresIn;
  expiresAt = loginResponse.data.expiresAt;

  Logger.log('Access token successfully retrieved!');
} catch (error) {
  Logger.error(
    `Error trying to login to Kloutit SDK. Status code: ${error.response.data.statusCode}`,
    error.response.data.message,
  );
  throw new Error(error.response.data.message);
}

Sample code other calls

Once you have the accessToken with the Login call, you can use it to make other calls, for instance, to create a case.

import {
  KloutitCaseApi,
  KloutitOrganizationType,
  KloutitChargebackReason,
  Currencies,
} from '@kloutit/kloutit-sdk';
import { Logger } from '@nestjs/common';
import { AxiosResponse } from 'axios';

// Create the desired api instance
const kloutitCase = new KloutitCaseApi();

try {
  // Make the call with the requested body
  Logger.log('Creating case into Kloutit');
  const caseResponse: AxiosResponse<KloutitCaseResponse> = await kloutitCase.createCase(
    {
      organizationId: ORGANIZATION_ID,
      organizationType: KloutitOrganizationType.Technology,
      expedientNumber: 'EXPNODE0001',
      notificationDate: '2024-09-22T11:31:22.347Z',
      deadline: '2027-09-22T11:31:22.347Z',
      disputeAmount: { currency: Currencies.EUR, value: 10 },
      chargebackReason: KloutitChargebackReason.ProductServiceNotReceived,
      transactionDate: '2024-09-22T11:31:22.347Z',
      panNumber: 'PAN000001',
      transactionId: 'TR0000001',
      bankName: 'Sample bank',
      is3DSPurchase: true,
      purchaseDate: '2024-09-22T11:31:22.347Z',
      purchaseAmount: { currency: Currencies.EUR, value: 10 },

      product: 'Sample product', // Product OR service should be informed
      service: null, // Product OR service should be informed
      isChargeRefundable: true,
      shippingCity: 'Barcelona',
      shippingProvince: 'Barcelona',
      shippingPostalCode: '08000',
      shippingDate: '2024-09-22T11:31:22.347Z',
      deliveryCompany: 'Sample company',
      deliveryDate: '2024-09-22T11:31:22.347Z',
      deliveryConfirmation: true,

      customerName: 'Node SDK sample',
      customerEmail: '[email protected]',
      contactDate: '2024-09-22T11:31:22.347Z',
      customerPhone: '612345678',
      additionalInfo: 'Some optional additional info',
    },
    {
      headers: {
        Authorization: `Bearer ${accessToken}`,
      },
    },
  );
} catch (error) {
  Logger.error(
    `Error trying to create a case into Kloutit. Status code: ${error.response.data.statusCode}`,
    error.response.data.message,
  );
  throw new Error(error.response.data.message);
}

This example is made for TECHNOLOGY sector. You can find the needed body for each sector here:

Documentation

In this document, you will be able to see all the available methods and all the parameters needed, so you know exactly what you need to do. If you have any doubts, please, don't hesitate to contact us so we can help you, or leave us any comment so we can improve your experience.

Autocompletion

If you use an IDE such as VSCode, you will be able to see all the autocompletion for methods and parameters, so you know exactly what the call is expecting to receive.

Security

Kloutit SDK does not store or refresh access tokens. Storing and refreshing access tokens is responsibility of the SDK consumer.

Please, if you discover any security issues, report them to [email protected] as soon as possible.

License

Apache 2.0