Socket
Socket
Sign inDemoInstall

israel-postal-service-api

Package Overview
Dependencies
9
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    israel-postal-service-api

Israel postal office pricing calculator


Version published
Maintainers
1
Install size
355 kB
Created

Readme

Source

IsraelPostalServiceAPI

An API for Israel postal service - query shipment price easily.

licence npm version github version

Installation

npm install --save israel-postal-service-api

Usage

Import library:

const Options = require('israel-postal-service-api').Options;
const IPS = require('israel-postal-service-api').IPS;

- or -

import { IPS, Options } from 'israel-postal-service-api';

Define Package Characteristics:

// define package characteristics
let weightInGrams = 20;
let serviceType = Options.AbroadMailOptions.LETTER.shipmentType;
let serviceSubtype = Options.AbroadMailOptions.LETTER.shipmentSubtypes.regular;
let option = serviceSubtype.options.signed;

// initialize service
let ips = new IPS();

Calculate Shipping Rate:

Option 1: with promises
// calculate package shipping rate asynchronously
ips.calculateAbroadShippingRate("Spain", weightInGrams, serviceType, serviceSubtype, option).then((response) => {
    console.log(response.getTotalPrice());  // see {@class ResponseParser} API to discover all the available data
}).catch((error) => {
    console.error('Error:', error);
});
Option 2: with async await
// calculate package shipping rate asynchronously
calculatePrice = async () => {
    try {
        const response = await ips.calculateAbroadShippingRate("Spain", weightInGrams, serviceType, serviceSubtype, option);
        console.log(response.getTotalPrice());
    } catch (error) {
        console.error('Error:', error);
    }
}

// invoke function
calculatePrice();

Documentation

Support

If you're having any problem, please raise an issue on GitHub and we'll be happy to help.

Contribute

Before submitting a pull request, please make sure that you include tests, and that jshint runs without any warnings: Download VSCode extension.

Test

Run the test suite by executing:

$ npm test

Note: This API was create as an open source service for makers and entrepreneurs. This is not an official API for Israel Post service.

Author: Benny Megidish.

Keywords

FAQs

Last updated on 16 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc