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

printme() should return string rather than printing #42

Closed
martinthurn opened this issue Jun 27, 2019 · 2 comments
Closed

printme() should return string rather than printing #42

martinthurn opened this issue Jun 27, 2019 · 2 comments

Comments

@martinthurn
Copy link

Or rather, I guess it would be nice to have a new method such as as_string() so that we can get a string and print it to where WE choose (e.g. log file).

@rveachkc
Copy link
Owner

rveachkc commented Jul 2, 2019

Instead of adding another method, would you consider just referencing the payload class attribute?
It's a python object, but can also be dumped to json or pretty printed.

Example:

# setup
teams_message = pymsteams.connectorcard(os.getenv("MS_TEAMS_WEBHOOK"))
teams_message.text("This is a simple text message.")
teams_message.title("Simple Message Title")

# dump to json string
import json
json.dumps(teams_message.payload)
# output: '{"text": "This is a simple text message.", "title": "Simple Message Title"}'

# pretty printing
import pprint
pprint.pprint(teams_message.payload)
# output: {'text': 'This is a simple text message.', 'title': 'Simple Message Title'}

@martinthurn
Copy link
Author

This is good, thank you!

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

No branches or pull requests

2 participants