Class: Naver::Connection

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

Constant Summary collapse

DEFAULT_API_BASE_URI =

Base URI for the NAVER API..

"https://openapi.naver.com"

Instance Method Summary collapse

Constructor Details

#initialize(api_base_uri: DEFAULT_API_BASE_URI) ⇒ Connection

Create a Connection object.

Parameters:

  • api_base_uri (String)

    Base URI at which to make API calls.


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/naver/connection.rb', line 8

def initialize(api_base_uri: DEFAULT_API_BASE_URI)
  @client_id     = Naver.client_id
  @client_secret = Naver.client_secret
  @api_base_uri  = api_base_uri

  headers = { user_agent: "NAVER Ruby SDK Gem #{ Naver::Sdk::VERSION}" }
  @connection = Faraday.new(url: @api_base_uri, headers: headers) do |faraday|
    faraday.request :multipart
    faraday.request :url_encoded
    faraday.response :logger if Naver.debug
    faraday.adapter :net_http
  end
end

Instance Method Details

#delete(path, params = {}) ⇒ Object

Perform a DELETE request.

Parameters:

  • path (String)

    The path at which to make ther request.

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

    A hash of request parameters.


46
47
48
# File 'lib/naver/connection.rb', line 46

def delete(path, params = {})
  request(:delete, path, params)
end

#get(path, params = {}) ⇒ Object

Perform a GET request.

Parameters:

  • path (String)

    The path at which to make ther request.

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

    A hash of request parameters.


25
26
27
# File 'lib/naver/connection.rb', line 25

def get(path, params = {})
  request(:get, path, params)
end

#post(path, params = {}) ⇒ Object

Perform a POST request.

Parameters:

  • path (String)

    The path at which to make ther request.

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

    A hash of request parameters.


39
40
41
# File 'lib/naver/connection.rb', line 39

def post(path, params = {})
  request(:post, path, params)
end

#put(path, params = {}) ⇒ Object

Perform a PUT request.

Parameters:

  • path (String)

    The path at which to make ther request.

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

    A hash of request parameters.


32
33
34
# File 'lib/naver/connection.rb', line 32

def put(path, params = {})
  request(:put, path, params)
end