Class: Pdftable::Connection
- Inherits:
-
Object
- Object
- Pdftable::Connection
- Defined in:
- lib/pdftable/connection.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #post(path, file:, format:) ⇒ Object
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
6 7 8 |
# File 'lib/pdftable/connection.rb', line 6 def initialize @configuration = Pdftable::Configuration.instance end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/pdftable/connection.rb', line 4 def configuration @configuration end |
Instance Method Details
#get(path) ⇒ Object
10 11 12 13 14 |
# File 'lib/pdftable/connection.rb', line 10 def get (path) opt = { key: configuration.key } res = RestClient.get url(path, opt) parse_response(res) end |
#post(path, file:, format:) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pdftable/connection.rb', line 16 def post (path, file:, format:) opt = { key: configuration.key, format: format } res = RestClient.post url(path, opt), file: File.new(file, 'rb') parse_response(res) #req = RestClient::Request.new method: :post, url: uri, payload: { multipart: true, file: File.new("pdf_table.pdf", 'rb')}, headers: {params: {key: 'abcde', format: "xml"}} #response = req.execute end |