Overview

1.1. Version information

Version: 1.2.0

1.2. Contact information

Contact: Airvestor

1.3. URI scheme

Host: https://ruv-airvestor-v1.p.mashape.com

BasePath: /v1 Schemes: HTTPS

1.4. Tags

  • Default: Default section
  • Airvestor Estimator: Imported from Airvestor Estimator

2. Paths

2.1. Loads a list of estimator

GET /estimators/
GET /globals/

2.1.1. Description

Loads a list of estimator

Sample Integration

https://www.airvestor.com/data/

2.1.2. Parameters

Type Name Description Required Schema Default

QueryParameter

hotel_property_count

Allows to filter the collections of result by the value of field hotel_property_count

false

string

QueryParameter

$page

Number of the page to retrieve. Integer value.

false

string

QueryParameter

airbnb_hotel_diff

Allows to filter the collections of result by the value of field airbnb_hotel_diff

false

string

QueryParameter

airbnb_avg_price_entire

Allows to filter the collections of result by the value of field airbnb_avg_price_entire

false

string

QueryParameter

appreciation_quarter

Allows to filter the collections of result by the value of field appreciation_quarter

false

string

QueryParameter

pct_fall_from_peak

Allows to filter the collections of result by the value of field pct_fall_from_peak

false

string

QueryParameter

appreciation_month

Allows to filter the collections of result by the value of field appreciation_month

false

string

QueryParameter

appreciation_5

Allows to filter the collections of result by the value of field appreciation_5

false

string

QueryParameter

country

Allows to filter the collections of result by the value of field country

false

string

QueryParameter

airbnb_avg_price_private

Allows to filter the collections of result by the value of field airbnb_avg_price_private

false

string

QueryParameter

airbnb_result_count

Allows to filter the collections of result by the value of field airbnb_result_count

false

string

QueryParameter

peak_quarter

Allows to filter the collections of result by the value of field peak_quarter

false

string

QueryParameter

occupancy_25

Allows to filter the collections of result by the value of field occupancy_25

false

string

QueryParameter

$size

Size of the page to retrieve. Integer value

false

string

QueryParameter

appreciation_10

Allows to filter the collections of result by the value of field appreciation_10

false

string

QueryParameter

value_ratio

Allows to filter the collections of result by the value of field value_ratio

false

string

QueryParameter

appreciation_year

Allows to filter the collections of result by the value of field appreciation_year

false

string

QueryParameter

city

Allows to filter the collections of result by the value of field city

false

string

QueryParameter

hotel_average

Allows to filter the collections of result by the value of field hotel_average

false

string

QueryParameter

occupancy_50

Allows to filter the collections of result by the value of field occupancy_50

false

string

QueryParameter

occupancy_100

Allows to filter the collections of result by the value of field occupancy_100

false

string

QueryParameter

zip

Allows to filter the collections of result by the value of field zip

false

string

QueryParameter

airbnb_avg_price_all

Allows to filter the collections of result by the value of field airbnb_avg_price_all

false

string

QueryParameter

peak_price

Allows to filter the collections of result by the value of field peak_price

false

string

QueryParameter

cccupancy_75

Allows to filter the collections of result by the value of field cccupancy_75

false

string

QueryParameter

$sort

Order in which to retrieve the results. Multiple sort criteria can be passed. Example: sort=age ASC,height DESC

false

string

QueryParameter

avergage_property_price

Allows to filter the collections of result by the value of field avergage_property_price

false

string

QueryParameter

address

Allows to filter the collections of result by the value of field address

false

string

QueryParameter

airbnb_avg_price_shared

Allows to filter the collections of result by the value of field airbnb_avg_price_shared

false

string

QueryParameter

search_radius

Allows to filter the collections of result by the value of field search_radius

false

string

QueryParameter

gross_income_50

Allows to filter the collections of result by the value of field gross_income_50

false

string

QueryParameter

monthly_mortgage_cost

Allows to filter the collections of result by the value of field monthly_mortgage_cost

false

string

QueryParameter

longitude

Allows to filter the collections of result by the value of field longitude

false

string

QueryParameter

latitude

Allows to filter the collections of result by the value of field latitude

false

string

QueryParameter

state

Allows to filter the collections of result by the value of field state

false

string

2.1.3. Responses

HTTP Code Description Schema

200

Success

[estimator] array

400

Error 400

No Content

2.1.4. Produces

  • application/json
  • application/x-yaml
  • application/xml
  • text/xml
## restlet Generated SDK

#### Input source
__AirEstimator - version: 1.0.0__


#### Structure

* `module.js` is the generated module containing a service
* `README` the current file

#### Usage

* Unzip the downloaded SDK into your project dependencies folder e.g.: myProject/libs/

* The module can be used directly. Considering your API in module.js with the following operations:
  * GET /estimators/{companyId} in SDK myApi
  * POST /estimators in SDK myApi


* Create a file `app.js` and inject the SDK as a dependency for your client module:

```javascript
// Declare the generated module as a dependency for your application
angular.module('appClient', [ 'restlet.myApi' ])

// Inject the services you want to use from the generated module
.controller('MainCtrl', function ($scope, $log,
                                  myApi) {

  // Configure one of the security schemes defined in the API definition. The security
  // configuration exposes one method per scheme, with the name prefixed with configure
  // and suffixed with Authentication.
  myApi.configureHttpBasicAuthentication("login", "password");

  // Get company list without config
  myApi.getCompanyList()
    .then(function (response) {
      $log.info('Get company list - Response status:' + response.status);
    })
    .catch(function (response) {
      $log.error('Get company list - Request failed with status:' + response.status);
    });

  var config = {
    params: {
      name: 'Nantes, France'
    }
  };

  // Adds a company
  var body = {
    tags: [ 'test tag' ],
    id: 'test id',
    address: {
      zipcode: 'test zipcode',
      street: 'test street',
      city: 'test city'
    },
    name: 'test name'
  };

  myApi.postCompanyList(body)
    .then(function (response) {
      $log.info('Add a company - Response status: ' + response.status);
    })
    .catch(function (response) {
      $log.error('Add a company - Request failed with status:' + response.status);
    });

  // Gets a company by ID
  var id = '00b00381-4810-11e5-b106-c598859c3466';

  myApi.getCompany(id)
    .then(function (response) {
      $log.info('Get a company by Id: ' + id + ' - Response status:' + response.status);
    })
    .catch(function (response) {
      $log.error('Get a company by Id: ' + id + ' - Request failed with status:' + response.status);
    });
```
(function () {
  'use strict';

  angular.module('restlet.sdk', []);

  angular.module('restlet.sdk')
    .service('airEstimator', ['$http', airEstimator]);

  function airEstimator ($http) {

    var endpoint = 'https://airestimator.apispark.net/v1';
    var globalSecurity = {};
    var securityConfigurations = {};

    this.setEndpoint = setEndpoint;

    this.configureBasicAuth = configureBasicAuth(globalSecurity);
    this.configureApiToken = configureApiToken(globalSecurity);
    this.configureOAuth2 = configureOAuth2(globalSecurity);

    this.configureHTTP_BASICAuthentication = configureHTTP_BASICAuthentication;

    /**
     * Loads a list of estimator
     *
     * @param config - Object describing the request to be made and how it should be processed. The object has following properties:
     * @param config.params - Map of strings or objects which will be serialized with the paramSerializer and appended as query parameters.
     {
       "latitude" : "Allows to filter the collections of result by the value of field latitude",
       "hotel_property_count" : "Allows to filter the collections of result by the value of field hotel_property_count",
       "city" : "Allows to filter the collections of result by the value of field city",
       "peak_price" : "Allows to filter the collections of result by the value of field peak_price",
       "state" : "Allows to filter the collections of result by the value of field state",
       "airbnb_avg_price_shared" : "Allows to filter the collections of result by the value of field airbnb_avg_price_shared",
       "zip" : "Allows to filter the collections of result by the value of field zip",
       "airbnb_avg_price_entire" : "Allows to filter the collections of result by the value of field airbnb_avg_price_entire",
       "$sort" : "Order in which to retrieve the results. Multiple sort criteria can be passed. Example: sort=age ASC,height DESC",
       "hotel_average" : "Allows to filter the collections of result by the value of field hotel_average",
       "peak_quarter" : "Allows to filter the collections of result by the value of field peak_quarter",
       "airbnb_hotel_diff" : "Allows to filter the collections of result by the value of field airbnb_hotel_diff",
       "appreciation_year" : "Allows to filter the collections of result by the value of field appreciation_year",
       "appreciation_10" : "Allows to filter the collections of result by the value of field appreciation_10",
       "pct_fall_from_peak" : "Allows to filter the collections of result by the value of field pct_fall_from_peak",
       "address" : "Allows to filter the collections of result by the value of field address",
       "search_radius" : "Allows to filter the collections of result by the value of field search_radius",
       "country" : "Allows to filter the collections of result by the value of field country",
       "cccupancy_75" : "Allows to filter the collections of result by the value of field cccupancy_75",
       "airbnb_result_count" : "Allows to filter the collections of result by the value of field airbnb_result_count",
       "occupancy_25" : "Allows to filter the collections of result by the value of field occupancy_25",
       "monthly_mortgage_cost" : "Allows to filter the collections of result by the value of field monthly_mortgage_cost",
       "appreciation_quarter" : "Allows to filter the collections of result by the value of field appreciation_quarter",
       "value_ratio" : "Allows to filter the collections of result by the value of field value_ratio",
       "longitude" : "Allows to filter the collections of result by the value of field longitude",
       "airbnb_avg_price_all" : "Allows to filter the collections of result by the value of field airbnb_avg_price_all",
       "appreciation_5" : "Allows to filter the collections of result by the value of field appreciation_5",
       "airbnb_avg_price_private" : "Allows to filter the collections of result by the value of field airbnb_avg_price_private",
       "$size" : "Size of the page to retrieve. Integer value",
       "avergage_property_price" : "Allows to filter the collections of result by the value of field avergage_property_price",
       "occupancy_100" : "Allows to filter the collections of result by the value of field occupancy_100",
       "$page" : "Number of the page to retrieve. Integer value.",
       "occupancy_50" : "Allows to filter the collections of result by the value of field occupancy_50",
       "appreciation_month" : "Allows to filter the collections of result by the value of field appreciation_month",
       "gross_income_50" : "Allows to filter the collections of result by the value of field gross_income_50"
     }
     * @param config.headers - Map of strings or functions which return strings representing HTTP headers to send to the server.
     *
     * @returns {HttpPromise} - a promise resolved with the response from the server.
     * In case of success (status in the 2XX range)
     *   * Status code : 200 - Payload :
     [
     {
       "address" : "Honolulu HI 96815 US",
       "airbnb_avg_price_all" : "146",
       "airbnb_avg_price_entire" : "146",
       "airbnb_avg_price_private" : "146",
       "airbnb_avg_price_shared" : "146",
       "airbnb_hotel_diff" : "-230.97",
       "airbnb_result_count" : "1205",
       "appreciation_10" : "0.02245818174",
       "appreciation_5" : "0.0584696876",
       "appreciation_month" : "0.003267973856",
       "appreciation_quarter" : "0.01751893939",
       "appreciation_year" : "0.04701583435",
       "avergage_property_price" : "sample avergage_property_price",
       "cccupancy_75" : "3330.63",
       "city" : "Honolulu",
       "country" : "US",
       "gross_income_50" : "426.88",
       "hotel_average" : "376.96",
       "hotel_property_count" : "sample hotel_property_count",
       "latitude" : "21.2700357",
       "longitude" : "-157.8182298",
       "monthly_mortgage_cost" : "1793.540517",
       "occupancy_100" : "4440.83",
       "occupancy_25" : "1110.21",
       "occupancy_50" : "3330.63",
       "pct_fall_from_peak" : "0",
       "peak_price" : "429800",
       "peak_quarter" : "2015-Q3",
       "search_radius" : "2866.960423",
       "state" : "HI",
       "value_ratio" : "0.01033232511",
       "zip" : "sample zip"
     }
     ]
     */
    this.getEstimators = function (config) {
      var url = endpoint + '/estimators/';

      return send('GET', url, addSecurityConfiguration(config, 'HTTP_BASIC'));
    };

    /**
     * Loads a estimator
     *
     * @param estimatorid - REQUIRED - Identifier of the estimator
     * @param config - Object describing the request to be made and how it should be processed. The object has following properties:
     * @param config.params - Map of strings or objects which will be serialized with the paramSerializer and appended as query parameters.
     * @param config.headers - Map of strings or functions which return strings representing HTTP headers to send to the server.
     *
     * @throws will throw an error if a required parameter is not set
     *
     * @returns {HttpPromise} - a promise resolved with the response from the server.
     * In case of success (status in the 2XX range)
     *   * Status code : 200 - Payload :
     {
       "address" : "Honolulu HI 96815 US",
       "airbnb_avg_price_all" : "146",
       "airbnb_avg_price_entire" : "146",
       "airbnb_avg_price_private" : "146",
       "airbnb_avg_price_shared" : "146",
       "airbnb_hotel_diff" : "-230.97",
       "airbnb_result_count" : "1205",
       "appreciation_10" : "0.02245818174",
       "appreciation_5" : "0.0584696876",
       "appreciation_month" : "0.003267973856",
       "appreciation_quarter" : "0.01751893939",
       "appreciation_year" : "0.04701583435",
       "avergage_property_price" : "sample avergage_property_price",
       "cccupancy_75" : "3330.63",
       "city" : "Honolulu",
       "country" : "US",
       "gross_income_50" : "426.88",
       "hotel_average" : "376.96",
       "hotel_property_count" : "sample hotel_property_count",
       "latitude" : "21.2700357",
       "longitude" : "-157.8182298",
       "monthly_mortgage_cost" : "1793.540517",
       "occupancy_100" : "4440.83",
       "occupancy_25" : "1110.21",
       "occupancy_50" : "3330.63",
       "pct_fall_from_peak" : "0",
       "peak_price" : "429800",
       "peak_quarter" : "2015-Q3",
       "search_radius" : "2866.960423",
       "state" : "HI",
       "value_ratio" : "0.01033232511",
       "zip" : "sample zip"
     }
     */
    this.getEstimatorsEstimatorid = function (estimatorid, config) {
      checkPathVariables(estimatorid, 'estimatorid');

      var url = endpoint + '/estimators/' + estimatorid + '';

      return send('GET', url, addSecurityConfiguration(config, 'HTTP_BASIC'));
    };

    function configureHTTP_BASICAuthentication(username, key) {
      securityConfigurations.HTTP_BASIC = {
        type: 'BASIC',
        token: 'Basic ' + btoa(username + ':' + key)
      };
    }

    function isNotAuthenticated (securityRequirementName) {
      return securityRequirementName === '_NONE';
    }

    /**
     * Enhances the provided request configuration with the configured
     * security requirements.
     *
     * One might notice that the security requirements are not explicitly defined
     * in the method signature. The reason is that one method might have zero,
     * one or more security requirement(s), so security requirements are recovered
     * dynamically from the `arguments`.
     *
     * The security configuration is defined as follow:
     *  - If no specific security requirements is defined for the method then:
     *    - if a global security is set the call will be authenticated
     *    - if no security is configured then the call will be unauthenticated
     *  - If a specific security requirements is defined for the method then:
     *    - one of them is configured and the first of them is used for the authentication
     *    - none of them is configured and an error is thrown
     *
     * @param {Object} config - a configuration object used inside the requests
     * which can contain among other things the headers & the params
     * @param {String...} requirement - the name of the security scheme to support
     */
    function addSecurityConfiguration (config) {
      var securityRequirements = Array.prototype.slice.call(arguments, 1);

      return securityConfigurationHelper(config, globalSecurity, 
        securityConfigurations, isNotAuthenticated, 
        securityRequirements);
    }

    /**
     * Sends a request to server.
     *
     * @param methodName - The name of method: GET, POST, PUT, DELETE
     * @param url - url
     * @param body - body
     * @param config - Object describing the request to be made and how it should be processed.
     * @returns{HttpPromise} a promise object
     */
    function send (methodName, url, config, body) {
      return sendHelper ($http, methodName, url, config, body);
    };

    /**
     * Sets a new endpoint.
     *
     * @param newEndPoint - the endpoint to be set.
     */
    function setEndpoint (newEndPoint) {
      endpoint = newEndPoint;
    }
  }

  function securityConfigurationHelper (config, globalSecurity, 
    securityConfigurations, isNotAuthenticated, 
    securityRequirements) {
    
    if (securityRequirements.length === 0) {
      return enhanceWithGlobalSecurityIfRequired(config, globalSecurity);
    }

    for (var i = 0; i < securityRequirements.length; i++) {
      var securityRequirementName = securityRequirements[i];
      var securityConfig = securityConfigurations[securityRequirementName];

      if (isNotAuthenticated(securityRequirementName)) {
        return angular.copy(config);
      } else if (angular.isDefined(securityConfig)) {
        return enhanceConfigurationWithSpecificSecurity(config, securityConfig);
      }
    }

    throw new Error('There is no configured security scheme found among: ' + securityRequirements.join(', '));
  }

  function enhanceWithGlobalSecurityIfRequired (config, globalSecurity) {
    if (!isEmpty(globalSecurity)) {
      config = angular.copy(config);
      config = enhanceConfigurationWithSpecificSecurity(config, globalSecurity);
    }

    return config;
  }

  function enhanceConfigurationWithSpecificSecurity (config, securityConfig) {
    config = angular.copy(config) || {};

    if (!config.headers) {
      config.headers = {};
    }

    if (!config.params) {
      config.params = {};
    }

    if (securityConfig.type === 'BASIC') {
      config.headers.Authorization = securityConfig.token;
    } else if (securityConfig.type === 'API_KEY' && securityConfig.placement === 'HEADER') {
      config.headers[securityConfig.name] = securityConfig.token;
    } else if (securityConfig.type === 'API_KEY' && securityConfig.placement === 'QUERY') {
      config.params[securityConfig.name] = securityConfig.token;
    } else if (securityConfig.type === 'OAUTH2') {
      config.headers.Authorization = securityConfig.token;
    } else {
      throw new Error('Cannot update config for unknown scheme');
    }

    return config;
  }

  /**
   * Validates the path variables to ensure that those are properly defined
   * since any variable defined in the path should be defined to avoid having
   * something like '/foo/undefined/bar'
   *
   * The arguments are dynamically recovered from the `arguments` object and
   * are looked for by pair where
   *   - the 2n set (even indexes) are the values
   *   - the 2n + 1 set (odd indexes) are the labels for the error reports
   */
  function checkPathVariables () {

    var errors = [];

    for (var i = 0; i < arguments.length; i += 2) {
      if (angular.isUndefined(arguments[ i ])) {
        errors.push(arguments[ i + 1 ]);
      }
    }

    if (errors.length > 0) {
      throw new Error('Missing required parameter: ' + errors.join(', '));
    }
  };

  /**
   * Sets up the authentication to be performed through basic auth.
   *
   * @param username - the user's username
   * @param password - the user's password
   */
  function configureBasicAuth (globalSecurity) {
    return function (username, password) {
      globalSecurity.type = 'BASIC';
      globalSecurity.token = 'Basic ' + btoa(username + ':' + password);
    };
  };

  /**
   * Sets up the authentication to be performed through oAuth2 protocol
   * meaning that the Authorization header will contain a Bearer token.
   *
   * @param token - the oAuth token to use
   */
  function configureOAuth2 (globalSecurity) {
    return function (token) {
      globalSecurity.type = 'OAUTH2';
      globalSecurity.token = 'Bearer ' + token;
    };
  };

  /**
   * Sets up the authentication to be performed through API token.
   *
   * @param tokenName - the name of the query parameter or header based on the location parameter.
   * @param tokenValue - the value of the token.
   * @param location - the location of the token, either header or query.
   */
  function configureApiToken (globalSecurity) {
    return function (tokenName, tokenValue, location) {
      if (angular.isUndefined(location)) {
        location = 'header';
      }

      if (location !== 'header' && location !== 'query') {
        throw new Error('Unknown location: ' + location);
      }

      globalSecurity.type = 'API_KEY';
      globalSecurity.placement = location;
      globalSecurity.name = tokenName;
      globalSecurity.token = tokenValue;
    };
  };

  /**
   * Sends a request to server.
   *
   * @param $http - the angular $http provider
   * @param methodName - The name of method: GET, POST, PUT, DELETE
   * @param url - url
   * @param body - body
   * @param config - Object describing the request to be made and how it should be processed.
   * @returns{HttpPromise} a promise object
   */
  function sendHelper ($http, methodName, url, config, body) {

    config = config || {};

    return $http({
      method: methodName,
      url: url,
      params: angular.extend({}, config.params),
      data: body,
      headers: angular.extend({}, config.headers)
    });
  };

  function isEmpty (obj) {
    return Object.keys(obj).length === 0;
  }

})();
[
  {
    "zip": "10001",
    "city": "New York",
    "state": "NY",
    "country": "US",
    "address": "New York NY 10001 US ",
    "latitude": "40.7536854",
    "longitude": "-73.9991637",
    "airbnb_avg_price_all": "211",
    "airbnb_avg_price_entire": null,
    "airbnb_avg_price_private": null,
    "airbnb_avg_price_shared": null,
    "occupancy_100": "6417.92",
    "cccupancy_75": "4813.44",
    "occupancy_50": "3208.96",
    "occupancy_25": "1604.48",
    "airbnb_result_count": "1218",
    "search_radius": "970.5827018",
    "value_ratio": "0.002468904276",
    "avergage_property_price": "2599500",
    "monthly_mortgage_cost": "10847.62348",
    "gross_income_50": "-7638.67",
    "appreciation_month": "0.01535036325",
    "appreciation_quarter": "0.06349466105",
    "appreciation_year": "0.2135854342",
    "appreciation_5": "0.1243053005",
    "appreciation_10": "0.06948750683",
    "pct_fall_from_peak": "0",
    "peak_price": "0",
    "peak_quarter": "0",
    "hotel_average": "365.06",
    "hotel_property_count": "546",
    "airbnb_hotel_diff": "-154.06"
  }
]