Skip to content
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

Send tweet #1

Merged
merged 1 commit into from
Jul 26, 2023
Merged

Send tweet #1

merged 1 commit into from
Jul 26, 2023

Conversation

samvanryssegem-qz
Copy link
Owner

No description provided.

tweetText = messageRequest.content
}

var request = HTTPClientRequest(url: "https://api.twitter.com/2/tweets")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define the url as a const

}
}

private func createHeader() -> String {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest "createAuthHeader", be as specific as possible

request.body = .bytes(ByteBuffer(data: (try JSONSerialization.data(withJSONObject: jsonText))))
let response = try await httpClient.execute(request, timeout: .seconds(30))
try await httpClient.shutdown()
if response.headers["location"] == [] {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key this off response.status.code

}
}

private func createHeader() -> String {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write a unit test for this function

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set this function to take function inputs rather than reading directly from the environment, that will make unit testing possible

@samvanryssegem-qz samvanryssegem-qz merged commit e638563 into feat-sendmessage-swift Jul 26, 2023
@samvanryssegem-qz samvanryssegem-qz deleted the send_tweet branch July 26, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants