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, password: nil, max_clicks: nil, track_conversions: nil, routing_rules: nil, ab_variants: 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`.

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

    gate the link behind a password.

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

    disable the link after this many clicks.

  • track_conversions (Boolean, nil) (defaults to: nil)

    enable conversion tracking.

  • routing_rules (Array<Rerout::Models::RoutingRule, Hash>, nil) (defaults to: nil)

    Smart Link routing rules.

  • ab_variants (Array<Rerout::Models::AbVariant, Hash>, nil) (defaults to: nil)

    A/B-test variants — each ‘{ target_url:, weight? }`.

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rerout/create_link_input.rb', line 29

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,
               password: nil, max_clicks: nil, track_conversions: nil,
               routing_rules: nil, ab_variants: 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
  @password = password
  @max_clicks = max_clicks
  @track_conversions = track_conversions
  @routing_rules = routing_rules
  @ab_variants = ab_variants
  freeze
end

Instance Attribute Details

#ab_variantsObject (readonly)

Returns the value of attribute ab_variants.



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

def ab_variants
  @ab_variants
end

#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

#max_clicksObject (readonly)

Returns the value of attribute max_clicks.



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

def max_clicks
  @max_clicks
end

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#routing_rulesObject (readonly)

Returns the value of attribute routing_rules.



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

def routing_rules
  @routing_rules
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

#track_conversionsObject (readonly)

Returns the value of attribute track_conversions.



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

def track_conversions
  @track_conversions
end

Instance Method Details

#to_hObject

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



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rerout/create_link_input.rb', line 54

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['password'] = password unless password.nil?
  hash['max_clicks'] = max_clicks unless max_clicks.nil?
  hash['track_conversions'] = track_conversions unless track_conversions.nil?
  hash['routing_rules'] = routing_rules.map { |r| InputSerialization.rule_hash(r) } unless routing_rules.nil?
  hash['ab_variants'] = ab_variants.map { |v| InputSerialization.variant_hash(v) } unless ab_variants.nil?
  hash
end