<commit_before># TravelPayouts API

[![Gem Version](http://img.shields.io/gem/v/travelpayouts_api.svg)][gem]

[gem]: https://rubygems.org/gems/travelpayouts_api

** This gem supports `ruby 2.2` and above. It won't work on earlier ruby versions due to extensive use of positional parameters.

## Overview

This gem supports

 * Data Access API ( http://support.travelpayouts.com/hc/ru/articles/203956163 )
 * Map API ( http://support.travelpayouts.com/hc/ru/articles/203755406 )
 * Calendar API ( http://support.travelpayouts.com/hc/ru/articles/203972143 )
 * Flights API ( http://support.travelpayouts.com/hc/ru/articles/203956173 )
 * Hotels API ( http://support.travelpayouts.com/hc/ru/articles/203956133 )

 ## How to use

 Include it in your `Gemfile`:

 ```ruby
 gem 'travelpayouts_api'
 ```

 Create an initializer in config/initializers:

 ```ruby
 # config/initializers/travelpayouts_api.rb
 TravelPayouts.configure do |config|
   config.token = '<token>'
   config.marker = '<marker>'
   config.host = 'localhost'
   config.currency = 'rub'
   config.locale = 'en'
 end
 ```

where

 * `token` - your api token
 * `marker` - your client id in travelpayouts system
 * `currency` - currency 3-digit code
 * `host` - should be set to your site host
 * `locale` - language of results


And now in your controller you can do something like this:

```ruby
@api = TravelPayouts.api
prices = @api.cheap_prices(origin: 'ODS', destination: 'MOW', depart_date: '2015-04-01')
```

All API calls will return hash objects or raise exceptions on failure.

## Data Access API

```ruby
cheap_prices(origin:, destination:, depart_date: nil, return_date: nil)
```

```ruby
direct_prices(origin:, destination:, depart_date: nil, return_date: nil)
```

```ruby
calendar_prices(origin:, destination:, calendar_type:, depart_date: nil, trip_duration: nil, return_date: nil)
```

```ruby
airline_directions(airline_code:, limit: 10)
```

```ruby
countries_data()
```

```ruby
cities_data()
```

```ruby
airports_data()
```

```ruby
airlines_data()
```

```ruby
airline_alliances_data()
```

```ruby
planes_data()
```

```ruby
routes_data()
```

```ruby
where_am_i(ip: nil, locale: nil)
```

## Map API

```ruby
map_of_supported_directions(origin_iata:, one_way: true, locale: nil)
```

```ruby
map_of_prices(origin_iata:, period: :month, one_way: true, direct: false,
    price: nil, no_visa: true, schengen: nil, need_visa: true, locale: nil,
    min_trip_duration_in_days: nil, max_trip_duration_in_days: nil)
```

## Flights API

```ruby
flight_search(user_ip:,locale: nil, trip_class: 'Y', passengers: {}, segments: {}, know_english: true)
```

```ruby
flight_search_link(search_id:, terms_url:)
```

```ruby
flight_search_results(search_id:)
```

```ruby
autocomplete_places(term:, locale: nil)
```

## Hotels API

```ruby
hotel_lookup(query:, lang: nil, look_for: nil, limit: 10, convert_case: true)
```<commit_msg>updated readme: added calendar api calls<commit_after># TravelPayouts API

[![Gem Version](http://img.shields.io/gem/v/travelpayouts_api.svg)][gem]

[gem]: https://rubygems.org/gems/travelpayouts_api

** This gem supports `ruby 2.2` and above. It won't work on earlier ruby versions due to extensive use of positional parameters.

## Overview

This gem supports

 * Data Access API ( http://support.travelpayouts.com/hc/ru/articles/203956163 )
 * Map API ( http://support.travelpayouts.com/hc/ru/articles/203755406 )
 * Calendar API ( http://support.travelpayouts.com/hc/ru/articles/203972143 )
 * Flights API ( http://support.travelpayouts.com/hc/ru/articles/203956173 )
 * Hotels API ( http://support.travelpayouts.com/hc/ru/articles/203956133 )

 ## How to use

 Include it in your `Gemfile`:

 ```ruby
 gem 'travelpayouts_api'
 ```

 Create an initializer in config/initializers:

 ```ruby
 # config/initializers/travelpayouts_api.rb
 TravelPayouts.configure do |config|
   config.token = '<token>'
   config.marker = '<marker>'
   config.host = 'localhost'
   config.currency = 'rub'
   config.locale = 'en'
 end
 ```

where

 * `token` - your api token
 * `marker` - your client id in travelpayouts system
 * `currency` - currency 3-digit code
 * `host` - should be set to your site host
 * `locale` - language of results


And now in your controller you can do something like this:

```ruby
@api = TravelPayouts.api
prices = @api.cheap_prices(origin: 'ODS', destination: 'MOW', depart_date: '2015-04-01')
```

All API calls will return hash objects or raise exceptions on failure.

## Data Access API

```ruby
cheap_prices(origin:, destination:, depart_date: nil, return_date: nil)
```

```ruby
direct_prices(origin:, destination:, depart_date: nil, return_date: nil)
```

```ruby
calendar_prices(origin:, destination:, calendar_type:, depart_date: nil, trip_duration: nil, return_date: nil)
```

```ruby
airline_directions(airline_code:, limit: 10)
```

```ruby
countries_data()
```

```ruby
cities_data()
```

```ruby
airports_data()
```

```ruby
airlines_data()
```

```ruby
airline_alliances_data()
```

```ruby
planes_data()
```

```ruby
routes_data()
```

```ruby
where_am_i(ip: nil, locale: nil)
```

## Map API

```ruby
map_of_supported_directions(origin_iata:, one_way: true, locale: nil)
```

```ruby
map_of_prices(origin_iata:, period: :month, one_way: true, direct: false,
    price: nil, no_visa: true, schengen: nil, need_visa: true, locale: nil,
    min_trip_duration_in_days: nil, max_trip_duration_in_days: nil)
```

## Calendar API

```ruby
calendar_of_prices(origin:, destination:, depart_date:, one_way:true)
```

## Flights API

```ruby
flight_search(user_ip:,locale: nil, trip_class: 'Y', passengers: {}, segments: {}, know_english: true)
```

```ruby
flight_search_link(search_id:, terms_url:)
```

```ruby
flight_search_results(search_id:)
```

```ruby
autocomplete_places(term:, locale: nil)
```

## Hotels API

```ruby
hotel_lookup(query:, lang: nil, look_for: nil, limit: 10, convert_case: true)
```
{'fraction_non_alphanumeric': 0.1559185047987877, 'fraction_numerical': 0.020205421788179828, 'mean_word_length': 5.11740473738414, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1388426', 'n_tokens_mistral': 2362, 'n_tokens_neox': 2085, 'n_words': 518}