Class: Hubspot::Cms::UrlRedirects::UrlMapping
- Inherits:
-
Object
- Object
- Hubspot::Cms::UrlRedirects::UrlMapping
- Defined in:
- lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#destination ⇒ Object
The destination URL, where the target URL should be redirected if it matches the ‘routePrefix`.
-
#id ⇒ Object
The unique ID of this URL redirect.
-
#is_match_full_url ⇒ Object
Whether the ‘routePrefix` should match on the entire URL, including the domain.
-
#is_match_query_string ⇒ Object
Whether the ‘routePrefix` should match on the entire URL path, including the query string.
-
#is_only_after_not_found ⇒ Object
Whether the URL redirect mapping should apply only if a live page on the URL isn’t found.
-
#is_pattern ⇒ Object
Whether the ‘routePrefix` should match based on pattern.
-
#is_protocol_agnostic ⇒ Object
Whether the ‘routePrefix` should match both HTTP and HTTPS protocols.
-
#is_trailing_slash_optional ⇒ Object
Whether a trailing slash will be ignored.
-
#precedence ⇒ Object
Used to prioritize URL redirection.
-
#redirect_style ⇒ Object
The type of redirect to create.
-
#route_prefix ⇒ Object
The target incoming URL, path, or pattern to match for redirection.
-
#updated ⇒ Object
Returns the value of attribute updated.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ UrlMapping
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ UrlMapping
Initializes the object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 108 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Cms::UrlRedirects::UrlMapping` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Cms::UrlRedirects::UrlMapping`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'is_trailing_slash_optional') self.is_trailing_slash_optional = attributes[:'is_trailing_slash_optional'] end if attributes.key?(:'redirect_style') self.redirect_style = attributes[:'redirect_style'] end if attributes.key?(:'is_match_query_string') self.is_match_query_string = attributes[:'is_match_query_string'] end if attributes.key?(:'created') self.created = attributes[:'created'] end if attributes.key?(:'is_match_full_url') self.is_match_full_url = attributes[:'is_match_full_url'] end if attributes.key?(:'destination') self.destination = attributes[:'destination'] end if attributes.key?(:'is_only_after_not_found') self.is_only_after_not_found = attributes[:'is_only_after_not_found'] end if attributes.key?(:'is_pattern') self.is_pattern = attributes[:'is_pattern'] end if attributes.key?(:'precedence') self.precedence = attributes[:'precedence'] end if attributes.key?(:'route_prefix') self.route_prefix = attributes[:'route_prefix'] end if attributes.key?(:'is_protocol_agnostic') self.is_protocol_agnostic = attributes[:'is_protocol_agnostic'] end if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'updated') self.updated = attributes[:'updated'] end end |
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
29 30 31 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 29 def created @created end |
#destination ⇒ Object
The destination URL, where the target URL should be redirected if it matches the ‘routePrefix`.
35 36 37 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 35 def destination @destination end |
#id ⇒ Object
The unique ID of this URL redirect.
53 54 55 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 53 def id @id end |
#is_match_full_url ⇒ Object
Whether the ‘routePrefix` should match on the entire URL, including the domain.
32 33 34 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 32 def is_match_full_url @is_match_full_url end |
#is_match_query_string ⇒ Object
Whether the ‘routePrefix` should match on the entire URL path, including the query string.
27 28 29 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 27 def is_match_query_string @is_match_query_string end |
#is_only_after_not_found ⇒ Object
Whether the URL redirect mapping should apply only if a live page on the URL isn’t found. If False, the URL redirect mapping will take precedence over any existing page.
38 39 40 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 38 def is_only_after_not_found @is_only_after_not_found end |
#is_pattern ⇒ Object
Whether the ‘routePrefix` should match based on pattern.
41 42 43 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 41 def is_pattern @is_pattern end |
#is_protocol_agnostic ⇒ Object
Whether the ‘routePrefix` should match both HTTP and HTTPS protocols.
50 51 52 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 50 def is_protocol_agnostic @is_protocol_agnostic end |
#is_trailing_slash_optional ⇒ Object
Whether a trailing slash will be ignored.
21 22 23 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 21 def is_trailing_slash_optional @is_trailing_slash_optional end |
#precedence ⇒ Object
Used to prioritize URL redirection. If a given URL matches more than one redirect, the one with the lower precedence will be used.
44 45 46 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 44 def precedence @precedence end |
#redirect_style ⇒ Object
The type of redirect to create. Options include: 301 (permanent), 302 (temporary), or 305 (proxy). Find more details [here](knowledge.hubspot.com/cos-general/how-to-redirect-a-hubspot-page).
24 25 26 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 24 def redirect_style @redirect_style end |
#route_prefix ⇒ Object
The target incoming URL, path, or pattern to match for redirection.
47 48 49 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 47 def route_prefix @route_prefix end |
#updated ⇒ Object
Returns the value of attribute updated.
55 56 57 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 55 def updated @updated end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
77 78 79 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 77 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 58 def self.attribute_map { :'is_trailing_slash_optional' => :'isTrailingSlashOptional', :'redirect_style' => :'redirectStyle', :'is_match_query_string' => :'isMatchQueryString', :'created' => :'created', :'is_match_full_url' => :'isMatchFullUrl', :'destination' => :'destination', :'is_only_after_not_found' => :'isOnlyAfterNotFound', :'is_pattern' => :'isPattern', :'precedence' => :'precedence', :'route_prefix' => :'routePrefix', :'is_protocol_agnostic' => :'isProtocolAgnostic', :'id' => :'id', :'updated' => :'updated' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
277 278 279 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 277 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
101 102 103 104 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 101 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 82 def self.openapi_types { :'is_trailing_slash_optional' => :'Boolean', :'redirect_style' => :'Integer', :'is_match_query_string' => :'Boolean', :'created' => :'Time', :'is_match_full_url' => :'Boolean', :'destination' => :'String', :'is_only_after_not_found' => :'Boolean', :'is_pattern' => :'Boolean', :'precedence' => :'Integer', :'route_prefix' => :'String', :'is_protocol_agnostic' => :'Boolean', :'id' => :'String', :'updated' => :'Time' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 244 def ==(o) return true if self.equal?(o) self.class == o.class && is_trailing_slash_optional == o.is_trailing_slash_optional && redirect_style == o.redirect_style && is_match_query_string == o.is_match_query_string && created == o.created && is_match_full_url == o.is_match_full_url && destination == o.destination && is_only_after_not_found == o.is_only_after_not_found && is_pattern == o.is_pattern && precedence == o.precedence && route_prefix == o.route_prefix && is_protocol_agnostic == o.is_protocol_agnostic && id == o.id && updated == o.updated end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 308 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Hubspot::Cms::UrlRedirects.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 379 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 284 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
264 265 266 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 264 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
270 271 272 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 270 def hash [is_trailing_slash_optional, redirect_style, is_match_query_string, created, is_match_full_url, destination, is_only_after_not_found, is_pattern, precedence, route_prefix, is_protocol_agnostic, id, updated].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 176 def list_invalid_properties invalid_properties = Array.new if @is_trailing_slash_optional.nil? invalid_properties.push('invalid value for "is_trailing_slash_optional", is_trailing_slash_optional cannot be nil.') end if @redirect_style.nil? invalid_properties.push('invalid value for "redirect_style", redirect_style cannot be nil.') end if @is_match_query_string.nil? invalid_properties.push('invalid value for "is_match_query_string", is_match_query_string cannot be nil.') end if @is_match_full_url.nil? invalid_properties.push('invalid value for "is_match_full_url", is_match_full_url cannot be nil.') end if @destination.nil? invalid_properties.push('invalid value for "destination", destination cannot be nil.') end if @is_only_after_not_found.nil? invalid_properties.push('invalid value for "is_only_after_not_found", is_only_after_not_found cannot be nil.') end if @is_pattern.nil? invalid_properties.push('invalid value for "is_pattern", is_pattern cannot be nil.') end if @precedence.nil? invalid_properties.push('invalid value for "precedence", precedence cannot be nil.') end if @route_prefix.nil? invalid_properties.push('invalid value for "route_prefix", route_prefix cannot be nil.') end if @is_protocol_agnostic.nil? invalid_properties.push('invalid value for "is_protocol_agnostic", is_protocol_agnostic cannot be nil.') end if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
355 356 357 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 355 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 361 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
349 350 351 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 349 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/hubspot/codegen/cms/url_redirects/models/url_mapping.rb', line 227 def valid? return false if @is_trailing_slash_optional.nil? return false if @redirect_style.nil? return false if @is_match_query_string.nil? return false if @is_match_full_url.nil? return false if @destination.nil? return false if @is_only_after_not_found.nil? return false if @is_pattern.nil? return false if @precedence.nil? return false if @route_prefix.nil? return false if @is_protocol_agnostic.nil? return false if @id.nil? true end |