Class: Crest::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/crest/connection.rb

Overview

A HTTP or HTTPS connection to EVE's Carbon REST API

Constant Summary collapse

CREST_PUBLIC_ENDPOINT =
'https://public-crest.eveonline.com'
CREST_AUTHED_ENDPOINT =
'https://crest-tq.eveonline.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Connection

Returns a new instance of Connection.

Parameters:

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

    Configuration options for a new CREST API connection

  • debug (Hash)

    a customizable set of options

Options Hash (config):

  • :endpoint (String) — default: CREST_PUBLIC_ENDPOINT

    URL of CREST API endpoint to connect to


15
16
17
18
19
20
21
# File 'lib/crest/connection.rb', line 15

def initialize(config = {})
  @configuration = {
    endpoint: CREST_PUBLIC_ENDPOINT
  }.merge(config)

  @connection = Excon.new(@configuration[:endpoint])
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration


9
10
11
# File 'lib/crest/connection.rb', line 9

def configuration
  @configuration
end

Instance Method Details

#get(path:, headers: {}, query: {}) ⇒ Object

Parameters:

  • path (String)

    Request path

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

    HTTP request headers

  • query (Hash{String, Symbol => String}) (defaults to: {})

    Query string


26
27
28
29
30
31
32
# File 'lib/crest/connection.rb', line 26

def get(path:, headers: {}, query: {})
  Crest::Response.from_excon @connection.get(
    path: path,
    headers: headers,
    query: query
  )
end

#inspectObject


35
36
37
# File 'lib/crest/connection.rb', line 35

def inspect
  format('<%s endpoint="%s">', self.class.name, @configuration[:endpoint])
end