Class: Rerout::CreateLinkInput

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/create_link_input.rb

Overview

Request body for ‘POST /v1/links`. Only `target_url` is required —everything else is optional and omitted from the payload when not set.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_url:, domain_hostname: nil, code: nil, expires_at: nil, seo_title: nil, seo_description: nil, seo_image_url: nil, seo_canonical_url: nil, seo_noindex: nil) ⇒ CreateLinkInput

Returns a new instance of CreateLinkInput.

Parameters:

  • target_url (String)

    required, the destination URL.

  • domain_hostname (String, nil) (defaults to: nil)

    verified custom domain (e.g. ‘go.brand.com`).

  • code (String, nil) (defaults to: nil)

    custom path. Only allowed with a verified ‘domain_hostname`.

  • expires_at (Integer, nil) (defaults to: nil)

    unix seconds.

  • seo_title (String, nil) (defaults to: nil)
  • seo_description (String, nil) (defaults to: nil)
  • seo_image_url (String, nil) (defaults to: nil)

    absolute https:// URL.

  • seo_canonical_url (String, nil) (defaults to: nil)
  • seo_noindex (Boolean, nil) (defaults to: nil)

    default server-side: ‘true`.

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rerout/create_link_input.rb', line 20

def initialize(target_url:, domain_hostname: nil, code: nil, expires_at: nil,
               seo_title: nil, seo_description: nil, seo_image_url: nil,
               seo_canonical_url: nil, seo_noindex: nil)
  raise ArgumentError, 'target_url is required' if target_url.nil? || target_url.to_s.empty?

  @target_url = target_url
  @domain_hostname = domain_hostname
  @code = code
  @expires_at = expires_at
  @seo_title = seo_title
  @seo_description = seo_description
  @seo_image_url = seo_image_url
  @seo_canonical_url = seo_canonical_url
  @seo_noindex = seo_noindex
  freeze
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def code
  @code
end

#domain_hostnameObject (readonly)

Returns the value of attribute domain_hostname.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def domain_hostname
  @domain_hostname
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def expires_at
  @expires_at
end

#seo_canonical_urlObject (readonly)

Returns the value of attribute seo_canonical_url.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def seo_canonical_url
  @seo_canonical_url
end

#seo_descriptionObject (readonly)

Returns the value of attribute seo_description.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def seo_description
  @seo_description
end

#seo_image_urlObject (readonly)

Returns the value of attribute seo_image_url.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def seo_image_url
  @seo_image_url
end

#seo_noindexObject (readonly)

Returns the value of attribute seo_noindex.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def seo_noindex
  @seo_noindex
end

#seo_titleObject (readonly)

Returns the value of attribute seo_title.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def seo_title
  @seo_title
end

#target_urlObject (readonly)

Returns the value of attribute target_url.



7
8
9
# File 'lib/rerout/create_link_input.rb', line 7

def target_url
  @target_url
end

Instance Method Details

#to_hObject

Serialize for the wire. Fields are only included when set.



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rerout/create_link_input.rb', line 38

def to_h
  hash = { 'target_url' => target_url }
  hash['domain_hostname'] = domain_hostname unless domain_hostname.nil?
  hash['code'] = code unless code.nil?
  hash['expires_at'] = expires_at unless expires_at.nil?
  hash['seo_title'] = seo_title unless seo_title.nil?
  hash['seo_description'] = seo_description unless seo_description.nil?
  hash['seo_image_url'] = seo_image_url unless seo_image_url.nil?
  hash['seo_canonical_url'] = seo_canonical_url unless seo_canonical_url.nil?
  hash['seo_noindex'] = seo_noindex unless seo_noindex.nil?
  hash
end