-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/android code refactor #13
Merged
Merged
Conversation
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
- Added Execute function that will handle all requests going forward. ManageTweetsAPI.kt - Created an interface - Added Logging - Created requestbuilder function - Created execute function that takes a builder to perform an API call ManageTweetsAPITest.kt - Updated tests to fit the new format
- Added Execute function that will handle all requests going forward. ManageTweetsAPI.kt - Created an interface - Added Logging - Created requestbuilder function - Created execute function that takes a builder to perform an API call ManageTweetsAPITest.kt - Updated tests to fit the new format build.gradle.kts - excluding license.md from jupiter for android build. - TODO: Make this android specific.
…sVersion from 1.6.2 to 1.7.0-Beta.
…bject was set to HttpMethod.Get to explicitly specify the HTTP method as a GET request. Additionally, the execute method was used instead of get method to send the HTTP request.
The class SearchTweetsAPI now takes in a ClientConfig object as a constructor parameter, instead of creating its own instance. The function search was renamed to searchTweet. The code that creates the HttpRequestBuilder and sets its properties was extracted into a separate function called createRequestBuilder. The HTTP method for the search endpoint was set explicitly to HttpMethod.Get. The URL parameters are now added to the URL using the url.encodedParameters.append method. The ContentType header is set to ContentType.Application.Json. The Authorization header is set using the headers { append(...) syntax. The logic for decoding the response JSON was simplified by directly accessing the TwitterSearch object properties.
…d delete() methods from the ClientConfig class, as well as changing the ContentType used in the submitForm() method from a string literal to a ContentType object.
…e @SerialName("edit_history_tweet_ids") annotation to the editHistoryTweetIds property.
… Tweet class has been replaced with TweetObject. Both TwitterSearch and TweetObject have been annotated with the @serializable annotation to indicate that they can be (de)serialized with Kotlinx Serialization library.
…the test coroutines. runTest is a function provided by the kotlinx.coroutines.test library that is designed for testing coroutines in a synchronous way. This allows for better control over the coroutine execution and makes it easier to test coroutines that depend on specific timing or ordering of operations. Additionally, the deleteTweet function has been updated to take the tweet ID as a parameter instead of using post.data.id!!. This allows the function to be reused for deleting tweets that were not created in the test.
Adding the assertThrows function to the imports. Changing the runBlocking function to runTest. Adding a signatureBuilder variable to the class. Initializing the searchTweetsAPI variable with searchTweetsAPI = SearchTweetsAPI(clientConfig). Changing the query parameter in searchTweets from kotlin to cat. Updating the searchTweets function to URL encode the query parameters. Changing the search function to searchTweet. Changing the println function in searchTweets to assertTrue(tweetObject.isNotEmpty()). Updating the searchTweets_NoResults function to URL encode the query parameters. Changing the assert function in searchTweets_NoResults to assertThrows with a JsonConvertException. Changing the query parameter in searchTweets_hasMedia from kotlin has:media to (from:chromasiv) has:media -is:retweet. Removing the signatureBuilder initialization in searchTweets_hasMedia.
plugin serialization 1.8.10 dokka 1.8.10 added coroutines core and test
…ject as a parameter. Update the recent method to use HttpRequestBuilderWrapper to build the HTTP request. Update the paramMap parameter processing in the recent method to use the url.encodedParameters.append function instead of builder.url.parameters.append. Add content type and authorization headers to the HttpRequestBuilderWrapper object used in the recent method. The purpose of these changes is to refactor the CountTweetsAPI class to use the HttpRequestBuilderWrapper class instead of the HttpRequestBuilder class, which provides a more convenient and safer way to build HTTP requests.
…. The createRequestBuilder function has been removed and instead HttpRequestBuilderWrapper is used to create the HttpRequestBuilder instance.
Remove unused imports Create a client property in the TwitterAuthentication class to be used throughout the class Update getRequestToken and getAccessToken functions to use execute instead of post on the client Refactor getRequestToken to extract the token values into a separate function getTokenValue Refactor getAccessToken to extract the creation of the authorization header string into a separate function createAuthorizationHeaderString and use the function in both getRequestToken and getAccessToken Remove the unnecessary assignment of the Authorization header value to a variable in both getRequestToken and getAccessToken Update getAccessToken to extract the token values using getTokenValue instead of substring operations
…tion for creating and closing ClientConfig instances Use HttpRequestBuilderWrapper to simplify code for making HTTP requests Update content type and HTTP method for making app-only bearer token requests Update submitForm parameters to be named arguments for better readability
Replaced runBlocking with runTest Created an instance of ClientConfig Passed clientConfig to CountTweetsAPI constructor Modified recentTweets function to use runTest instead of runBlocking Updated paramMap to use LinkedHashMap instead of HashMap
…or instead. MyHttpClient can take an argument to create a custom httpclient.
…or instead. MyHttpClient can take an argument to create a custom httpclient.
Change constructor parameters to non-nullable types Replace string concatenation with list-based joinToString Simplify additionalParameters generation Include paramMap entries in oauthBuilder string Update return statement format for buildSignature function"
Added an exclude for LICENSE issue for Android application. Updated ManageTweetsApi and ManageTweetsAPITest to use only OAuth2.0. Removed OAuth1.0 as it's no longer being supported by X.
…nto feature/android-code-refactor
Cleaned up code and added serialname to objects
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am updating the library to fit the new standard of X (ex-twitter). OAuth 2 is required now for everything and 1.1 has been removed.