Class: Rerout::UpdateLinkInput
- Inherits:
-
Object
- Object
- Rerout::UpdateLinkInput
- Defined in:
- lib/rerout/update_link_input.rb
Overview
Request body for ‘PATCH /v1/links/:code`. Every field is optional. To send `null` to the server (clear an existing value), pass `Rerout::CLEAR` to that keyword argument.
Constant Summary collapse
- FIELDS =
%i[ target_url expires_at is_active seo_title seo_description seo_image_url seo_canonical_url seo_noindex password max_clicks track_conversions routing_rules ab_variants ].freeze
- LIST_FIELDS =
Smart Link fields that are a full replacement (an Array of value objects or Hashes) rather than a scalar — serialized element-by-element.
%i[routing_rules ab_variants].freeze
Instance Method Summary collapse
-
#empty? ⇒ Boolean
True when no field was set.
-
#initialize(target_url: OMIT, expires_at: OMIT, is_active: OMIT, seo_title: OMIT, seo_description: OMIT, seo_image_url: OMIT, seo_canonical_url: OMIT, seo_noindex: OMIT, password: OMIT, max_clicks: OMIT, track_conversions: OMIT, routing_rules: OMIT, ab_variants: OMIT) ⇒ UpdateLinkInput
constructor
A new instance of UpdateLinkInput.
-
#to_h ⇒ Object
Serialize for the wire.
-
#value_for(field) ⇒ Object
The raw value (sentinel or actual) for a field.
Constructor Details
#initialize(target_url: OMIT, expires_at: OMIT, is_active: OMIT, seo_title: OMIT, seo_description: OMIT, seo_image_url: OMIT, seo_canonical_url: OMIT, seo_noindex: OMIT, password: OMIT, max_clicks: OMIT, track_conversions: OMIT, routing_rules: OMIT, ab_variants: OMIT) ⇒ UpdateLinkInput
Returns a new instance of UpdateLinkInput.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rerout/update_link_input.rb', line 47 def initialize(target_url: OMIT, expires_at: OMIT, is_active: OMIT, seo_title: OMIT, seo_description: OMIT, seo_image_url: OMIT, seo_canonical_url: OMIT, seo_noindex: OMIT, password: OMIT, max_clicks: OMIT, track_conversions: OMIT, routing_rules: OMIT, ab_variants: OMIT) @values = { target_url: target_url, expires_at: expires_at, is_active: is_active, 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 Method Details
#empty? ⇒ Boolean
Returns true when no field was set.
85 86 87 |
# File 'lib/rerout/update_link_input.rb', line 85 def empty? to_h.empty? end |
#to_h ⇒ Object
Serialize for the wire. Unset fields are omitted; ‘Rerout::CLEAR` becomes `null`. `routing_rules` / `ab_variants` are a full replacement and serialize their elements (value objects or Hashes).
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rerout/update_link_input.rb', line 73 def to_h out = {} FIELDS.each do |field| v = @values[field] next if v.equal?(OMIT) out[field.to_s] = serialize_field(field, v) end out end |
#value_for(field) ⇒ Object
Returns the raw value (sentinel or actual) for a field.
90 91 92 |
# File 'lib/rerout/update_link_input.rb', line 90 def value_for(field) @values.fetch(field) end |