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

fns-api

v1.0.8

Published

Methods of working with FNS API

Downloads

29

Readme

fns-api npm version npm version

Methods of working with FNS API.

Installation

npm install fns-api axios

Usage

// App.js
import axios from 'axios';
import * as fns from 'fns-api';

const axiosInstance = axios.create({
  baseURL: fns.BASE_URL,
  headers: fns.defaultHeaders
});
const receiptApi = new fns.ReceiptApi(axiosInstance, '<your session id>');

receiptApi
  .addReceiptQR({ qr: '<your qr data scanned from the receipt>' })
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

Example

Create LoginApi instance to work with login

import axios from 'axios';
import * as fns from 'fns-api';

const axiosInstance = axios.create({
  baseURL: fns.BASE_URL,
  headers: fns.defaultHeaders
});
const loginApi = new fns.LoginApi(axiosInstance);

Create ReceiptApi instance to work with receipts

import axios from 'axios';
import * as fns from 'fns-api';

// Get session id from login response
const sessionId = '<your session id>';

const axiosInstance = axios.create({
  baseURL: fns.BASE_URL,
  headers: fns.defaultHeaders
});
const receiptApi = new fns.ReceiptApi(axiosInstance, sessionId);

Session id you will receive after logging in any chosen way.

Login with the same credentials as on the site lkfl2.nalog.ru

// Your INN from https://lkfl2.nalog.ru
const inn = '<your inn>';
// Your password from https://lkfl2.nalog.ru
const password = '<your password>';
// Client secret
const clientSecret = '<client secret>';

loginApi
  .loginLKFL({ inn, password, client_secret: clientSecret })
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

To get information about a receipt, you must first add it

// Your receipt data
const fiscalData: fns.FiscalData = {
  date: '2021-06-14T14:32',
  operationType: 1,
  sum: 43600,
  fsId: '9982450301247855',
  documentId: 65724,
  fiscalSign: '7634185632'
};

receiptApi
  .addReceipt({ fiscalData, sendToEmail: false })
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

A receipt can be added according to the data from the QR-code

// QR-data string from the receipt
const qr = '<your qr data scanned from the receipt>';

receiptApi
  .addReceiptQR({ qr })
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

After adding, we can get detailed information about the receipt

// Get receipt id after call add receipt api
const receiptId = '<your receipt id>';

// Periodically make requests,
// until you get the ReceiptStatus.NPD_FOUND or ReceiptStatus.HAVE_COPY status.
receiptApi
  .getReceipt(receiptId)
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

More information about receipt status.

Get a list of all added receipts

receiptApi
  .getReceipts()
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

Remove a receipt from the list of added

// Receipt id
const receiptId = '<your receipt id>';

receiptApi
  .removeReceipt(receiptId)
  .then((response) => console.log(response.status))
  .catch((e) => console.error(e));

Refresh session id and refresh token

// Get refresh token from login response
const refreshToken = '<your refresh token>';
// Client secret
const clientSecret = '<client secret>';

loginApi
  .refreshTokens({ refresh_token: refreshToken, client_secret: clientSecret })
  .then((response) => console.log(response.data))
  .catch((e) => console.error(e));

API Specification

Read API specification for full information.

Translations:

License

Licensed under the MIT License.