Initial Tweet object to start querying.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-06-30 18:58:53 -05:00
parent 99436b6ebb
commit c116768ce9
11 changed files with 46 additions and 9 deletions

View File

@ -0,0 +1,3 @@
accessing
created
^ created

View File

@ -0,0 +1,7 @@
accessing
fromDictionary: aDictionary
created := (aDictionary at: 'created_at') asDateAndTime.
text := aDictionary at: 'text'.
id := aDictionary at: 'id'.
authorId := aDictionary at: 'author_id'.
^ self

View File

@ -0,0 +1,3 @@
queries
mentions: aWord
^ self text includesSubstring: aWord

View File

@ -0,0 +1,5 @@
accessing
printOn: aStream
super printOn: aStream.
aStream
nextPutAll: '( ',self text ,' )'

View File

@ -0,0 +1,3 @@
accessing
text
^ text

View File

@ -0,0 +1,3 @@
utilities
words
^ self text splitOn: Character space

View File

@ -0,0 +1,3 @@
accessing
wordsInLowercase
^ self words collect: [:word | word asLowercase ]

View File

@ -0,0 +1,16 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "Datanalitica",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"created",
"text",
"id",
"authorId"
],
"name" : "Tweet",
"type" : "normal"
}

View File

@ -1,8 +0,0 @@
accessing
userTweetsFor: username
| rawResponse queryURL parameters |
"The following query gets the last 100 tweets, that is the maximun allowed for a particular user without pagination:"
parameters := '?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=100'.
queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/tweets', parameters.
rawResponse := self rawResponseForURL:queryURL.
^ (STONJSON fromString: rawResponse)

View File

@ -13,6 +13,8 @@ userTweetsFrom: username since: startDateString until: endDateString
'&', untilDate, '&', untilDate,
'&', nextToken. '&', nextToken.
response := STONJSON fromString: (self rawResponseForURL: queryUrl). response := STONJSON fromString: (self rawResponseForURL: queryUrl).
messages addAll: (response at: 'data'). (response at: 'data') do: [:tweetData |
messages add: (Tweet new fromDictionary: tweetData)
].
nextToken := 'pagination_token=',((response at: 'meta') at: 'next_token' ifAbsent: [ 'stop' ])]. nextToken := 'pagination_token=',((response at: 'meta') at: 'next_token' ifAbsent: [ 'stop' ])].
^ messages. ^ messages.