=begin #Mandrill API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.4 Contact: apihelp@mandrill.com Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.12 =end require 'date' module MailchimpTransactional # the other information on the message to send - same as /messages/send, but without the html content class MessagessendtemplateMessage # optional full HTML content to be sent if not in template attr_accessor :html # optional full text content to be sent attr_accessor :text # the message subject attr_accessor :subject # the sender email address attr_accessor :from_email # optional from name to be used attr_accessor :from_name # an array of recipient information. attr_accessor :to # optional extra headers to add to the message (most headers are allowed) attr_accessor :headers # whether or not this message is important, and should be delivered ahead of non-important messages attr_accessor :important # whether or not to turn on open tracking for the message attr_accessor :track_opens # whether or not to turn on click tracking for the message attr_accessor :track_clicks # whether or not to automatically generate a text part for messages that are not given text attr_accessor :auto_text # whether or not to automatically generate an HTML part for messages that are not given HTML attr_accessor :auto_html # whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size attr_accessor :inline_css # whether or not to strip the query string from URLs when aggregating tracked URL data attr_accessor :url_strip_qs # whether or not to expose all recipients in to \"To\" header for each email attr_accessor :preserve_recipients # set to false to remove content logging for sensitive emails attr_accessor :view_content_link # an optional address to receive an exact copy of each recipient's email attr_accessor :bcc_address # a custom domain to use for tracking opens and clicks instead of mandrillapp.com attr_accessor :tracking_domain # a custom domain to use for SPF/DKIM signing instead of mandrill (for \"via\" or \"on behalf of\" in email clients) attr_accessor :signing_domain # a custom domain to use for the messages's return-path attr_accessor :return_path_domain # whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided. attr_accessor :merge # the merge tag language to use when evaluating merge tags, either mailchimp or handlebars attr_accessor :merge_language # global merge variables to use for all recipients. You can override these per recipient. attr_accessor :global_merge_vars # per-recipient merge variables, which override global merge variables with the same name. attr_accessor :merge_vars # an array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors. attr_accessor :tags # the unique id of a subaccount for this message - must already exist or will fail with an error attr_accessor :subaccount # an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically. attr_accessor :google_analytics_domains # optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead. attr_accessor :google_analytics_campaign attr_accessor :metadata # Per-recipient metadata that will override the global values specified in the metadata parameter. attr_accessor :recipient_metadata # an array of supported attachments to add to the message attr_accessor :attachments # an array of embedded images to add to the message attr_accessor :images class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @allowable_values = allowable_values.map do |value| case datatype.to_s when /Integer/i value.to_i when /Float/i value.to_f else value end end end def valid?(value) !value || allowable_values.include?(value) end end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'html' => :'html', :'text' => :'text', :'subject' => :'subject', :'from_email' => :'from_email', :'from_name' => :'from_name', :'to' => :'to', :'headers' => :'headers', :'important' => :'important', :'track_opens' => :'track_opens', :'track_clicks' => :'track_clicks', :'auto_text' => :'auto_text', :'auto_html' => :'auto_html', :'inline_css' => :'inline_css', :'url_strip_qs' => :'url_strip_qs', :'preserve_recipients' => :'preserve_recipients', :'view_content_link' => :'view_content_link', :'bcc_address' => :'bcc_address', :'tracking_domain' => :'tracking_domain', :'signing_domain' => :'signing_domain', :'return_path_domain' => :'return_path_domain', :'merge' => :'merge', :'merge_language' => :'merge_language', :'global_merge_vars' => :'global_merge_vars', :'merge_vars' => :'merge_vars', :'tags' => :'tags', :'subaccount' => :'subaccount', :'google_analytics_domains' => :'google_analytics_domains', :'google_analytics_campaign' => :'google_analytics_campaign', :'metadata' => :'metadata', :'recipient_metadata' => :'recipient_metadata', :'attachments' => :'attachments', :'images' => :'images' } end # Attribute type mapping. def self.swagger_types { :'html' => :'String', :'text' => :'String', :'subject' => :'String', :'from_email' => :'String', :'from_name' => :'String', :'to' => :'Array', :'headers' => :'Object', :'important' => :'BOOLEAN', :'track_opens' => :'BOOLEAN', :'track_clicks' => :'BOOLEAN', :'auto_text' => :'BOOLEAN', :'auto_html' => :'BOOLEAN', :'inline_css' => :'BOOLEAN', :'url_strip_qs' => :'BOOLEAN', :'preserve_recipients' => :'BOOLEAN', :'view_content_link' => :'BOOLEAN', :'bcc_address' => :'String', :'tracking_domain' => :'String', :'signing_domain' => :'String', :'return_path_domain' => :'String', :'merge' => :'BOOLEAN', :'merge_language' => :'String', :'global_merge_vars' => :'Array', :'merge_vars' => :'Array', :'tags' => :'Array', :'subaccount' => :'String', :'google_analytics_domains' => :'Array', :'google_analytics_campaign' => :'String', :'metadata' => :'MessagessendMessageMetadata', :'recipient_metadata' => :'Array', :'attachments' => :'Array', :'images' => :'Array' } end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'html') self.html = attributes[:'html'] end if attributes.has_key?(:'text') self.text = attributes[:'text'] end if attributes.has_key?(:'subject') self.subject = attributes[:'subject'] end if attributes.has_key?(:'from_email') self.from_email = attributes[:'from_email'] end if attributes.has_key?(:'from_name') self.from_name = attributes[:'from_name'] end if attributes.has_key?(:'to') if (value = attributes[:'to']).is_a?(Array) self.to = value end end if attributes.has_key?(:'headers') self.headers = attributes[:'headers'] end if attributes.has_key?(:'important') self.important = attributes[:'important'] end if attributes.has_key?(:'track_opens') self.track_opens = attributes[:'track_opens'] end if attributes.has_key?(:'track_clicks') self.track_clicks = attributes[:'track_clicks'] end if attributes.has_key?(:'auto_text') self.auto_text = attributes[:'auto_text'] end if attributes.has_key?(:'auto_html') self.auto_html = attributes[:'auto_html'] end if attributes.has_key?(:'inline_css') self.inline_css = attributes[:'inline_css'] end if attributes.has_key?(:'url_strip_qs') self.url_strip_qs = attributes[:'url_strip_qs'] end if attributes.has_key?(:'preserve_recipients') self.preserve_recipients = attributes[:'preserve_recipients'] end if attributes.has_key?(:'view_content_link') self.view_content_link = attributes[:'view_content_link'] end if attributes.has_key?(:'bcc_address') self.bcc_address = attributes[:'bcc_address'] end if attributes.has_key?(:'tracking_domain') self.tracking_domain = attributes[:'tracking_domain'] end if attributes.has_key?(:'signing_domain') self.signing_domain = attributes[:'signing_domain'] end if attributes.has_key?(:'return_path_domain') self.return_path_domain = attributes[:'return_path_domain'] end if attributes.has_key?(:'merge') self.merge = attributes[:'merge'] end if attributes.has_key?(:'merge_language') self.merge_language = attributes[:'merge_language'] end if attributes.has_key?(:'global_merge_vars') if (value = attributes[:'global_merge_vars']).is_a?(Array) self.global_merge_vars = value end end if attributes.has_key?(:'merge_vars') if (value = attributes[:'merge_vars']).is_a?(Array) self.merge_vars = value end end if attributes.has_key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end if attributes.has_key?(:'subaccount') self.subaccount = attributes[:'subaccount'] end if attributes.has_key?(:'google_analytics_domains') if (value = attributes[:'google_analytics_domains']).is_a?(Array) self.google_analytics_domains = value end end if attributes.has_key?(:'google_analytics_campaign') self.google_analytics_campaign = attributes[:'google_analytics_campaign'] end if attributes.has_key?(:'metadata') self.metadata = attributes[:'metadata'] end if attributes.has_key?(:'recipient_metadata') if (value = attributes[:'recipient_metadata']).is_a?(Array) self.recipient_metadata = value end end if attributes.has_key?(:'attachments') if (value = attributes[:'attachments']).is_a?(Array) self.attachments = value end end if attributes.has_key?(:'images') if (value = attributes[:'images']).is_a?(Array) self.images = value end end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? merge_language_validator = EnumAttributeValidator.new('String', ['mailchimp', 'handlebars']) return false unless merge_language_validator.valid?(@merge_language) true end # Custom attribute writer method checking allowed values (enum). # @param [Object] merge_language Object to be assigned def merge_language=(merge_language) validator = EnumAttributeValidator.new('String', ['mailchimp', 'handlebars']) unless validator.valid?(merge_language) fail ArgumentError, 'invalid value for "merge_language", must be one of #{validator.allowable_values}.' end @merge_language = merge_language end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && html == o.html && text == o.text && subject == o.subject && from_email == o.from_email && from_name == o.from_name && to == o.to && headers == o.headers && important == o.important && track_opens == o.track_opens && track_clicks == o.track_clicks && auto_text == o.auto_text && auto_html == o.auto_html && inline_css == o.inline_css && url_strip_qs == o.url_strip_qs && preserve_recipients == o.preserve_recipients && view_content_link == o.view_content_link && bcc_address == o.bcc_address && tracking_domain == o.tracking_domain && signing_domain == o.signing_domain && return_path_domain == o.return_path_domain && merge == o.merge && merge_language == o.merge_language && global_merge_vars == o.global_merge_vars && merge_vars == o.merge_vars && tags == o.tags && subaccount == o.subaccount && google_analytics_domains == o.google_analytics_domains && google_analytics_campaign == o.google_analytics_campaign && metadata == o.metadata && recipient_metadata == o.recipient_metadata && attachments == o.attachments && images == o.images end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash [html, text, subject, from_email, from_name, to, headers, important, track_opens, track_clicks, auto_text, auto_html, inline_css, url_strip_qs, preserve_recipients, view_content_link, bcc_address, tracking_domain, signing_domain, return_path_domain, merge, merge_language, global_merge_vars, merge_vars, tags, subaccount, google_analytics_domains, google_analytics_campaign, metadata, recipient_metadata, attachments, images].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_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 # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data 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<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\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 temp_model = MailchimpTransactional.const_get(type).new temp_model.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash 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 end end