Class: Sendly::ShortLinkListItem
- Inherits:
-
Object
- Object
- Sendly::ShortLinkListItem
- Defined in:
- lib/sendly/links_resource.rb
Overview
A short link with click analytics, as returned by LinksResource#list.
Instance Attribute Summary collapse
-
#brand_slug ⇒ Object
readonly
Returns the value of attribute brand_slug.
-
#click_count ⇒ Object
readonly
Returns the value of attribute click_count.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#destination_url ⇒ Object
readonly
Returns the value of attribute destination_url.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#last_clicked_at ⇒ Object
readonly
Returns the value of attribute last_clicked_at.
-
#last_country ⇒ Object
readonly
Returns the value of attribute last_country.
-
#short_url ⇒ Object
readonly
Returns the value of attribute short_url.
-
#spark ⇒ Object
readonly
Returns the value of attribute spark.
Instance Method Summary collapse
-
#disabled? ⇒ Boolean
Whether the link is disabled (its redirect returns 404).
-
#initialize(data) ⇒ ShortLinkListItem
constructor
A new instance of ShortLinkListItem.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ ShortLinkListItem
Returns a new instance of ShortLinkListItem.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sendly/links_resource.rb', line 37 def initialize(data) @code = data["code"] @short_url = data["shortUrl"] || data["short_url"] @destination_url = data["destinationUrl"] || data["destination_url"] @brand_slug = data["brandSlug"] || data["brand_slug"] @click_count = data["clickCount"] || data["click_count"] || 0 @disabled = data["disabled"] || false @last_country = data["lastCountry"] || data["last_country"] @last_clicked_at = parse_time(data["lastClickedAt"] || data["last_clicked_at"]) @created_at = parse_time(data["createdAt"] || data["created_at"]) # 14-day daily click histogram, oldest first (today last) @spark = data["spark"] || [] end |
Instance Attribute Details
#brand_slug ⇒ Object (readonly)
Returns the value of attribute brand_slug.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def brand_slug @brand_slug end |
#click_count ⇒ Object (readonly)
Returns the value of attribute click_count.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def click_count @click_count end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def code @code end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def created_at @created_at end |
#destination_url ⇒ Object (readonly)
Returns the value of attribute destination_url.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def destination_url @destination_url end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def disabled @disabled end |
#last_clicked_at ⇒ Object (readonly)
Returns the value of attribute last_clicked_at.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def last_clicked_at @last_clicked_at end |
#last_country ⇒ Object (readonly)
Returns the value of attribute last_country.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def last_country @last_country end |
#short_url ⇒ Object (readonly)
Returns the value of attribute short_url.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def short_url @short_url end |
#spark ⇒ Object (readonly)
Returns the value of attribute spark.
34 35 36 |
# File 'lib/sendly/links_resource.rb', line 34 def spark @spark end |
Instance Method Details
#disabled? ⇒ Boolean
Returns Whether the link is disabled (its redirect returns 404).
52 53 54 |
# File 'lib/sendly/links_resource.rb', line 52 def disabled? disabled end |
#to_h ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/sendly/links_resource.rb', line 56 def to_h { code: code, short_url: short_url, destination_url: destination_url, brand_slug: brand_slug, click_count: click_count, disabled: disabled, last_country: last_country, last_clicked_at: last_clicked_at&.iso8601, created_at: created_at&.iso8601, spark: spark }.compact end |