Module: Twitter::REST::DirectMessages::WelcomeMessages

Includes:
UploadUtils, Utils, Utils
Included in:
API
Defined in:
lib/twitter/rest/direct_messages/welcome_messages.rb

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#create_welcome_message(text, name = nil, options = {}) ⇒ Object

Welcome Message



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 16

def create_welcome_message(text, name = nil, options = {})
  json_options = {
    welcome_message: {
      message_data: {
        text:,
      },
    },
  }
  json_options[:welcome_message][:name] = name if name
  welcome_message_wrapper = perform_request_with_object(:json_post, "/1.1/direct_messages/welcome_messages/new.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper)
  welcome_message_wrapper.welcome_message
end

#create_welcome_message_rule(welcome_message_id, options = {}) ⇒ Object

Welcome Message Rule



61
62
63
64
65
66
67
68
69
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 61

def create_welcome_message_rule(welcome_message_id, options = {})
  json_options = {
    welcome_message_rule: {
      welcome_message_id:,
    },
  }
  rule_wrapper = perform_request_with_object(:json_post, "/1.1/direct_messages/welcome_messages/rules/new.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageRuleWrapper)
  rule_wrapper.welcome_message_rule
end

#destroy_welcome_message(*ids) ⇒ Object



29
30
31
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 29

def destroy_welcome_message(*ids)
  perform_requests(:delete, "/1.1/direct_messages/welcome_messages/destroy.json", ids)
end

#destroy_welcome_message_rule(*ids) ⇒ Object



71
72
73
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 71

def destroy_welcome_message_rule(*ids)
  perform_requests(:delete, "/1.1/direct_messages/welcome_messages/rules/destroy.json", ids)
end

#update_welcome_message(welcome_message_id, text, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 33

def update_welcome_message(welcome_message_id, text, options = {})
  params = {
    id: welcome_message_id,
  }
  json_options = {
    message_data: {
      text:,
    },
  }
  welcome_message_wrapper = perform_request_with_object(:json_put, "/1.1/direct_messages/welcome_messages/update.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper, params)
  welcome_message_wrapper.welcome_message
end

#welcome_message(id, options = {}) ⇒ Object



46
47
48
49
50
51
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 46

def welcome_message(id, options = {})
  options = options.dup
  options[:id] = id
  welcome_message_wrapper = perform_get_with_object("/1.1/direct_messages/welcome_messages/show.json", options, Twitter::DirectMessages::WelcomeMessageWrapper)
  welcome_message_wrapper.welcome_message
end

#welcome_message_list(options = {}) ⇒ Object



53
54
55
56
57
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 53

def welcome_message_list(options = {})
  limit = options.fetch(:count, 20)
  welcome_message_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/list.json", options.merge!(no_default_cursor: true, count: 50, limit:), :welcome_messages, Twitter::DirectMessages::WelcomeMessageWrapper)
  welcome_message_wrappers.collect(&:welcome_message)
end

#welcome_message_rule(id, options = {}) ⇒ Object



75
76
77
78
79
80
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 75

def welcome_message_rule(id, options = {})
  options = options.dup
  options[:id] = id
  rule_wrapper = perform_get_with_object("/1.1/direct_messages/welcome_messages/rules/show.json", options, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
  rule_wrapper.welcome_message_rule
end

#welcome_message_rule_list(options = {}) ⇒ Object



82
83
84
85
86
# File 'lib/twitter/rest/direct_messages/welcome_messages.rb', line 82

def welcome_message_rule_list(options = {})
  limit = options.fetch(:count, 20)
  rule_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/rules/list.json", options.merge!(no_default_cursor: true, count: 50, limit:), :welcome_message_rules, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
  rule_wrappers.collect(&:welcome_message_rule)
end