Method: Bitly::API::Bitlink.shorten

Defined in:
lib/bitly/api/bitlink.rb

.shorten(client:, long_url:, domain: nil, group_guid: nil) ⇒ Bitly::API::Bitlink

Shortens a long url. [‘POST /v4/shorten`](dev.bitly.com/v4/#operation/createBitlink)

Examples:

bitlink = Bitly::API::Bitlink.shorten(client: client, long_url: long_url)

Parameters:

  • client (Bitly::API::Client)

    An authorized API client

  • long_url (String)

    A long URL that you want shortened

  • domain (String) (defaults to: nil)

    The bitly domain you want to shorten, API default is “bit.ly”

  • group_guid (String) (defaults to: nil)

    The GUID of the group for which you want to shorten this URL

Returns:



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bitly/api/bitlink.rb', line 35

def self.shorten(client:, long_url:, domain: nil, group_guid: nil)
  response = client.request(
    path: "/shorten",
    method: "POST",
    params: {
      "long_url" => long_url,
      "domain" => domain,
      "group_guid" => group_guid
    })
  new(data: response.body, client: client, response: response)
end