Class: Twitter::DirectMessages::WelcomeMessageWrapper

Inherits:
Identity
  • Object
show all
Defined in:
lib/twitter/direct_messages/welcome_message_wrapper.rb

Overview

Wraps a Twitter welcome message response

Instance Attribute Summary collapse

Attributes inherited from Identity

#id

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, display_uri_attr_reader, object_attr_reader, predicate_attr_reader, uri_attr_reader

Methods included from Utils

flat_pmap, pmap

Constructor Details

#initialize(attrs) ⇒ Twitter::DirectMessages::WelcomeMessageWrapper

Initializes a new WelcomeMessageWrapper

Parameters:

  • attrs (Hash)

    The attributes hash from the API response



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/twitter/direct_messages/welcome_message_wrapper.rb', line 25

def initialize(attrs)
  attrs = read_from_response(attrs)
  message_data = attrs.fetch(:message_data)
  text = message_data.fetch(:text)
  urls = message_data.fetch(:entities).fetch(:urls)

  text = text.gsub(urls.fetch(0).fetch(:url), urls.fetch(0).fetch(:expanded_url)) if urls.any?

  attrs[:welcome_message] = build_welcome_message(attrs, text, message_data)
  super
end

Instance Attribute Details

#created_timestampString (readonly)

The timestamp when the message was created

Examples:

wrapper.created_timestamp

Returns:

  • (String)


14
15
16
# File 'lib/twitter/direct_messages/welcome_message_wrapper.rb', line 14

def created_timestamp
  @created_timestamp
end