forked from Ilhasoft/goflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from weni-ai/release/0.1.0-goflow-0.144.3
Release/0.1.0 goflow 0.144.3
- Loading branch information
Showing
22 changed files
with
544 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
0.1.0-goflow-0.144.3 | ||
---------- | ||
* Add support for external services actions and events | ||
* Add Support for trigger.params in Msg events | ||
* Add support for trigger.params in ticket events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package assets | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nyaruka/gocommon/uuids" | ||
) | ||
|
||
// ExternalServiceUUID is the UUID of a external service | ||
type ExternalServiceUUID uuids.UUID | ||
|
||
// ExternalService is a third party service that can be called | ||
// | ||
// { | ||
// "uuid": "4e19fc3c-ae17-4f6b-acb5-7d915e29dc27", | ||
// "name": "Third party service integration 1", | ||
// "uuid": "generic third party service", | ||
// } | ||
// | ||
// @asset external_service | ||
type ExternalService interface { | ||
UUID() ExternalServiceUUID | ||
Name() string | ||
Type() string | ||
} | ||
|
||
// ExternalServiceReference is used to reference a external service | ||
type ExternalServiceReference struct { | ||
UUID ExternalServiceUUID `json:"uuid" validate:"required,uuid"` | ||
Name string `json:"name"` | ||
} | ||
|
||
type ExternalServiceCallAction struct { | ||
Name string `json:"name"` | ||
Value string `json:"value"` | ||
} | ||
|
||
type ExternalServiceParam struct { | ||
Data struct { | ||
Value interface{} `json:"value,omitempty"` | ||
} `json:"data,omitempty"` | ||
Filter struct { | ||
Value *ExternalServiceFilterValue `json:"value"` | ||
} `json:"filter,omitempty"` | ||
Type string `json:"type,omitempty"` | ||
VerboseName string `json:"verboseName,omitempty"` | ||
} | ||
|
||
type ExternalServiceFilterValue struct { | ||
Name string `json:"name,omitempty"` | ||
Type string `json:"type,omitempty"` | ||
VerboseName string `json:"verboseName,omitempty"` | ||
} | ||
|
||
func NewExternalServiceParam( | ||
dataValue interface{}, | ||
filterName, | ||
filterType, | ||
filterVerboseName, | ||
pType, | ||
verboseName string, | ||
) *ExternalServiceParam { | ||
p := &ExternalServiceParam{} | ||
p.Data.Value = dataValue | ||
if filterName != "" && filterType != "" && filterVerboseName != "" { | ||
p.Filter.Value = &ExternalServiceFilterValue{} | ||
p.Filter.Value.Name = filterName | ||
p.Filter.Value.Type = filterType | ||
p.Filter.Value.VerboseName = filterVerboseName | ||
} else { | ||
p.Filter.Value = nil | ||
} | ||
p.Type = pType | ||
p.VerboseName = verboseName | ||
return p | ||
} | ||
|
||
// NewExternalServiceReference creates a new external service reference with the given UUID and name | ||
func NewExternalServiceReference(uuid ExternalServiceUUID, name string) *ExternalServiceReference { | ||
return &ExternalServiceReference{UUID: uuid, Name: name} | ||
} | ||
|
||
// Type returns the name of the asset type | ||
func (r *ExternalServiceReference) Type() string { | ||
return "external_service" | ||
} | ||
|
||
// GenericUUID returns the untyped UUID | ||
func (r *ExternalServiceReference) GenericUUID() uuids.UUID { | ||
return uuids.UUID(r.UUID) | ||
} | ||
|
||
// Identity retusns the unique identity of the asset | ||
func (r *ExternalServiceReference) Identity() string { | ||
return string(r.UUID) | ||
} | ||
|
||
// Variable returns whether this a variable (vs concrete) reference | ||
func (r *ExternalServiceReference) Variable() bool { | ||
return false | ||
} | ||
|
||
// String returns a formated string for the external service referenced | ||
func (r *ExternalServiceReference) String() string { | ||
return fmt.Sprintf("%s[uuid=%s,name=%s]", r.Type(), r.Identity(), r.Name) | ||
} | ||
|
||
var _ UUIDReference = (*ExternalServiceReference)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package static | ||
|
||
import ( | ||
"github.com/nyaruka/goflow/assets" | ||
) | ||
|
||
// ExternalService is a JSON serializable implementation of a external service asset | ||
type ExternalService struct { | ||
UUID_ assets.ExternalServiceUUID `json:"uuid" validate:"required,uuid` | ||
Name_ string `json:"name"` | ||
Type_ string `json:"type"` | ||
} | ||
|
||
// NewExternalService creates a new external service | ||
func NewExternalService(uuid assets.ExternalServiceUUID, name string, type_ string) assets.ExternalService { | ||
return &ExternalService{ | ||
UUID_: uuid, | ||
Name_: name, | ||
Type_: type_, | ||
} | ||
} | ||
|
||
// UUID returns the UUIUD of this external service | ||
func (e *ExternalService) UUID() assets.ExternalServiceUUID { return e.UUID_ } | ||
|
||
// Name returns the name of this external service | ||
func (e *ExternalService) Name() string { return e.Name_ } | ||
|
||
// Type returns the type of this external service | ||
func (e *ExternalService) Type() string { return e.Type_ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.