class LinkedinV2::Templates::Payloads::Shares

Attributes

options[R]

Public Class Methods

new(**options) click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 5
def initialize(**options)
  super(options)
end

Public Instance Methods

to_json() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 9
def to_json
  payload.to_json
end

Private Instance Methods

body() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 27
def body
  {
    "owner" => "urn:li:#{entity}:#{identifier}",
    "content" => {
      "contentEntities" => [
        {
          "entityLocation" => url,
        }.merge(thumbnail_attribute)
      ]
    },
    "distribution" => {
      "linkedInDistributionTarget" => {}
    },
    "text" => {
      "text" => text
    }
  }
end
description() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 72
def description
  options.fetch(:description, nil)
end
description_attribute() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 88
def description_attribute
  {
    "content" => {
      "description" => description,
    },
  }
end
entity() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 48
def entity
  options.fetch(:entity)
end
identifier() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 52
def identifier
  options.fetch(:identifier)
end
payload() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 15
def payload
  response = body
  if Helpers::Attribute.present?(description)
    response = Helpers::Hash.deep_merge(response, description_attribute)
  end
  if Helpers::Attribute.present?(title)
    response = Helpers::Hash.deep_merge(response, title_attribute)
  end

  response
end
text() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 60
def text
  options.fetch(:text)
end
thumbnail() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 64
def thumbnail
  options.fetch(:thumbnail, nil)
end
thumbnail_attribute() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 76
def thumbnail_attribute
  return {} if thumbnail.to_s.empty?

  {
    "thumbnails" => [
      {
        "resolvedUrl": thumbnail,
      }
    ],
  }
end
title() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 68
def title
  options.fetch(:title, nil)
end
title_attribute() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 96
def title_attribute
  {
    "content" => {
      "title" => title,
    },
  }
end
url() click to toggle source
# File lib/linkedin_v2/templates/payloads/shares.rb, line 56
def url
  options.fetch(:url)
end