Class: Bitly::V4::Client
- Inherits:
-
Object
- Object
- Bitly::V4::Client
- Defined in:
- lib/bitly/v4/client.rb
Overview
Bitly Client.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Client
constructor
A new instance of Client.
- #shorten(long_url, options = {}) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/bitly/v4/client.rb', line 10 def initialize(**args) @conn = Faraday.new(BASE_URI) @conn.(:Bearer, args[:access_token]) @conn.headers[:content_type] = 'application/json' end |
Instance Method Details
#shorten(long_url, options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/bitly/v4/client.rb', line 16 def shorten(long_url, = {}) body = { long_url: long_url }.merge() response = post('/v4/shorten', body.to_json) Bitly::V4::Bitlink.new(JSON.parse(response.body, symbolize_names: true)) end |