Skip to content

Commit

Permalink
Fixed example activity code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lixingwang committed Aug 12, 2019
1 parent e088276 commit 39b62a9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions docs/content/building-extensions/organizing-code/activity-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,17 @@ func (a *IFTTTActivity) Eval(context activity.Context) (done bool, err error) {
activityLog.Info("The WebHook URL is set to " + iftttURL)

// Create JSON payload. The data is completely optional, and you can also pass value1, value2, and value3 as query parameters or form variables. This content will be passed on to the Action in your Recipe.
var data Payload
data := Payload{}
if context.GetInput(ivValue3) != nil {
data.Value3 = context.GetInput(ivValue3).(string)
}

if context.GetInput(ivValue2) != nil {
data.Value2 = context.GetInput(ivValue2).(string)
}

if context.GetInput(ivValue3) == nil {
data = Payload{Value1: context.GetInput(ivValue1).(string), Value2: context.GetInput(ivValue2).(string)}
} else if context.GetInput(ivValue2) == nil {
data = Payload{Value1: context.GetInput(ivValue1).(string)}
if context.GetInput(ivValue1) != nil {
data.Value1 = context.GetInput(ivValue1).(string)
}

payloadBytes, err := json.Marshal(data)
Expand Down Expand Up @@ -129,6 +134,7 @@ func (a *IFTTTActivity) Eval(context activity.Context) (done bool, err error) {
context.SetOutput(ovResult, strconv.Itoa(resp.StatusCode))
return true, nil
}

```

## activity_test.go
Expand Down

0 comments on commit 39b62a9

Please sign in to comment.