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

add CustomData param to New-PoshBotCardResponse #89

Conversation

scrthq
Copy link
Contributor

@scrthq scrthq commented Aug 2, 2018

Description

This is to allow custom data to be passed back to SendMessage in the Data stream of the response. Backend developers can leverage this to receive parsable data (i.e. REST body JSON) specific to their card response options. This will also be ignored by the included backends (Slack and Teams), so plugins/backends using this can create functions that will be cross-backend compatible.

Related Issue

#88

Motivation and Context

This is to allow custom data to be passed back to SendMessage in the Data stream of the response and be parsed by custom backends.

How Has This Been Tested?

This has been tested during the buildout of the Google Chat backend I'm adding to PSGSuite currently. PSGSuite itself is tested in PS 5-Core via AppVeyor and Travis CI.

Screenshots:

Google Chat response

image

Slack response

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

This is to allow custom data to be passed back to SendMessage in the Data stream of the response. Backend developers can leverage this to receive parsable data (i.e. REST body JSON) specific to their card response options. This will also be ignored by the included backends (Slack and Teams), so plugins/backends using this can create functions that will be cross-backend compatible.
)

$response = [ordered]@{
PSTypeName = 'PoshBot.Card.Response'
Type = $Type
Text = $Text.Trim()
Private = $PSBoundParameters.ContainsKey('Private')
DM = $PSBoundParameters.ContainsKey('DM')
DM = $PSBoundParameters['DM']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was changed to allow the DM switch to work as expected if someone passed it as -DM:$false. Currently, DM will always equal true if the parameter is present in PSBoundParameters.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

[string]$Color = '#D3D3D3'
[string]$Color = '#D3D3D3',

[object]$CustomData
)

$response = [ordered]@{
PSTypeName = 'PoshBot.Card.Response'
Type = $Type
Text = $Text.Trim()
Private = $PSBoundParameters.ContainsKey('Private')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is Private just here as a reservation or can it be removed as well? The current parameters don't apparently have Private included.

Copy link
Member

Choose a reason for hiding this comment

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

Oooh. That's some old, dead code right there. I'll remove it. Thanks for catching that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure!

@devblackops
Copy link
Member

Thanks for this!

@devblackops devblackops merged commit e414a22 into poshbotio:master Aug 3, 2018
@scrthq scrthq deleted the feature/add_customData_param_to_CardResponse branch August 3, 2018 15:19
@scrthq
Copy link
Contributor Author

scrthq commented Aug 3, 2018

Cheers!

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.

None yet

2 participants