Class: PdfServices::Api
- Inherits:
-
Object
- Object
- PdfServices::Api
- Defined in:
- lib/pdfservices/api.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #delete(url, headers: {}) ⇒ Object
- #get(url, headers: {}) ⇒ Object
-
#initialize(access_token = nil, client_id = nil) ⇒ Api
constructor
A new instance of Api.
- #post(url, body:, headers: {}) ⇒ Object
- #put(url, body:, headers: {}) ⇒ Object
Constructor Details
#initialize(access_token = nil, client_id = nil) ⇒ Api
Returns a new instance of Api.
7 8 9 10 11 12 13 14 15 |
# File 'lib/pdfservices/api.rb', line 7 def initialize(access_token = nil, client_id = nil) @access_token = access_token @client_id = client_id @connection = Faraday.new do |conn| conn.request :url_encoded conn.adapter Faraday.default_adapter end end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/pdfservices/api.rb', line 5 def access_token @access_token end |
Instance Method Details
#delete(url, headers: {}) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/pdfservices/api.rb', line 38 def delete(url, headers: {}) response = @connection.delete(url) do |req| build_request(req, headers, nil) end handle_response(response) end |
#get(url, headers: {}) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/pdfservices/api.rb', line 24 def get(url, headers: {}) response = @connection.get(url) do |req| build_request(req, headers, nil) end handle_response(response) end |
#post(url, body:, headers: {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/pdfservices/api.rb', line 17 def post(url, body:, headers: {}) response = @connection.post(url) do |req| build_request(req, headers, body) end handle_response(response) end |
#put(url, body:, headers: {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/pdfservices/api.rb', line 31 def put(url, body:, headers: {}) response = @connection.put(url) do |req| build_request(req, headers, body) end handle_response(response) end |