Class: Amadeus::Client

Inherits:
Object
  • Object
show all
Includes:
HTTP, Pagination, Namespaces
Defined in:
lib/amadeus/client.rb,
lib/amadeus/client/http.rb,
lib/amadeus/client/decorator.rb,
lib/amadeus/client/validator.rb,
lib/amadeus/client/pagination.rb,
lib/amadeus/client/access_token.rb

Overview

The Amadeus client library for accessing the travel APIs

Defined Under Namespace

Modules: HTTP, Pagination

Constant Summary collapse

HOSTS =

The available hosts for this API

{
  test: 'test.api.amadeus.com',
  production: 'api.amadeus.com'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Namespaces

#airport, #analytics, #booking, #e_reputation, #reference_data, #safety, #shopping, #travel

Methods included from Pagination

#first, #last, #next, #previous

Methods included from HTTP

#get, #post

Constructor Details

#initialize(options = {}) ⇒ Client

Initialize using your credentials:

amadeus = Amadeus::Client.new(
  client_id:    'REPLACE_BY_YOUR_API_KEY',
  client_secret: 'REPLACE_BY_YOUR_API_SECRET'
)

Alternatively, initialize the library using the environment variables AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET

amadeus = Amadeus::Client.new

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :clientId (string)

    the API key used to authenticate the API

  • :clientSecret (string)

    the API secret used to authenticate the API

  • :logger (Object) — default: 'Logger'

    a ‘Logger`-compatible logger that accepts a debug call

  • :log_level (string) — default: 'silent'

    if this client is running in debug, warn, or silent mode

  • :hostname (string) — default: 'production'

    the name of the server API calls are made to (‘production` or `test`)

  • :custom_app_id (string) — default: null

    a custom App ID to be passed in the User Agent to the server.

  • :custom_app_version (string) — default: null

    a custom App Version number to be passed in the User Agent to the server.

  • :http (Object) — default: Net::HTTP

    an optional Node/HTTPS-compatible client that accepts a ‘request()’ call with an array of options.

  • :ssl (boolean) — default: true

    if this client is will use HTTPS



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/amadeus/client.rb', line 78

def initialize(options = {})
  initialize_client_credentials(options)
  initialize_logger(options)
  initialize_host(options)
  initialize_custom_app(options)
  initialize_http(options)

  recognized_options = %i[client_id client_secret
                          logger host hostname
                          custom_app_id custom_app_version
                          http log_level ssl port]
  warn_on_unrecognized_options(options, logger, recognized_options)
end

Instance Attribute Details

#client_idObject (readonly)

The API key used to authenticate against the API



19
20
21
# File 'lib/amadeus/client.rb', line 19

def client_id
  @client_id
end

#client_secretObject (readonly)

The API secret used to authenticate against the API



21
22
23
# File 'lib/amadeus/client.rb', line 21

def client_secret
  @client_secret
end

#custom_app_idObject (readonly)

A custom App ID to be passed in the User Agent to the server



35
36
37
# File 'lib/amadeus/client.rb', line 35

def custom_app_id
  @custom_app_id
end

#custom_app_versionObject (readonly)

A custom App version to be passed in the User Agent to the server



37
38
39
# File 'lib/amadeus/client.rb', line 37

def custom_app_version
  @custom_app_version
end

#hostObject (readonly)

The host domain used to make API calls against



29
30
31
# File 'lib/amadeus/client.rb', line 29

def host
  @host
end

#hostnameObject (readonly)

The short name of the host used to make API calls against



27
28
29
# File 'lib/amadeus/client.rb', line 27

def hostname
  @hostname
end

#httpObject (readonly)

The Net:HTTP compatible HTTP client in use



39
40
41
# File 'lib/amadeus/client.rb', line 39

def http
  @http
end

#log_levelObject (readonly)

If this client is running in debug, warn, or silent mode



25
26
27
# File 'lib/amadeus/client.rb', line 25

def log_level
  @log_level
end

#loggerObject (readonly)

The logger used to output warnings and debug messages



23
24
25
# File 'lib/amadeus/client.rb', line 23

def logger
  @logger
end

#portObject (readonly)

The port to connect to, if not the default 443



33
34
35
# File 'lib/amadeus/client.rb', line 33

def port
  @port
end

#sslObject (readonly)

Wether to use HTTPS to connect



31
32
33
# File 'lib/amadeus/client.rb', line 31

def ssl
  @ssl
end