travelhubapi/travelhubapi-node-sdk

View on GitHub
src/client/TravelhubApiSDK.js

Summary

Maintainability
A
0 mins
Test Coverage
import TravelhubApiSDKHotel from '../hotel/TravelhubApiSDKHotel';
import TravelhubApiSDKOAuth from '../oauth/TravelhubApiSDKOAuth';

export default class TravelhubApiSDK {

  constructor(settings) {
    this.oauth = new TravelhubApiSDKOAuth(settings);
    this.hotel = new TravelhubApiSDKHotel(settings, this.oauth);
  }

  request(method, uri, options = {}) {
    const opts = {
      uri,
      method,
    };
    Object.assign(opts, options);
    return this.oauth.request(opts);
  }

  get(uri, options) {
    return this.request('GET', uri, options);
  }

  post(uri, options) {
    return this.request('POST', uri, options);
  }

  del(uri, options) {
    return this.request('DELETE', uri, options);
  }
}