Class: Formstack::Connection

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

Constant Summary collapse

BASE_URI =
URI('https://www.formstack.com/api/v2/').freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri: BASE_URI, access_token: ENV['FORMSTACK_ACCESS_TOKEN']) ⇒ Connection

Returns a new instance of Connection.



11
12
13
14
# File 'lib/formstack/connection.rb', line 11

def initialize(base_uri: BASE_URI, access_token: ENV['FORMSTACK_ACCESS_TOKEN'])
  @base_uri = URI(base_uri)
  @access_token = access_token
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



7
8
9
# File 'lib/formstack/connection.rb', line 7

def access_token
  @access_token
end

#base_uriObject (readonly)

Returns the value of attribute base_uri.



7
8
9
# File 'lib/formstack/connection.rb', line 7

def base_uri
  @base_uri
end

Instance Method Details

#delete(uri, args = {}) ⇒ Object



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

def delete(uri, args={})
  request(uri: uri, request_factory: Net::HTTP::Delete, args: args)
end

#get(uri, args = {}) ⇒ Object



16
17
18
# File 'lib/formstack/connection.rb', line 16

def get(uri, args={})
  request(uri: uri, request_factory: Net::HTTP::Get, args: args)
end

#post(uri, args = {}) ⇒ Object



20
21
22
# File 'lib/formstack/connection.rb', line 20

def post(uri, args={})
  request(uri: uri, request_factory: Net::HTTP::Post, args: args)
end

#put(uri, args = {}) ⇒ Object



24
25
26
# File 'lib/formstack/connection.rb', line 24

def put(uri, args={})
  request(uri: uri, request_factory: Net::HTTP::Put, args: args)
end