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
-
.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
102 103 104 105 106 107 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 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 102 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?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'route_prefix') self.route_prefix = attributes[:'route_prefix'] end if attributes.key?(:'destination') self.destination = attributes[:'destination'] end if attributes.key?(:'redirect_style') self.redirect_style = attributes[:'redirect_style'] 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_match_full_url') self.is_match_full_url = attributes[:'is_match_full_url'] end if attributes.key?(:'is_match_query_string') self.is_match_query_string = attributes[:'is_match_query_string'] end if attributes.key?(:'is_pattern') self.is_pattern = attributes[:'is_pattern'] end if attributes.key?(:'is_trailing_slash_optional') self.is_trailing_slash_optional = attributes[:'is_trailing_slash_optional'] end if attributes.key?(:'is_protocol_agnostic') self.is_protocol_agnostic = attributes[:'is_protocol_agnostic'] end if attributes.key?(:'precedence') self.precedence = attributes[:'precedence'] end if attributes.key?(:'created') self.created = attributes[:'created'] end if attributes.key?(:'updated') self.updated = attributes[:'updated'] end end |
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
52 53 54 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 52 def created @created end |
#destination ⇒ Object
The destination URL, where the target URL should be redirected if it matches the ‘routePrefix`.
26 27 28 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 26 def destination @destination end |
#id ⇒ Object
The unique ID of this URL redirect.
20 21 22 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 20 def id @id end |
#is_match_full_url ⇒ Object
Whether the ‘routePrefix` should match on the entire URL, including the domain.
35 36 37 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 35 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.
38 39 40 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 38 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.
32 33 34 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 32 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.
47 48 49 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 47 def is_protocol_agnostic @is_protocol_agnostic end |
#is_trailing_slash_optional ⇒ Object
Whether a trailing slash will be ignored.
44 45 46 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 44 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.
50 51 52 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 50 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).
29 30 31 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 29 def redirect_style @redirect_style end |
#route_prefix ⇒ Object
The target incoming URL, path, or pattern to match for redirection.
23 24 25 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 23 def route_prefix @route_prefix end |
#updated ⇒ Object
Returns the value of attribute updated.
54 55 56 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 54 def updated @updated end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 57 def self.attribute_map { :'id' => :'id', :'route_prefix' => :'routePrefix', :'destination' => :'destination', :'redirect_style' => :'redirectStyle', :'is_only_after_not_found' => :'isOnlyAfterNotFound', :'is_match_full_url' => :'isMatchFullUrl', :'is_match_query_string' => :'isMatchQueryString', :'is_pattern' => :'isPattern', :'is_trailing_slash_optional' => :'isTrailingSlashOptional', :'is_protocol_agnostic' => :'isProtocolAgnostic', :'precedence' => :'precedence', :'created' => :'created', :'updated' => :'updated' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
271 272 273 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 271 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
95 96 97 98 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 95 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 76 def self.openapi_types { :'id' => :'String', :'route_prefix' => :'String', :'destination' => :'String', :'redirect_style' => :'Integer', :'is_only_after_not_found' => :'Boolean', :'is_match_full_url' => :'Boolean', :'is_match_query_string' => :'Boolean', :'is_pattern' => :'Boolean', :'is_trailing_slash_optional' => :'Boolean', :'is_protocol_agnostic' => :'Boolean', :'precedence' => :'Integer', :'created' => :'DateTime', :'updated' => :'DateTime' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 238 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && route_prefix == o.route_prefix && destination == o.destination && redirect_style == o.redirect_style && is_only_after_not_found == o.is_only_after_not_found && is_match_full_url == o.is_match_full_url && is_match_query_string == o.is_match_query_string && is_pattern == o.is_pattern && is_trailing_slash_optional == o.is_trailing_slash_optional && is_protocol_agnostic == o.is_protocol_agnostic && precedence == o.precedence && created == o.created && updated == o.updated end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
299 300 301 302 303 304 305 306 307 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 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 299 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.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 Hubspot::Cms::UrlRedirects.const_get(type).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
368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 368 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
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 278 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if 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 # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
258 259 260 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 258 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
264 265 266 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 264 def hash [id, route_prefix, destination, redirect_style, is_only_after_not_found, is_match_full_url, is_match_query_string, is_pattern, is_trailing_slash_optional, is_protocol_agnostic, precedence, created, updated].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
170 171 172 173 174 175 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 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 170 def list_invalid_properties invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @route_prefix.nil? invalid_properties.push('invalid value for "route_prefix", route_prefix cannot be nil.') end if @destination.nil? invalid_properties.push('invalid value for "destination", destination cannot be nil.') end if @redirect_style.nil? invalid_properties.push('invalid value for "redirect_style", redirect_style 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_match_full_url.nil? invalid_properties.push('invalid value for "is_match_full_url", is_match_full_url 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_pattern.nil? invalid_properties.push('invalid value for "is_pattern", is_pattern cannot be nil.') end 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 @is_protocol_agnostic.nil? invalid_properties.push('invalid value for "is_protocol_agnostic", is_protocol_agnostic cannot be nil.') end if @precedence.nil? invalid_properties.push('invalid value for "precedence", precedence cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
344 345 346 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 344 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 350 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
338 339 340 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 338 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb', line 221 def valid? return false if @id.nil? return false if @route_prefix.nil? return false if @destination.nil? return false if @redirect_style.nil? return false if @is_only_after_not_found.nil? return false if @is_match_full_url.nil? return false if @is_match_query_string.nil? return false if @is_pattern.nil? return false if @is_trailing_slash_optional.nil? return false if @is_protocol_agnostic.nil? return false if @precedence.nil? true end |