Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudbeds-qa-request

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudbeds-qa-request

A library to handle HTTP requests

  • 0.0.11
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Cloudbeds Request library

The interface to handle HTTP requests

Installing

In order to install we just need to do. If you can not download make sure that you are logging in npm with Cloudbeds credentials

npm install cloudbeds-qa-request

Initializing

After installing we need to initialize the library with the service configuration.

Example without creating a new instance:

const requestService = require('cloudbeds-qa-request');

Example creating a new instance:

const baseUrl = "http://devboxurl.com";
const cookie = true;
const requestService = require('cloudbeds-qa-request').create({ baseUrl, cookie });;

Optional example of creating with headers to be sent on each request:

const baseUrl = "http://devboxurl.com";
const cookie = true;
const clientHeaders = {Authorization: 'Bearer asdas2123asdq34'}
const requestService = require('cloudbeds-qa-request').create({ baseUrl, cookie, clientHeaders });;

Params:

baseUrl: This will be used in all the request. cookie: If you want to share cookies across the request that you will make clientHeaders: Headers that will be sent across with every request

Methods

How to use url ? - Url is and Object that has 3 properties

const url = {
  path: '/example/url'
};

const response = requestService.post({url});
  • Using this case as example a post request will be made against baseUrl + path

Let's suppose that I have a dynamic url

const url = {
  path: '/clients/:clientId',
  replacements: {
    'clientId' : 1
  }
};

const response = requestService.post({url});
  • Using this case as example a post request will be made to baseUrl + /clients/1

Let's suppose that I want to send query params

const url = {
  path: '/clients',
  queryParam: {
    'clientId' : 1,
    'propertyId' : 2
  }
};

  • Using this case as example a post request will be made to baseUrl + /clients?clientId=1&propertyId=2

get({ url, headers })

Send a get request to the specified url, with the optional headers.

If no headers are specified, these are the default ones:

  • Accept: 'application/json'
  • Accept-Language: 'en_US'
  • X-Request-Id: 'uuid'
  • User-Agent: 'Cloudbeds QA Request Library'

post({ url, payload, headers })

Send a post request to the specified url with the payload, and with the optional headers.

If no headers are specified, these are the default ones:

  • Accept: 'application/json'
  • Accept-Language: 'en_US'
  • X-Request-Id: 'uuid'
  • User-Agent: 'Cloudbeds QA Request Library'

patch({ url, payload, headers })

Send a patch request to the specified url with the payload, and with the optional headers.

If no headers are specified, these are the default ones:

  • Accept: 'application/json'
  • Accept-Language: 'en_US'
  • X-Request-Id: 'uuid'
  • User-Agent: 'Cloudbeds QA Request Library'

postFiles({ url, files, headers })

Send a multipart post request to the specified url with the files, and with the optional headers.

If no headers are specified, these are the default ones:

  • Accept: 'application/json'
  • Content-Type: 'multipart/form-data'
  • Accept-Language: 'en_US'
  • X-Request-Id: 'uuid'
  • User-Agent: 'Cloudbeds QA Request Library'

Files should be an array of objects with the properties:

  • name: name of the file being uploaded
  • path: path to the files being uploaded

delete({ url, headers })

Send a delete request to the specified url, and with the optional headers.

If no headers are specified, these are the default ones:

  • Accept: 'application/json'
  • Accept-Language: 'en_US'
  • X-Request-Id: 'uuid'
  • User-Agent: 'Cloudbeds QA Request Library'

resetCookies()

It will create a new Cookie instance, cleaning them

updateBaseUrl(baseUrl)

It will update the baseUrl

FAQs

Package last updated on 01 Feb 2021

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