-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
1,086 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
debug.fullTrace=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'twitter/creatable' | ||
require 'twitter/entities' | ||
require 'twitter/identity' | ||
|
||
module Twitter | ||
module DirectMessages | ||
class WelcomeMessage < Twitter::Identity | ||
include Twitter::Creatable | ||
include Twitter::Entities | ||
# @return [String] | ||
attr_reader :text | ||
# @return [String] | ||
attr_reader :name | ||
alias full_text text | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'twitter/creatable' | ||
require 'twitter/identity' | ||
|
||
module Twitter | ||
module DirectMessages | ||
class WelcomeMessageRule < Twitter::Identity | ||
include Twitter::Creatable | ||
# @return [Integer] | ||
attr_reader :welcome_message_id | ||
end | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
lib/twitter/direct_messages/welcome_message_rule_wrapper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'twitter/creatable' | ||
require 'twitter/identity' | ||
|
||
module Twitter | ||
module DirectMessages | ||
class WelcomeMessageRuleWrapper < Twitter::Identity | ||
attr_reader :created_timestamp | ||
|
||
object_attr_reader 'DirectMessages::WelcomeMessageRule', :welcome_message_rule | ||
|
||
def initialize(attrs) | ||
attrs = read_from_response(attrs) | ||
|
||
attrs[:welcome_message_rule] = build_welcome_message_rule(attrs) | ||
super | ||
end | ||
|
||
private | ||
|
||
# @return [Hash] Normalized hash of attrs | ||
def read_from_response(attrs) | ||
return attrs[:welcome_message_rule] unless attrs[:welcome_message_rule].nil? | ||
attrs | ||
end | ||
|
||
def build_welcome_message_rule(attrs) | ||
{ | ||
id: attrs[:id].to_i, | ||
created_at: Time.at(attrs[:created_timestamp].to_i / 1000.0), | ||
welcome_message_id: attrs[:welcome_message_id].to_i, | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'twitter/creatable' | ||
require 'twitter/identity' | ||
|
||
module Twitter | ||
module DirectMessages | ||
class WelcomeMessageWrapper < Twitter::Identity | ||
attr_reader :created_timestamp | ||
|
||
object_attr_reader 'DirectMessages::WelcomeMessage', :welcome_message | ||
|
||
def initialize(attrs) | ||
attrs = read_from_response(attrs) | ||
text = attrs.dig(:message_data, :text) | ||
urls = attrs.dig(:message_data, :entities, :urls) | ||
|
||
text.gsub!(urls[0][:url], urls[0][:expanded_url]) if urls.any? | ||
|
||
attrs[:welcome_message] = build_welcome_message(attrs, text) | ||
super | ||
end | ||
|
||
private | ||
|
||
# @return [Hash] Normalized hash of attrs | ||
def read_from_response(attrs) | ||
return attrs[:welcome_message] unless attrs[:welcome_message].nil? | ||
attrs | ||
end | ||
|
||
def build_welcome_message(attrs, text) | ||
{ | ||
id: attrs[:id].to_i, | ||
created_at: Time.at(attrs[:created_timestamp].to_i / 1000.0), | ||
text: text, | ||
name: attrs[:name], | ||
entities: attrs.dig(:message_data, :entities), | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.