Starting TwitterAPIReponse.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-07-26 07:46:45 -05:00
parent 23fa2a12f5
commit b87c834a7e
16 changed files with 66 additions and 8 deletions

View File

@ -0,0 +1,7 @@
accessing
userEndPointFor: username selecting: tweetsOrMentions
"I build a shared URL for querying last 100 mentions or tweets for a particular user.
Second parameter should be only 'tweets' or 'mentions', dateString should be YYYY-MM-DD."
| commonQueryParameters |
commonQueryParameters := '?expansions=author_id&tweet.fields=conversation_id,created_at&user.fields=username&max_results=100'.
^ self usersBaseEndPoint, (self userIDFrom: username), '/', tweetsOrMentions, commonQueryParameters

View File

@ -1,7 +1,5 @@
accessing accessing
userMentionsFor: username userMentionsFor: username
| rawResponse queryURL | | rawResponse queryURL |
"The following query gets the last tweets, that is the maximun allowed for a particular user without pagination:" "The following query gets the last 100 mentions that is the maximun allowed for a particular user without pagination:"
queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/mentions', self defaultQueryParameters. ^ self userQueryFor: username selecting: 'mentions'
rawResponse := self rawResponseForURL:queryURL.
^ (STONJSON fromString: rawResponse)

View File

@ -0,0 +1,7 @@
accessing
userQueryFor: username selecting: tweetsOrMentions
| rawResponse queryURL |
"The following query gets the last 100 tweets or mentions that is the maximun allowed for a particular user without pagination:"
queryURL := self userEndPointFor: username selecting: tweetsOrMentions.
rawResponse := self rawResponseForURL:queryURL.
^ TwitterAPIResponse new fromDictionary: (STONJSON fromString: rawResponse)

View File

@ -1,7 +1,4 @@
accessing accessing
userTweetsFrom: username userTweetsFrom: username
| rawResponse queryURL |
"The following query gets the last 100 tweets, that is the maximun allowed for a particular user without pagination:" "The following query gets the last 100 tweets, that is the maximun allowed for a particular user without pagination:"
queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/tweets', self defaultQueryParameters at: 'tweets'. ^ self userQueryFor: username selecting: 'tweets'
rawResponse := self rawResponseForURL:queryURL.
^ (STONJSON fromString: rawResponse)

View File

@ -0,0 +1,3 @@
accessing
data: anObject
data := anObject

View File

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

View File

@ -0,0 +1,5 @@
accessing
fromDictionary: aDictionary
data := aDictionary at: 'data'.
includes := aDictionary at: 'includes'.
meta := aDictionary at: 'meta'.

View File

@ -0,0 +1,3 @@
accessing
includes: anObject
includes := anObject

View File

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

View File

@ -0,0 +1,3 @@
accessing
meta: anObject
meta := anObject

View File

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

View File

@ -0,0 +1,3 @@
accessing
nextToken
^ self meta at: 'next_token'

View File

@ -0,0 +1,3 @@
accessing
nextTokenPreview
^ (self nextToken copyFrom: 1 to: 7), '...'

View File

@ -0,0 +1,5 @@
accessing
printOn: aStream
super printOn: aStream.
aStream
nextPutAll: '( size: ', self data size asString, ' | next token: ', self nextTokenPreview, ' )'

View File

@ -0,0 +1,15 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "Datanalitica-Datanalitica",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"data",
"includes",
"meta"
],
"name" : "TwitterAPIResponse",
"type" : "normal"
}