Improving API vocabulary.
This commit is contained in:
parent
c116768ce9
commit
78cc29b7d6
@ -4,4 +4,6 @@ fromDictionary: aDictionary
|
|||||||
text := aDictionary at: 'text'.
|
text := aDictionary at: 'text'.
|
||||||
id := aDictionary at: 'id'.
|
id := aDictionary at: 'id'.
|
||||||
authorId := aDictionary at: 'author_id'.
|
authorId := aDictionary at: 'author_id'.
|
||||||
|
username := aDictionary at: 'username' ifAbsent: [''] .
|
||||||
|
conversationId := aDictionary at: 'conversation_id' ifAbsent: [ '' ].
|
||||||
^ self
|
^ self
|
@ -1,3 +1,3 @@
|
|||||||
utilities
|
utilities
|
||||||
words
|
words
|
||||||
^ self text splitOn: Character space
|
^ self text allRegexMatches: '\w*'
|
@ -9,7 +9,9 @@
|
|||||||
"created",
|
"created",
|
||||||
"text",
|
"text",
|
||||||
"id",
|
"id",
|
||||||
"authorId"
|
"authorId",
|
||||||
|
"conversationId",
|
||||||
|
"username"
|
||||||
],
|
],
|
||||||
"name" : "Tweet",
|
"name" : "Tweet",
|
||||||
"type" : "normal"
|
"type" : "normal"
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
accessing
|
|
||||||
bearerKey
|
|
||||||
self keys at: 'Bearer Token'
|
|
@ -1,3 +1,7 @@
|
|||||||
accessing
|
accessing
|
||||||
defaultQueryParameters
|
defaultQueryParameters
|
||||||
^ '?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=100'
|
^ Dictionary new
|
||||||
|
at: 'tweetsOrig' put: '?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=100';
|
||||||
|
at: 'tweets' put: '?', 'tweet.fields=created_at', '&', 'expansions=author_id', '&', 'max_results=100';
|
||||||
|
at: 'mentionsOrig' put: '?expansions=author_id&tweet.fields=conversation_id,created_at,lang&user.fields=created_at,entities&max_results=100';
|
||||||
|
yourself
|
@ -0,0 +1,18 @@
|
|||||||
|
accessing
|
||||||
|
userMentionsFor: username since: startDateString
|
||||||
|
| nextToken queryUrl sinceDate untilDate messages response |
|
||||||
|
|
||||||
|
sinceDate := 'start_time=',startDateString, 'T00:00:00Z'.
|
||||||
|
messages := OrderedCollection new.
|
||||||
|
nextToken := ''.
|
||||||
|
[ nextToken includesSubstring: 'stop' ] whileFalse: [
|
||||||
|
queryUrl := self usersBaseEndPoint,
|
||||||
|
(self userIDFrom: username), '/mentions', (self defaultQueryParameters at: 'mentionsOrig') ,
|
||||||
|
'&', sinceDate,
|
||||||
|
'&', nextToken.
|
||||||
|
response := STONJSON fromString: (self rawResponseForURL: queryUrl).
|
||||||
|
(response at: 'data') do: [:tweetData |
|
||||||
|
messages add: (Tweet new fromDictionary: tweetData)
|
||||||
|
].
|
||||||
|
nextToken := 'pagination_token=',((response at: 'meta') at: 'next_token' ifAbsent: [ 'stop' ])].
|
||||||
|
^ messages.
|
@ -0,0 +1,21 @@
|
|||||||
|
accessing
|
||||||
|
userMentionsFor: username since: startDateString until: endDateString
|
||||||
|
| nextToken queryUrl sinceDate untilDate messages response extraQueryParamenters |
|
||||||
|
|
||||||
|
sinceDate := 'start_time=',startDateString, 'T17:00:00Z'.
|
||||||
|
untilDate := 'end_time=',endDateString, 'T01:00:00Z'.
|
||||||
|
extraQueryParamenters := '?expansions=author_id&tweet.fields=conversation_id&user.fields=created_at,entities&max_results=100'.
|
||||||
|
messages := OrderedCollection new.
|
||||||
|
nextToken := ''.
|
||||||
|
[ nextToken includesSubstring: 'stop' ] whileFalse: [
|
||||||
|
queryUrl := self usersBaseEndPoint,
|
||||||
|
(self userIDFrom: username), '/mentions', extraQueryParamenters,
|
||||||
|
'&', sinceDate,
|
||||||
|
"'&', untilDate,"
|
||||||
|
'&', nextToken.
|
||||||
|
response := STONJSON fromString: (self rawResponseForURL: queryUrl).
|
||||||
|
(response at: 'data') do: [:tweetData |
|
||||||
|
messages add: (Tweet new fromDictionary: tweetData)
|
||||||
|
].
|
||||||
|
nextToken := 'pagination_token=',((response at: 'meta') at: 'next_token' ifAbsent: [ 'stop' ])].
|
||||||
|
^ messages.
|
@ -2,13 +2,13 @@ accessing
|
|||||||
userTweetsFrom: username since: startDateString until: endDateString
|
userTweetsFrom: username since: startDateString until: endDateString
|
||||||
| nextToken queryUrl sinceDate untilDate messages response |
|
| nextToken queryUrl sinceDate untilDate messages response |
|
||||||
|
|
||||||
sinceDate := 'start_time=',startDateString, 'T17:00:00Z'.
|
sinceDate := 'start_time=',startDateString, 'T00:00:00Z'.
|
||||||
untilDate := 'end_time=',endDateString, 'T01:00:00Z'.
|
untilDate := 'end_time=',endDateString, 'T23:59:59Z'.
|
||||||
messages := OrderedCollection new.
|
messages := OrderedCollection new.
|
||||||
nextToken := ''.
|
nextToken := ''.
|
||||||
[ nextToken includesSubstring: 'stop' ] whileFalse: [
|
[ nextToken includesSubstring: 'stop' ] whileFalse: [
|
||||||
queryUrl := self usersBaseEndPoint,
|
queryUrl := self usersBaseEndPoint,
|
||||||
(self userIDFrom: username), '/tweets', self defaultQueryParameters,
|
(self userIDFrom: username), '/tweets', (self defaultQueryParameters at: 'tweets'),
|
||||||
'&', sinceDate,
|
'&', sinceDate,
|
||||||
'&', untilDate,
|
'&', untilDate,
|
||||||
'&', nextToken.
|
'&', nextToken.
|
||||||
|
Loading…
Reference in New Issue
Block a user