Class: Sendly::ShortLink
- Inherits:
-
Object
- Object
- Sendly::ShortLink
- Defined in:
- lib/sendly/links_resource.rb
Overview
A newly minted branded short link, as returned by LinksResource#create.
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
Short code (the segment after the domain, e.g. "Ab3xY7").
-
#destination_url ⇒ String
readonly
The destination the short link redirects to.
-
#raw ⇒ Hash
readonly
The raw parsed response.
-
#short_url ⇒ String
readonly
Full branded short URL to share (e.g. "https://sendly.live/l/Ab3xY7").
Instance Method Summary collapse
-
#initialize(data) ⇒ ShortLink
constructor
A new instance of ShortLink.
- #to_h ⇒ Object
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
#code ⇒ String (readonly)
Returns 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_url ⇒ String (readonly)
Returns The destination the short link redirects to.
13 14 15 |
# File 'lib/sendly/links_resource.rb', line 13 def destination_url @destination_url end |
#raw ⇒ Hash (readonly)
Returns The raw parsed response.
16 17 18 |
# File 'lib/sendly/links_resource.rb', line 16 def raw @raw end |
#short_url ⇒ String (readonly)
Returns Full branded short URL to share (e.g. "https://sendly.live/l/Ab3xY7").
10 11 12 |
# File 'lib/sendly/links_resource.rb', line 10 def short_url @short_url end |
Instance Method Details
#to_h ⇒ Object
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 |