Class: Formstack::Connection
- Inherits:
-
Object
- Object
- Formstack::Connection
- Defined in:
- lib/formstack/connection.rb
Constant Summary collapse
- BASE_URI =
URI('https://www.formstack.com/api/v2/').freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
Instance Method Summary collapse
- #delete(uri, args = {}) ⇒ Object
- #get(uri, args = {}) ⇒ Object
-
#initialize(base_uri: BASE_URI, access_token: ENV['FORMSTACK_ACCESS_TOKEN']) ⇒ Connection
constructor
A new instance of Connection.
- #post(uri, args = {}) ⇒ Object
- #put(uri, args = {}) ⇒ Object
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_token ⇒ Object (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_uri ⇒ Object (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 |