Class: Pingram::TemplatePostRequest

Inherits:
ApiModelBase show all
Defined in:
lib/pingram/models/template_post_request.rb

Overview

Request body for creating a template. Include templateId (required) plus any channel-specific fields for the channel in the path. Which fields apply depends on the channel (EMAIL, INAPP_WEB, SMS, PUSH, etc.).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ TemplatePostRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
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
# File 'lib/pingram/models/template_post_request.rb', line 142

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Pingram::TemplatePostRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Pingram::TemplatePostRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'template_id')
    self.template_id = attributes[:'template_id']
  else
    self.template_id = nil
  end

  if attributes.key?(:'html')
    self.html = attributes[:'html']
  end

  if attributes.key?(:'preview_text')
    self.preview_text = attributes[:'preview_text']
  end

  if attributes.key?(:'internal')
    self.internal = attributes[:'internal']
  end

  if attributes.key?(:'subject')
    self.subject = attributes[:'subject']
  end

  if attributes.key?(:'sender_name')
    self.sender_name = attributes[:'sender_name']
  end

  if attributes.key?(:'sender_email')
    self.sender_email = attributes[:'sender_email']
  end

  if attributes.key?(:'migration')
    self.migration = attributes[:'migration']
  end

  if attributes.key?(:'title')
    self.title = attributes[:'title']
  end

  if attributes.key?(:'redirect_url')
    self.redirect_url = attributes[:'redirect_url']
  end

  if attributes.key?(:'image_url')
    self.image_url = attributes[:'image_url']
  end

  if attributes.key?(:'instant')
    self.instant = attributes[:'instant']
  end

  if attributes.key?(:'batch')
    self.batch = attributes[:'batch']
  end

  if attributes.key?(:'text')
    self.text = attributes[:'text']
  end

  if attributes.key?(:'message')
    self.message = attributes[:'message']
  end

  if attributes.key?(:'icon')
    self.icon = attributes[:'icon']
  end

  if attributes.key?(:'url')
    self.url = attributes[:'url']
  end

  if attributes.key?(:'blocks')
    if (value = attributes[:'blocks']).is_a?(Array)
      self.blocks = value
    end
  end

  if attributes.key?(:'username')
    self.username = attributes[:'username']
  end
end

Instance Attribute Details

#batchObject

Returns the value of attribute batch.



54
55
56
# File 'lib/pingram/models/template_post_request.rb', line 54

def batch
  @batch
end

#blocksObject

Slack message blocks (optional).



69
70
71
# File 'lib/pingram/models/template_post_request.rb', line 69

def blocks
  @blocks
end

#htmlObject

HTML body of the email.



23
24
25
# File 'lib/pingram/models/template_post_request.rb', line 23

def html
  @html
end

#iconObject

Web push: icon URL. Slack: bot icon (emoji or URL).



63
64
65
# File 'lib/pingram/models/template_post_request.rb', line 63

def icon
  @icon
end

#image_urlObject

Image URL shown in the in-app notification.



50
51
52
# File 'lib/pingram/models/template_post_request.rb', line 50

def image_url
  @image_url
end

#instantObject

Returns the value of attribute instant.



52
53
54
# File 'lib/pingram/models/template_post_request.rb', line 52

def instant
  @instant
end

#internalObject

Internal editor representation of the email content (e.g. Bee or Redactor JSON). Used for editing and component embedding; the actual email sent to recipients uses the html field.



29
30
31
# File 'lib/pingram/models/template_post_request.rb', line 29

def internal
  @internal
end

#messageObject

Push notification body text. (title is shared with INAPP_WEB above.)



60
61
62
# File 'lib/pingram/models/template_post_request.rb', line 60

def message
  @message
end

#migrationObject

Migration metadata (e.g. from template migration).



41
42
43
# File 'lib/pingram/models/template_post_request.rb', line 41

def migration
  @migration
end

#preview_textObject

Preview text (e.g. for inbox).



26
27
28
# File 'lib/pingram/models/template_post_request.rb', line 26

def preview_text
  @preview_text
end

#redirect_urlObject

URL to open when the user taps the notification.



47
48
49
# File 'lib/pingram/models/template_post_request.rb', line 47

def redirect_url
  @redirect_url
end

#sender_emailObject

Sender email address.



38
39
40
# File 'lib/pingram/models/template_post_request.rb', line 38

def sender_email
  @sender_email
end

#sender_nameObject

Sender display name.



35
36
37
# File 'lib/pingram/models/template_post_request.rb', line 35

def sender_name
  @sender_name
end

#subjectObject

Email subject line.



32
33
34
# File 'lib/pingram/models/template_post_request.rb', line 32

def subject
  @subject
end

#template_idObject

Unique ID for this template within the notification and channel. Required.



20
21
22
# File 'lib/pingram/models/template_post_request.rb', line 20

def template_id
  @template_id
end

#textObject

Message text (SMS or call).



57
58
59
# File 'lib/pingram/models/template_post_request.rb', line 57

def text
  @text
end

#titleObject

Notification title (in-app).



44
45
46
# File 'lib/pingram/models/template_post_request.rb', line 44

def title
  @title
end

#urlObject

Web push: URL to open when the notification is clicked.



66
67
68
# File 'lib/pingram/models/template_post_request.rb', line 66

def url
  @url
end

#usernameObject

Slack bot username.



72
73
74
# File 'lib/pingram/models/template_post_request.rb', line 72

def username
  @username
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



100
101
102
# File 'lib/pingram/models/template_post_request.rb', line 100

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



105
106
107
# File 'lib/pingram/models/template_post_request.rb', line 105

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/pingram/models/template_post_request.rb', line 75

def self.attribute_map
  {
    :'template_id' => :'templateId',
    :'html' => :'html',
    :'preview_text' => :'previewText',
    :'internal' => :'internal',
    :'subject' => :'subject',
    :'sender_name' => :'senderName',
    :'sender_email' => :'senderEmail',
    :'migration' => :'migration',
    :'title' => :'title',
    :'redirect_url' => :'redirectURL',
    :'image_url' => :'imageURL',
    :'instant' => :'instant',
    :'batch' => :'batch',
    :'text' => :'text',
    :'message' => :'message',
    :'icon' => :'icon',
    :'url' => :'url',
    :'blocks' => :'blocks',
    :'username' => :'username'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/pingram/models/template_post_request.rb', line 308

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_nullableObject

List of attributes with nullable: true



135
136
137
138
# File 'lib/pingram/models/template_post_request.rb', line 135

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/pingram/models/template_post_request.rb', line 110

def self.openapi_types
  {
    :'template_id' => :'String',
    :'html' => :'String',
    :'preview_text' => :'String',
    :'internal' => :'String',
    :'subject' => :'String',
    :'sender_name' => :'String',
    :'sender_email' => :'String',
    :'migration' => :'String',
    :'title' => :'String',
    :'redirect_url' => :'String',
    :'image_url' => :'String',
    :'instant' => :'TemplatePostRequestInstant',
    :'batch' => :'TemplatePostRequestBatch',
    :'text' => :'String',
    :'message' => :'String',
    :'icon' => :'String',
    :'url' => :'String',
    :'blocks' => :'Array<Hash<String, Object>>',
    :'username' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/pingram/models/template_post_request.rb', line 269

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      template_id == o.template_id &&
      html == o.html &&
      preview_text == o.preview_text &&
      internal == o.internal &&
      subject == o.subject &&
      sender_name == o.sender_name &&
      sender_email == o.sender_email &&
      migration == o.migration &&
      title == o.title &&
      redirect_url == o.redirect_url &&
      image_url == o.image_url &&
      instant == o.instant &&
      batch == o.batch &&
      text == o.text &&
      message == o.message &&
      icon == o.icon &&
      url == o.url &&
      blocks == o.blocks &&
      username == o.username
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


295
296
297
# File 'lib/pingram/models/template_post_request.rb', line 295

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



301
302
303
# File 'lib/pingram/models/template_post_request.rb', line 301

def hash
  [template_id, html, preview_text, internal, subject, sender_name, sender_email, migration, title, redirect_url, image_url, instant, batch, text, message, icon, url, blocks, username].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



239
240
241
242
243
244
245
246
247
# File 'lib/pingram/models/template_post_request.rb', line 239

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @template_id.nil?
    invalid_properties.push('invalid value for "template_id", template_id cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/pingram/models/template_post_request.rb', line 330

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

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



251
252
253
254
255
# File 'lib/pingram/models/template_post_request.rb', line 251

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @template_id.nil?
  true
end