Class: Bitly::Client::Connection
- Inherits:
-
Object
- Object
- Bitly::Client::Connection
- Defined in:
- lib/bitly/client/connection.rb
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#long_url ⇒ Object
Returns the value of attribute long_url.
Instance Method Summary collapse
-
#initialize(long_url, api_token = nil, api_url = nil) ⇒ Connection
constructor
A new instance of Connection.
- #shorten ⇒ Object
Constructor Details
#initialize(long_url, api_token = nil, api_url = nil) ⇒ Connection
Returns a new instance of Connection.
11 12 13 14 15 |
# File 'lib/bitly/client/connection.rb', line 11 def initialize(long_url, api_token = nil, api_url = nil) @api_token = api_token || Bitly::Client.configuration.api_token @api_url = api_url || Bitly::Client.configuration.api_url @long_url = long_url end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
7 8 9 |
# File 'lib/bitly/client/connection.rb', line 7 def api_token @api_token end |
#api_url ⇒ Object
Returns the value of attribute api_url.
8 9 10 |
# File 'lib/bitly/client/connection.rb', line 8 def api_url @api_url end |
#long_url ⇒ Object
Returns the value of attribute long_url.
9 10 11 |
# File 'lib/bitly/client/connection.rb', line 9 def long_url @long_url end |
Instance Method Details
#shorten ⇒ Object
17 18 19 20 21 22 |
# File 'lib/bitly/client/connection.rb', line 17 def shorten @response = HTTParty.post(api_url, headers: headers, body: body) if !@response.nil? && @response.success? @response["link"] end end |