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 ].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) ⇒ 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) ⇒ UpdateLinkInput
Returns a new instance of UpdateLinkInput.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rerout/update_link_input.rb', line 42 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) @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 } freeze end |
Instance Method Details
#empty? ⇒ Boolean
Returns true when no field was set.
72 73 74 |
# File 'lib/rerout/update_link_input.rb', line 72 def empty? to_h.empty? end |
#to_h ⇒ Object
Serialize for the wire. Unset fields are omitted; ‘Rerout::CLEAR` becomes `null`.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rerout/update_link_input.rb', line 60 def to_h out = {} FIELDS.each do |field| v = @values[field] next if v.equal?(OMIT) out[field.to_s] = v.equal?(CLEAR) ? nil : v end out end |
#value_for(field) ⇒ Object
Returns the raw value (sentinel or actual) for a field.
77 78 79 |
# File 'lib/rerout/update_link_input.rb', line 77 def value_for(field) @values.fetch(field) end |