Class: ClerkHttpClient::Template
- Inherits:
-
Object
- Object
- ClerkHttpClient::Template
- Defined in:
- lib/clerk-http-client/models/template.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#available_variables ⇒ Object
list of variables that are available for use in the template body.
-
#body ⇒ Object
the template body before variable interpolation.
-
#can_delete ⇒ Object
whether this template can be deleted.
-
#can_revert ⇒ Object
whether this template can be reverted to the corresponding system default.
-
#can_toggle ⇒ Object
whether this template can be enabled or disabled, true only for notification SMS templates.
-
#created_at ⇒ Object
Unix timestamp of creation.
-
#delivered_by_clerk ⇒ Object
Returns the value of attribute delivered_by_clerk.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#from_email_name ⇒ Object
Returns the value of attribute from_email_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instance_id ⇒ Object
the id of the instance the template belongs to.
-
#markup ⇒ Object
the editor markup used to generate the body of the template.
-
#name ⇒ Object
user-friendly name of the template.
-
#object ⇒ Object
String representing the object’s type.
-
#position ⇒ Object
position with the listing of templates.
-
#reply_to_email_name ⇒ Object
Returns the value of attribute reply_to_email_name.
-
#required_variables ⇒ Object
list of variables that must be contained in the template body.
-
#resource_type ⇒ Object
whether this is a system (default) or user overridden) template.
-
#slug ⇒ Object
machine-friendly name of the template.
-
#subject ⇒ Object
email subject.
-
#template_type ⇒ Object
whether this is an email or SMS template.
-
#updated_at ⇒ Object
Unix timestamp of last update.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.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.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Template
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 = {}) ⇒ Template
Initializes the object
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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/clerk-http-client/models/template.rb', line 172 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `ClerkHttpClient::Template` 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 `ClerkHttpClient::Template`. 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?(:'object') self.object = attributes[:'object'] end if attributes.key?(:'instance_id') self.instance_id = attributes[:'instance_id'] end if attributes.key?(:'resource_type') self.resource_type = attributes[:'resource_type'] end if attributes.key?(:'template_type') self.template_type = attributes[:'template_type'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'slug') self.slug = attributes[:'slug'] end if attributes.key?(:'position') self.position = attributes[:'position'] end if attributes.key?(:'can_revert') self.can_revert = attributes[:'can_revert'] end if attributes.key?(:'can_delete') self.can_delete = attributes[:'can_delete'] end if attributes.key?(:'can_toggle') self.can_toggle = attributes[:'can_toggle'] end if attributes.key?(:'subject') self.subject = attributes[:'subject'] end if attributes.key?(:'markup') self.markup = attributes[:'markup'] end if attributes.key?(:'body') self.body = attributes[:'body'] end if attributes.key?(:'available_variables') if (value = attributes[:'available_variables']).is_a?(Array) self.available_variables = value end end if attributes.key?(:'required_variables') if (value = attributes[:'required_variables']).is_a?(Array) self.required_variables = value end end if attributes.key?(:'from_email_name') self.from_email_name = attributes[:'from_email_name'] end if attributes.key?(:'reply_to_email_name') self.reply_to_email_name = attributes[:'reply_to_email_name'] end if attributes.key?(:'delivered_by_clerk') self.delivered_by_clerk = attributes[:'delivered_by_clerk'] end if attributes.key?(:'enabled') self.enabled = attributes[:'enabled'] end if attributes.key?(:'updated_at') self.updated_at = attributes[:'updated_at'] end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end end |
Instance Attribute Details
#available_variables ⇒ Object
list of variables that are available for use in the template body
60 61 62 |
# File 'lib/clerk-http-client/models/template.rb', line 60 def available_variables @available_variables end |
#body ⇒ Object
the template body before variable interpolation
57 58 59 |
# File 'lib/clerk-http-client/models/template.rb', line 57 def body @body end |
#can_delete ⇒ Object
whether this template can be deleted
45 46 47 |
# File 'lib/clerk-http-client/models/template.rb', line 45 def can_delete @can_delete end |
#can_revert ⇒ Object
whether this template can be reverted to the corresponding system default
42 43 44 |
# File 'lib/clerk-http-client/models/template.rb', line 42 def can_revert @can_revert end |
#can_toggle ⇒ Object
whether this template can be enabled or disabled, true only for notification SMS templates
48 49 50 |
# File 'lib/clerk-http-client/models/template.rb', line 48 def can_toggle @can_toggle end |
#created_at ⇒ Object
Unix timestamp of creation.
77 78 79 |
# File 'lib/clerk-http-client/models/template.rb', line 77 def created_at @created_at end |
#delivered_by_clerk ⇒ Object
Returns the value of attribute delivered_by_clerk.
69 70 71 |
# File 'lib/clerk-http-client/models/template.rb', line 69 def delivered_by_clerk @delivered_by_clerk end |
#enabled ⇒ Object
Returns the value of attribute enabled.
71 72 73 |
# File 'lib/clerk-http-client/models/template.rb', line 71 def enabled @enabled end |
#from_email_name ⇒ Object
Returns the value of attribute from_email_name.
65 66 67 |
# File 'lib/clerk-http-client/models/template.rb', line 65 def from_email_name @from_email_name end |
#id ⇒ Object
Returns the value of attribute id.
18 19 20 |
# File 'lib/clerk-http-client/models/template.rb', line 18 def id @id end |
#instance_id ⇒ Object
the id of the instance the template belongs to
24 25 26 |
# File 'lib/clerk-http-client/models/template.rb', line 24 def instance_id @instance_id end |
#markup ⇒ Object
the editor markup used to generate the body of the template
54 55 56 |
# File 'lib/clerk-http-client/models/template.rb', line 54 def markup @markup end |
#name ⇒ Object
user-friendly name of the template
33 34 35 |
# File 'lib/clerk-http-client/models/template.rb', line 33 def name @name end |
#object ⇒ Object
String representing the object’s type. Objects of the same type share the same value.
21 22 23 |
# File 'lib/clerk-http-client/models/template.rb', line 21 def object @object end |
#position ⇒ Object
position with the listing of templates
39 40 41 |
# File 'lib/clerk-http-client/models/template.rb', line 39 def position @position end |
#reply_to_email_name ⇒ Object
Returns the value of attribute reply_to_email_name.
67 68 69 |
# File 'lib/clerk-http-client/models/template.rb', line 67 def reply_to_email_name @reply_to_email_name end |
#required_variables ⇒ Object
list of variables that must be contained in the template body
63 64 65 |
# File 'lib/clerk-http-client/models/template.rb', line 63 def required_variables @required_variables end |
#resource_type ⇒ Object
whether this is a system (default) or user overridden) template
27 28 29 |
# File 'lib/clerk-http-client/models/template.rb', line 27 def resource_type @resource_type end |
#slug ⇒ Object
machine-friendly name of the template
36 37 38 |
# File 'lib/clerk-http-client/models/template.rb', line 36 def slug @slug end |
#subject ⇒ Object
email subject
51 52 53 |
# File 'lib/clerk-http-client/models/template.rb', line 51 def subject @subject end |
#template_type ⇒ Object
whether this is an email or SMS template
30 31 32 |
# File 'lib/clerk-http-client/models/template.rb', line 30 def template_type @template_type end |
#updated_at ⇒ Object
Unix timestamp of last update.
74 75 76 |
# File 'lib/clerk-http-client/models/template.rb', line 74 def updated_at @updated_at end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/clerk-http-client/models/template.rb', line 373 def self._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 = ClerkHttpClient.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
130 131 132 |
# File 'lib/clerk-http-client/models/template.rb', line 130 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
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 |
# File 'lib/clerk-http-client/models/template.rb', line 102 def self.attribute_map { :'id' => :'id', :'object' => :'object', :'instance_id' => :'instance_id', :'resource_type' => :'resource_type', :'template_type' => :'template_type', :'name' => :'name', :'slug' => :'slug', :'position' => :'position', :'can_revert' => :'can_revert', :'can_delete' => :'can_delete', :'can_toggle' => :'can_toggle', :'subject' => :'subject', :'markup' => :'markup', :'body' => :'body', :'available_variables' => :'available_variables', :'required_variables' => :'required_variables', :'from_email_name' => :'from_email_name', :'reply_to_email_name' => :'reply_to_email_name', :'delivered_by_clerk' => :'delivered_by_clerk', :'enabled' => :'enabled', :'updated_at' => :'updated_at', :'created_at' => :'created_at' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/clerk-http-client/models/template.rb', line 349 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{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[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
163 164 165 166 167 168 |
# File 'lib/clerk-http-client/models/template.rb', line 163 def self.openapi_nullable Set.new([ :'instance_id', :'subject', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
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 |
# File 'lib/clerk-http-client/models/template.rb', line 135 def self.openapi_types { :'id' => :'String', :'object' => :'String', :'instance_id' => :'String', :'resource_type' => :'String', :'template_type' => :'String', :'name' => :'String', :'slug' => :'String', :'position' => :'Integer', :'can_revert' => :'Boolean', :'can_delete' => :'Boolean', :'can_toggle' => :'Boolean', :'subject' => :'String', :'markup' => :'String', :'body' => :'String', :'available_variables' => :'Array<String>', :'required_variables' => :'Array<String>', :'from_email_name' => :'String', :'reply_to_email_name' => :'String', :'delivered_by_clerk' => :'Boolean', :'enabled' => :'Boolean', :'updated_at' => :'Integer', :'created_at' => :'Integer' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
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 |
# File 'lib/clerk-http-client/models/template.rb', line 307 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && object == o.object && instance_id == o.instance_id && resource_type == o.resource_type && template_type == o.template_type && name == o.name && slug == o.slug && position == o.position && can_revert == o.can_revert && can_delete == o.can_delete && can_toggle == o.can_toggle && subject == o.subject && markup == o.markup && body == o.body && available_variables == o.available_variables && required_variables == o.required_variables && from_email_name == o.from_email_name && reply_to_email_name == o.reply_to_email_name && delivered_by_clerk == o.delivered_by_clerk && enabled == o.enabled && updated_at == o.updated_at && created_at == o.created_at end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/clerk-http-client/models/template.rb', line 444 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 |
#eql?(o) ⇒ Boolean
336 337 338 |
# File 'lib/clerk-http-client/models/template.rb', line 336 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
342 343 344 |
# File 'lib/clerk-http-client/models/template.rb', line 342 def hash [id, object, instance_id, resource_type, template_type, name, slug, position, can_revert, can_delete, can_toggle, subject, markup, body, available_variables, required_variables, from_email_name, reply_to_email_name, delivered_by_clerk, enabled, updated_at, created_at].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
280 281 282 283 284 |
# File 'lib/clerk-http-client/models/template.rb', line 280 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
420 421 422 |
# File 'lib/clerk-http-client/models/template.rb', line 420 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/clerk-http-client/models/template.rb', line 426 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
414 415 416 |
# File 'lib/clerk-http-client/models/template.rb', line 414 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
288 289 290 291 292 293 |
# File 'lib/clerk-http-client/models/template.rb', line 288 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' object_validator = EnumAttributeValidator.new('String', ["template"]) return false unless object_validator.valid?(@object) true end |