Method: Bitly::API::Bitlink.create

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

.create(client:, long_url:, domain: nil, group_guid: nil, title: nil, tags: nil, deeplinks: nil) ⇒ Bitly::API::Bitlink

Creates a new Bitlink from a long URL. Similar to #shorten but takes more parameters. [‘POST /v4/bitlinks`](dev.bitly.com/v4/#operation/createFullBitlink)

Examples:

bitlink = Bitly::API::Bitlink.create(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

  • title (String) (defaults to: nil)

    A descriptive title for the link

  • tags (Array<String>) (defaults to: nil)

    Some tags for the Bitlink

  • deeplinks (Array<Bitly::API::Bitlink::Deeplink>) (defaults to: nil)

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bitly/api/bitlink.rb', line 66

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