-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add "Create a List" method #7
Conversation
Sources/Twift+Tweets.swift
Outdated
@@ -262,6 +262,13 @@ public struct DeleteResponse: Codable { | |||
public let deleted: Bool | |||
} | |||
|
|||
/// A response object pertaining to list created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type definition should probably live in Twift+Lists.swift
instead of Twift+Tweets.swift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, did not even pay attention to the file I was in. Just saw deletedResponse and thought they would fit nicely together 😂
Sources/Twift+Tweets.swift
Outdated
@@ -262,6 +262,13 @@ public struct DeleteResponse: Codable { | |||
public let deleted: Bool | |||
} | |||
|
|||
/// A response object pertaining to list created | |||
public struct CreatedListResponse: Codable { | |||
/// If the returned response object contains an id and the name of your List, you have successfully created the List. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc comment will only appear when authors look up the id
attribute; you should add doc comments specific to each property and add this comment as a description on the type itself
Sources/Twift+Lists.swift
Outdated
/// - Parameters: | ||
/// - name: List name (required) | ||
/// - description: Description for the list (optional) | ||
/// - private: true or false (optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a nit, but “true or false” is not a super helpful comment when people can see the accepted type is Bool
. Try to describe the meaning of the field, e.g. Whether the list is private to the authenticated user or publicly viewable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not used to writing these types of comments but I did pause for a second and thought if I need more context here.
It so makes sense not to mention true/false if they already see a type.
I hope to get better at this 🤞
Sources/Twift+Lists.swift
Outdated
"description": description ?? "", | ||
"private": isPrivate ?? false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already have default values for description
and isPrivate
, you don't need to do this nullish coalescing. Just make the types for the arguments non-optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, making description
optional does make sense
This is a concern for me too! I don’t yet have a solid testing approach other than adding methods to a test SwiftUI app I have in a private repo. I will plan to stub a new issue specifically to set up a testing suite and strategy. |
Sources/Twift+Lists.swift
Outdated
/// - id: If the returned response object contains an id, response is considered successfull | ||
/// - name: If List name was returned, response is considered successfull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments should be written directly above their respective struct properties so that they show up in Xcode’s quick help and the generated GitHub wiki docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, had no idea 😅
Sources/Twift+Lists.swift
Outdated
} | ||
|
||
/// A response object pertaining to list created | ||
/// - Returns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: since this is a struct and not a function, Returns
isn’t accurate and can be removed
Sources/Twift+Lists.swift
Outdated
/// - Returns: | ||
/// - id: If the returned response object contains an id, response is considered successfull | ||
/// - name: If List name was returned, response is considered successfull | ||
public struct CreatedListResponse: Codable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct shouldn’t be a member of the Twift
class; I’d pull it out from being nested inside the class and put it at the root of this file, along with PinnedResponse
FYI, I really appreciate you being patient with all these explanations 🙌 I will take note of all this in the future as not to have some repeated issues 👌 |
Sources/Twift+Lists.swift
Outdated
/// A response object pertaining to list created | ||
public struct CreatedListResponse: Codable { | ||
/// If returned response object contains an id, response is considered successfull | ||
public let id: Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be typed as List.ID
Of course, thanks for your patience with the reviews and revisions! This is helpful for informing contribution guidelines too. |
Co-authored-by: Daniel Eden <dan.eden@me.com>
@roblack FYI I just updated the main branch to include a demo app; you can use that to test your changes! Feel free to also provide feedback on the demo app since it’s a bit rough-and-ready (just copied from my own sandbox). |
Co-authored-by: Daniel Eden <dan.eden@me.com>
Oh that is awesome! Will check it out and report back once tested. 🙌 |
Yah I’m wondering whether Xcode can drive UI tests in the demo app as a way to test library methods. I have some research to do! |
@roblack ah, the error for preview content may be legit but you should check the readme in the demo app folder to resolve the Secrets error 😇 |
@daneden I kinda thought "secrets" might be something used "per user", especially after seeing some new fields in the plist file. 🤦♂️ I definitely need to take the blindfold off as currently I just do what the comment is and don't really "inspect" things properly. Not sure if this is making sense, but it is to me 😂 Need to be more pro-active! |
@roblack I managed to fix a couple of issues in the demo app so it should build now (maybe after a clean build folder). I'm adding some custom warnings to make it easier to resolve issues too. Thanks for the feedback! |
@daneden HOLLY SHIZZ MAN! 🙌 That app looks/works so good, i love it! 2 notes:
Btw, the "Secrets" thing approach with the .env file is just EPIC, love it! |
@roblack good catch on the URL scheme, added that to the
Thanks! Took me a while to figure out a safe way to simplify setup while avoiding accidentally checking in secrets 😅 still not 100% happy with it but it works. |
Btw I lost track if this PR is good to go? |
Just tested locally and made one small change 😊 it's a small thing, but the Twitter v2 API doesn’t accept requests to paths with trailing slashes, so |
Oh wow, good to know! 🙌 Thank you! |
Create List method was lacking from the "Manage Lists" group.
https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/introduction
Not sure If this is the correct way to do it, but I tried to follow the same approach as for some other similar methods I saw inside Twift.
@daneden Note 👇
The main concern on my end is: "How do I test this?" 😅
So far I've only worked on personal packages and changing branches was easy 👌 However, when contributing I do not know how to test it without having to do quite a bit of duplication 😅