From b87c834a7e71c6cac6a5ae363f9cd90837f2412a Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 26 Jul 2021 07:46:45 -0500 Subject: [PATCH] Starting TwitterAPIReponse. --- .../instance/userEndPointFor.selecting..st | 7 +++++++ .../TwitterAPI.class/instance/userMentionsFor..st | 6 ++---- .../instance/userQueryFor.selecting..st | 7 +++++++ .../TwitterAPI.class/instance/userTweetsFrom..st | 5 +---- .../TwitterAPIResponse.class/README.md | 0 .../TwitterAPIResponse.class/instance/data..st | 3 +++ .../TwitterAPIResponse.class/instance/data.st | 3 +++ .../instance/fromDictionary..st | 5 +++++ .../instance/includes..st | 3 +++ .../TwitterAPIResponse.class/instance/includes.st | 3 +++ .../TwitterAPIResponse.class/instance/meta..st | 3 +++ .../TwitterAPIResponse.class/instance/meta.st | 3 +++ .../instance/nextToken.st | 3 +++ .../instance/nextTokenPreview.st | 3 +++ .../TwitterAPIResponse.class/instance/printOn..st | 5 +++++ .../TwitterAPIResponse.class/properties.json | 15 +++++++++++++++ 16 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 Datanalitica.package/TwitterAPI.class/instance/userEndPointFor.selecting..st create mode 100644 Datanalitica.package/TwitterAPI.class/instance/userQueryFor.selecting..st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/README.md create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/data..st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/data.st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/fromDictionary..st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/includes..st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/includes.st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/meta..st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/meta.st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/nextToken.st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/nextTokenPreview.st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/instance/printOn..st create mode 100644 Datanalitica.package/TwitterAPIResponse.class/properties.json diff --git a/Datanalitica.package/TwitterAPI.class/instance/userEndPointFor.selecting..st b/Datanalitica.package/TwitterAPI.class/instance/userEndPointFor.selecting..st new file mode 100644 index 0000000..81b2ce4 --- /dev/null +++ b/Datanalitica.package/TwitterAPI.class/instance/userEndPointFor.selecting..st @@ -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 \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPI.class/instance/userMentionsFor..st b/Datanalitica.package/TwitterAPI.class/instance/userMentionsFor..st index b1982aa..9efe433 100644 --- a/Datanalitica.package/TwitterAPI.class/instance/userMentionsFor..st +++ b/Datanalitica.package/TwitterAPI.class/instance/userMentionsFor..st @@ -1,7 +1,5 @@ accessing userMentionsFor: username | rawResponse queryURL | - "The following query gets the last tweets, that is the maximun allowed for a particular user without pagination:" - queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/mentions', self defaultQueryParameters. - rawResponse := self rawResponseForURL:queryURL. - ^ (STONJSON fromString: rawResponse) \ No newline at end of file + "The following query gets the last 100 mentions that is the maximun allowed for a particular user without pagination:" + ^ self userQueryFor: username selecting: 'mentions' \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPI.class/instance/userQueryFor.selecting..st b/Datanalitica.package/TwitterAPI.class/instance/userQueryFor.selecting..st new file mode 100644 index 0000000..450f1a6 --- /dev/null +++ b/Datanalitica.package/TwitterAPI.class/instance/userQueryFor.selecting..st @@ -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) \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPI.class/instance/userTweetsFrom..st b/Datanalitica.package/TwitterAPI.class/instance/userTweetsFrom..st index 9c36f7e..645e09c 100644 --- a/Datanalitica.package/TwitterAPI.class/instance/userTweetsFrom..st +++ b/Datanalitica.package/TwitterAPI.class/instance/userTweetsFrom..st @@ -1,7 +1,4 @@ accessing userTweetsFrom: username - | rawResponse queryURL | "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'. - rawResponse := self rawResponseForURL:queryURL. - ^ (STONJSON fromString: rawResponse) \ No newline at end of file + ^ self userQueryFor: username selecting: 'tweets' \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/README.md b/Datanalitica.package/TwitterAPIResponse.class/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/data..st b/Datanalitica.package/TwitterAPIResponse.class/instance/data..st new file mode 100644 index 0000000..6133d52 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/data..st @@ -0,0 +1,3 @@ +accessing +data: anObject + data := anObject \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/data.st b/Datanalitica.package/TwitterAPIResponse.class/instance/data.st new file mode 100644 index 0000000..664ff01 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/data.st @@ -0,0 +1,3 @@ +accessing +data + ^ data \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/fromDictionary..st b/Datanalitica.package/TwitterAPIResponse.class/instance/fromDictionary..st new file mode 100644 index 0000000..4eb5d95 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/fromDictionary..st @@ -0,0 +1,5 @@ +accessing +fromDictionary: aDictionary + data := aDictionary at: 'data'. + includes := aDictionary at: 'includes'. + meta := aDictionary at: 'meta'. \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/includes..st b/Datanalitica.package/TwitterAPIResponse.class/instance/includes..st new file mode 100644 index 0000000..282180e --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/includes..st @@ -0,0 +1,3 @@ +accessing +includes: anObject + includes := anObject \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/includes.st b/Datanalitica.package/TwitterAPIResponse.class/instance/includes.st new file mode 100644 index 0000000..b8cf758 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/includes.st @@ -0,0 +1,3 @@ +accessing +includes + ^ includes \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/meta..st b/Datanalitica.package/TwitterAPIResponse.class/instance/meta..st new file mode 100644 index 0000000..5d288e8 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/meta..st @@ -0,0 +1,3 @@ +accessing +meta: anObject + meta := anObject \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/meta.st b/Datanalitica.package/TwitterAPIResponse.class/instance/meta.st new file mode 100644 index 0000000..36b6aca --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/meta.st @@ -0,0 +1,3 @@ +accessing +meta + ^ meta \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/nextToken.st b/Datanalitica.package/TwitterAPIResponse.class/instance/nextToken.st new file mode 100644 index 0000000..a8f658d --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/nextToken.st @@ -0,0 +1,3 @@ +accessing +nextToken + ^ self meta at: 'next_token' \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/nextTokenPreview.st b/Datanalitica.package/TwitterAPIResponse.class/instance/nextTokenPreview.st new file mode 100644 index 0000000..25d40bf --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/nextTokenPreview.st @@ -0,0 +1,3 @@ +accessing +nextTokenPreview + ^ (self nextToken copyFrom: 1 to: 7), '...' \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/instance/printOn..st b/Datanalitica.package/TwitterAPIResponse.class/instance/printOn..st new file mode 100644 index 0000000..742d266 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/instance/printOn..st @@ -0,0 +1,5 @@ +accessing +printOn: aStream + super printOn: aStream. + aStream + nextPutAll: '( size: ', self data size asString, ' | next token: ', self nextTokenPreview, ' )' \ No newline at end of file diff --git a/Datanalitica.package/TwitterAPIResponse.class/properties.json b/Datanalitica.package/TwitterAPIResponse.class/properties.json new file mode 100644 index 0000000..463b718 --- /dev/null +++ b/Datanalitica.package/TwitterAPIResponse.class/properties.json @@ -0,0 +1,15 @@ +{ + "commentStamp" : "", + "super" : "Object", + "category" : "Datanalitica-Datanalitica", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ + "data", + "includes", + "meta" + ], + "name" : "TwitterAPIResponse", + "type" : "normal" +} \ No newline at end of file