New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@karhoo/demand-bloc-quotes

Package Overview
Dependencies
Maintainers
5
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@karhoo/demand-bloc-quotes

BLoC to work with Karhoo Quotes API

  • 20.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-93.75%
Maintainers
5
Weekly downloads
 
Created
Source
Karhoo logo

demand-bloc-quotes

BLoC to work with Karhoo Quotes API


License

Installation

npm i @karhoo/demand-bloc-quotes

Usage


import { getApi } from '@karhoo/demand-api'
import { QuotesBloc } from '@karhoo/demand-bloc-quotes'

const api = getApi({
  url: 'api',
  defaultRequestOptionsGetter: () => ({
    headers: {
      identifier: 'XXXX',
      referrer: 'https://example-referer.com/'
    }
  })
})

/*
* The latitude in degrees. It must be in the range [-90.0, +90.0], with at least 4  decimal digits of precision.
* The longitude in degrees. It must be in the range [-180.0, +180.0], with at least 4  decimal digits of precision.
*/
const quotesSearchParams = {
  origin: {
    latitude: '51.501364',
    longitude: '-0.14189',
    displayAddress: 'Buckingham Palace, London SW1A 1AA',
  },
  destination: {
    latitude: '41.78650',
    longitude: '1.78954',
    displayAddress: 'Big Ben, Westminster, London SW1A 0AA, UK',
  },
  localTimeOfPickup: "2020-05-20T12:00"
}

/*
* quotesService use quotes V1 API which is depricated. Use quotesV2Service instead
*/
const quotesBloc = new QuotesBloc(api.quotesV2Service)

quotesBloc.filters = {
  numOfLuggage: 2,
  numOfPassengers: 2,
}

quotesBloc.matchingQuotes.subscribe((data) => {
  // quotes that accepts 2 passengers and 2 bags
  console.log('Matching quotes', data)
})

quotesBloc.otherAvailibleQuotes.subscribe((data) => {
  // all other quotes that did not match filters
  console.log('Other quotes', data)
})

quotesBloc.loading.subscribe(isLoading => {
  console.log('isLoading', isLoading)
})

quotesBloc.quotesExpired.subscribe(() => {
  console.log('Quotes Expired')

  quotesBloc.refreshQuotes() // requests quotes with same search params
})

quotesBloc.requestQuotes(quotesSearchParams)

Keywords

FAQs

Package last updated on 17 Jan 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc