Class: Typeform::Connection

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

Instance Method Summary collapse

Constructor Details

#initializeConnection

Create a Connection object.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/typeform/connection.rb', line 6

def initialize
  @typeform_token = Typeform.typeform_token
  @api_base_uri = Configuration::DEFAULT_API_BASE_URI
  @headers = { user_agent: Configuration::DEFAULT_USER_AGENT }
  @connection = Faraday.new(url: @api_base_uri, headers: @headers) do |faraday|
    # faraday.request :multipart
    faraday.request :url_encoded
    faraday.response :logger if Typeform.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.



49
50
51
# File 'lib/typeform/connection.rb', line 49

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.



21
22
23
# File 'lib/typeform/connection.rb', line 21

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

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

Perform a patch request.

Parameters:

  • path (String)

    The path at which to make ther request.

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

    A hash of request parameters.



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

def patch(path, params = {})
  request(:patch, 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.



42
43
44
# File 'lib/typeform/connection.rb', line 42

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.



28
29
30
# File 'lib/typeform/connection.rb', line 28

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