Class: Late::PlatformTarget

Inherits:
ApiModelBase show all
Defined in:
lib/late-sdk/models/platform_target.rb

Defined Under Namespace

Classes: EnumAttributeValidator

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 = {}) ⇒ PlatformTarget

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/late-sdk/models/platform_target.rb', line 132

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Late::PlatformTarget` 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 `Late::PlatformTarget`. 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?(:'platform')
    self.platform = attributes[:'platform']
  end

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



21
22
23
# File 'lib/late-sdk/models/platform_target.rb', line 21

def 
  @account_id
end

#custom_contentObject

Platform-specific text override. When set, this content is used instead of the top-level post content for this platform. Useful for tailoring captions per platform (e.g. keeping tweets under 280 characters).



24
25
26
# File 'lib/late-sdk/models/platform_target.rb', line 24

def custom_content
  @custom_content
end

#custom_mediaObject

Returns the value of attribute custom_media.



26
27
28
# File 'lib/late-sdk/models/platform_target.rb', line 26

def custom_media
  @custom_media
end

#error_categoryObject

Error category for programmatic handling: auth_expired (token expired/revoked), user_content (wrong format/too long), user_abuse (rate limits/spam), account_issue (config problems), platform_rejected (policy violation), platform_error (5xx/maintenance), system_error (Late infra), unknown



49
50
51
# File 'lib/late-sdk/models/platform_target.rb', line 49

def error_category
  @error_category
end

#error_messageObject

Human-readable error message when status is failed. Contains platform-specific error details explaining why the publish failed.



46
47
48
# File 'lib/late-sdk/models/platform_target.rb', line 46

def error_message
  @error_message
end

#error_sourceObject

Who caused the error: user (fix content/reconnect), platform (outage/API change), system (Late issue, rare)



52
53
54
# File 'lib/late-sdk/models/platform_target.rb', line 52

def error_source
  @error_source
end

#platformObject

Supported values: twitter, threads, instagram, youtube, facebook, linkedin, pinterest, reddit, tiktok, bluesky, googlebusiness, telegram



19
20
21
# File 'lib/late-sdk/models/platform_target.rb', line 19

def platform
  @platform
end

#platform_post_idObject

The native post ID on the platform (populated after successful publish)



37
38
39
# File 'lib/late-sdk/models/platform_target.rb', line 37

def platform_post_id
  @platform_post_id
end

#platform_post_urlObject

Public URL of the published post. Included in the response for immediate posts; for scheduled posts, fetch via GET /v1/posts/postId after publish time.



40
41
42
# File 'lib/late-sdk/models/platform_target.rb', line 40

def platform_post_url
  @platform_post_url
end

#platform_specific_dataObject

Returns the value of attribute platform_specific_data.



31
32
33
# File 'lib/late-sdk/models/platform_target.rb', line 31

def platform_specific_data
  @platform_specific_data
end

#published_atObject

Timestamp when the post was published to this platform



43
44
45
# File 'lib/late-sdk/models/platform_target.rb', line 43

def published_at
  @published_at
end

#scheduled_forObject

Optional per-platform scheduled time override (uses post.scheduledFor when omitted)



29
30
31
# File 'lib/late-sdk/models/platform_target.rb', line 29

def scheduled_for
  @scheduled_for
end

#statusObject

Platform-specific status: pending, publishing, published, failed



34
35
36
# File 'lib/late-sdk/models/platform_target.rb', line 34

def status
  @status
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



96
97
98
# File 'lib/late-sdk/models/platform_target.rb', line 96

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



101
102
103
# File 'lib/late-sdk/models/platform_target.rb', line 101

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/late-sdk/models/platform_target.rb', line 77

def self.attribute_map
  {
    :'platform' => :'platform',
    :'account_id' => :'accountId',
    :'custom_content' => :'customContent',
    :'custom_media' => :'customMedia',
    :'scheduled_for' => :'scheduledFor',
    :'platform_specific_data' => :'platformSpecificData',
    :'status' => :'status',
    :'platform_post_id' => :'platformPostId',
    :'platform_post_url' => :'platformPostUrl',
    :'published_at' => :'publishedAt',
    :'error_message' => :'errorMessage',
    :'error_category' => :'errorCategory',
    :'error_source' => :'errorSource'
  }
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



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/late-sdk/models/platform_target.rb', line 275

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



125
126
127
128
# File 'lib/late-sdk/models/platform_target.rb', line 125

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

.openapi_typesObject

Attribute type mapping.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/late-sdk/models/platform_target.rb', line 106

def self.openapi_types
  {
    :'platform' => :'String',
    :'account_id' => :'PlatformTargetAccountId',
    :'custom_content' => :'String',
    :'custom_media' => :'Array<MediaItem>',
    :'scheduled_for' => :'Time',
    :'platform_specific_data' => :'PlatformTargetPlatformSpecificData',
    :'status' => :'String',
    :'platform_post_id' => :'String',
    :'platform_post_url' => :'String',
    :'published_at' => :'Time',
    :'error_message' => :'String',
    :'error_category' => :'String',
    :'error_source' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/late-sdk/models/platform_target.rb', line 242

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      platform == o.platform &&
       == o. &&
      custom_content == o.custom_content &&
      custom_media == o.custom_media &&
      scheduled_for == o.scheduled_for &&
      platform_specific_data == o.platform_specific_data &&
      status == o.status &&
      platform_post_id == o.platform_post_id &&
      platform_post_url == o.platform_post_url &&
      published_at == o.published_at &&
      error_message == o.error_message &&
      error_category == o.error_category &&
      error_source == o.error_source
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


262
263
264
# File 'lib/late-sdk/models/platform_target.rb', line 262

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



268
269
270
# File 'lib/late-sdk/models/platform_target.rb', line 268

def hash
  [platform, , custom_content, custom_media, scheduled_for, platform_specific_data, status, platform_post_id, platform_post_url, published_at, error_message, error_category, error_source].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



203
204
205
206
207
# File 'lib/late-sdk/models/platform_target.rb', line 203

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/late-sdk/models/platform_target.rb', line 297

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



211
212
213
214
215
216
217
218
# File 'lib/late-sdk/models/platform_target.rb', line 211

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  error_category_validator = EnumAttributeValidator.new('String', ["auth_expired", "user_content", "user_abuse", "account_issue", "platform_rejected", "platform_error", "system_error", "unknown"])
  return false unless error_category_validator.valid?(@error_category)
  error_source_validator = EnumAttributeValidator.new('String', ["user", "platform", "system"])
  return false unless error_source_validator.valid?(@error_source)
  true
end