Class: Sendly::ShortLink

Inherits:
Object
  • Object
show all
Defined in:
lib/sendly/links_resource.rb

Overview

A newly minted branded short link, as returned by LinksResource#create.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ShortLink

Returns a new instance of ShortLink.



18
19
20
21
22
23
# File 'lib/sendly/links_resource.rb', line 18

def initialize(data)
  @raw = data
  @code = data["code"]
  @short_url = data["shortUrl"] || data["short_url"]
  @destination_url = data["destinationUrl"] || data["destination_url"]
end

Instance Attribute Details

#codeString (readonly)

Returns Short code (the segment after the domain, e.g. "Ab3xY7").

Returns:

  • (String)

    Short code (the segment after the domain, e.g. "Ab3xY7")



7
8
9
# File 'lib/sendly/links_resource.rb', line 7

def code
  @code
end

#destination_urlString (readonly)

Returns The destination the short link redirects to.

Returns:

  • (String)

    The destination the short link redirects to



13
14
15
# File 'lib/sendly/links_resource.rb', line 13

def destination_url
  @destination_url
end

#rawHash (readonly)

Returns The raw parsed response.

Returns:

  • (Hash)

    The raw parsed response



16
17
18
# File 'lib/sendly/links_resource.rb', line 16

def raw
  @raw
end

#short_urlString (readonly)

Returns Full branded short URL to share (e.g. "https://sendly.live/l/Ab3xY7").

Returns:



10
11
12
# File 'lib/sendly/links_resource.rb', line 10

def short_url
  @short_url
end

Instance Method Details

#to_hObject



25
26
27
28
29
# File 'lib/sendly/links_resource.rb', line 25

def to_h
  {
    code: code, short_url: short_url, destination_url: destination_url
  }.compact
end