Skip to content

Commit

Permalink
feat: add FCM V1 destination support
Browse files Browse the repository at this point in the history
  • Loading branch information
nitish-sudo authored Mar 1, 2023
1 parent 1e73683 commit 5502d4a
Show file tree
Hide file tree
Showing 10 changed files with 413 additions and 181 deletions.
16 changes: 8 additions & 8 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.sum|^.secrets.baseline$",
"lines": null
},
"generated_at": "2023-01-27T15:07:26Z",
"generated_at": "2023-02-17T05:43:00Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -110,31 +110,31 @@
"hashed_secret": "811424347556b661512671f7a53aafa6aaf03ca2",
"is_secret": false,
"is_verified": false,
"line_number": 41,
"line_number": 42,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "e8e75379ccc030eb8ec988a993ef3c6e6cbd9c98",
"is_secret": false,
"is_verified": false,
"line_number": 154,
"line_number": 178,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "4b0873b633484d5de20b2d8f852a8c07b43336bc",
"is_secret": false,
"is_verified": false,
"line_number": 532,
"line_number": 556,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "76093020087344732c40421926f0a97a6cccc17e",
"is_secret": false,
"is_verified": false,
"line_number": 1159,
"line_number": 1207,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -144,15 +144,15 @@
"hashed_secret": "e8e75379ccc030eb8ec988a993ef3c6e6cbd9c98",
"is_secret": false,
"is_verified": false,
"line_number": 165,
"line_number": 188,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "4b0873b633484d5de20b2d8f852a8c07b43336bc",
"is_secret": false,
"is_verified": false,
"line_number": 627,
"line_number": 650,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -170,7 +170,7 @@
"hashed_secret": "b8473b86d4c2072ca9b08bd28e373e8253e865c4",
"is_secret": false,
"is_verified": false,
"line_number": 8429,
"line_number": 8422,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ language: go
dist: bionic

go:
- 1.16.x
- 1.17.x
- 1.18.x
- 1.19.x
- 1.20.x

notifications:
email: true
Expand All @@ -18,8 +19,8 @@ before_install:
- pyenv global 3.8

install:
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.41.1
- curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.1
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.51.2
- curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

script:
- make travis-ci
Expand All @@ -35,5 +36,5 @@ deploy:
script: npm run semantic-release
skip_cleanup: true
on:
go: '1.16.x'
go: '1.18.x'
branch: main
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
COVERAGE = -coverprofile=coverage.txt -covermode=atomic

all: tidy test lint
travis-ci: test-cov lint scan-gosec tidy
travis-ci: tidy test-cov lint scan-gosec

test:
go test `go list ./...`
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Service Name | Package name

* An [IBM Cloud][ibm-cloud-onboarding] account.
* An Event Notifications Instance
* Go version 1.16 or above.
* Go version 1.18 or above.

## Installation
Install using the command.
Expand Down Expand Up @@ -671,7 +671,7 @@ notificationsSouce := "<notification-source>"
specVersion := "1.0"

notificationDevicesModel := "{\"user_ids\": [\"userId\"]}"
notificationFcmBodyModel := "{\"title\" : \"Portugal vs. Denmark\", \"badge\": \"great match\"}"
notificationFcmBodyModel := "{\"message\": {\"android\": {\"notification\": {\"title\": \"Alert message\",\"body\": \"Bob wants to play Poker\"},\"data\": {\"name\": \"Willie Greenholt\",\"description\": \"notification for the Poker\"}}}}"
notificationAPNsBodyModel := "{\"alert\": \"Game Request\", \"badge\": 5 }"
notificationSafariBodyModel := "{\"aps\":{\"alert\":{\"title\":\"FlightA998NowBoarding\",\"body\":\"BoardinghasbegunforFlightA998.\",\"action\":\"View\"},\"url-args\":[\"boarding\",\"A998\"]}}}"

Expand Down
80 changes: 50 additions & 30 deletions eventnotificationsv1/event_notifications_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,8 @@ func (eventNotifications *EventNotificationsV1) DeleteDestinationWithContext(ctx
return
}

// CreateTagsSubscription : Create a new Tag subscription
// Create a new Tag subscription.
// CreateTagsSubscription : Create a new tag subscription
// Create a new tag subscription.
func (eventNotifications *EventNotificationsV1) CreateTagsSubscription(createTagsSubscriptionOptions *CreateTagsSubscriptionOptions) (result *DestinationTagsSubscriptionResponse, response *core.DetailedResponse, err error) {
return eventNotifications.CreateTagsSubscriptionWithContext(context.Background(), createTagsSubscriptionOptions)
}
Expand Down Expand Up @@ -1425,8 +1425,8 @@ func (eventNotifications *EventNotificationsV1) CreateTagsSubscriptionWithContex
return
}

// ListTagsSubscription : List all Tag Subscriptions
// List all Tag Subscriptions.
// ListTagsSubscription : List all tag subscriptions
// List all tag subscriptions.
func (eventNotifications *EventNotificationsV1) ListTagsSubscription(listTagsSubscriptionOptions *ListTagsSubscriptionOptions) (result *TagsSubscriptionList, response *core.DetailedResponse, err error) {
return eventNotifications.ListTagsSubscriptionWithContext(context.Background(), listTagsSubscriptionOptions)
}
Expand Down Expand Up @@ -1505,8 +1505,8 @@ func (eventNotifications *EventNotificationsV1) ListTagsSubscriptionWithContext(
return
}

// DeleteTagsSubscription : Delete a Tag subcription
// Delete a Tag subcription.
// DeleteTagsSubscription : Delete a tag subscription
// Delete a tag subscription.
func (eventNotifications *EventNotificationsV1) DeleteTagsSubscription(deleteTagsSubscriptionOptions *DeleteTagsSubscriptionOptions) (response *core.DetailedResponse, err error) {
return eventNotifications.DeleteTagsSubscriptionWithContext(context.Background(), deleteTagsSubscriptionOptions)
}
Expand Down Expand Up @@ -2933,6 +2933,15 @@ type DestinationConfigOneOf struct {
// If pre prod enabled.
PreProd *bool `json:"pre_prod,omitempty"`

// FCM project_id.
ProjectID *string `json:"project_id,omitempty"`

// FCM private_key.
PrivateKey *string `json:"private_key,omitempty"`

// FCM client_email.
ClientEmail *string `json:"client_email,omitempty"`

// Authentication type (p8 or p12).
CertType *string `json:"cert_type,omitempty"`

Expand Down Expand Up @@ -3031,6 +3040,18 @@ func UnmarshalDestinationConfigOneOf(m map[string]json.RawMessage, result interf
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "project_id", &obj.ProjectID)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "private_key", &obj.PrivateKey)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "client_email", &obj.ClientEmail)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "cert_type", &obj.CertType)
if err != nil {
return
Expand Down Expand Up @@ -6722,27 +6743,26 @@ func UnmarshalDestinationConfigOneOfChromeDestinationConfig(m map[string]json.Ra
return
}

// DestinationConfigOneOfFcmDestinationConfig : Payload describing an FCM destination configuration.
// DestinationConfigOneOfFcmDestinationConfig : Payload describing an FCM destination configuration. project_id, private_key and client_email for FCM HTTP v1 APIs.
// This model "extends" DestinationConfigOneOf
type DestinationConfigOneOfFcmDestinationConfig struct {
// FCM server_key.
ServerKey *string `json:"server_key" validate:"required"`
ServerKey *string `json:"server_key,omitempty"`

// FCM sender_id.
SenderID *string `json:"sender_id" validate:"required"`
SenderID *string `json:"sender_id,omitempty"`

// If pre prod enabled.
PreProd *bool `json:"pre_prod,omitempty"`
}

// NewDestinationConfigOneOfFcmDestinationConfig : Instantiate DestinationConfigOneOfFcmDestinationConfig (Generic Model Constructor)
func (*EventNotificationsV1) NewDestinationConfigOneOfFcmDestinationConfig(serverKey string, senderID string) (_model *DestinationConfigOneOfFcmDestinationConfig, err error) {
_model = &DestinationConfigOneOfFcmDestinationConfig{
ServerKey: core.StringPtr(serverKey),
SenderID: core.StringPtr(senderID),
}
err = core.ValidateStruct(_model, "required parameters")
return
// FCM project_id.
ProjectID *string `json:"project_id,omitempty"`

// FCM private_key.
PrivateKey *string `json:"private_key,omitempty"`

// FCM client_email.
ClientEmail *string `json:"client_email,omitempty"`
}

func (*DestinationConfigOneOfFcmDestinationConfig) isaDestinationConfigOneOf() bool {
Expand All @@ -6764,6 +6784,18 @@ func UnmarshalDestinationConfigOneOfFcmDestinationConfig(m map[string]json.RawMe
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "project_id", &obj.ProjectID)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "private_key", &obj.PrivateKey)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "client_email", &obj.ClientEmail)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}
Expand Down Expand Up @@ -8121,9 +8153,7 @@ func UnmarshalSubscriptionUpdateAttributesWebhookAttributes(m map[string]json.Ra
return
}

//
// SourcesPager can be used to simplify the use of the "ListSources" method.
//
type SourcesPager struct {
hasNext bool
options *ListSourcesOptions
Expand Down Expand Up @@ -8208,9 +8238,7 @@ func (pager *SourcesPager) GetAll() (allItems []SourceListItem, err error) {
return pager.GetAllWithContext(context.Background())
}

//
// TopicsPager can be used to simplify the use of the "ListTopics" method.
//
type TopicsPager struct {
hasNext bool
options *ListTopicsOptions
Expand Down Expand Up @@ -8295,9 +8323,7 @@ func (pager *TopicsPager) GetAll() (allItems []TopicsListItem, err error) {
return pager.GetAllWithContext(context.Background())
}

//
// DestinationsPager can be used to simplify the use of the "ListDestinations" method.
//
type DestinationsPager struct {
hasNext bool
options *ListDestinationsOptions
Expand Down Expand Up @@ -8382,9 +8408,7 @@ func (pager *DestinationsPager) GetAll() (allItems []DestinationListItem, err er
return pager.GetAllWithContext(context.Background())
}

//
// TagsSubscriptionPager can be used to simplify the use of the "ListTagsSubscription" method.
//
type TagsSubscriptionPager struct {
hasNext bool
options *ListTagsSubscriptionOptions
Expand Down Expand Up @@ -8469,9 +8493,7 @@ func (pager *TagsSubscriptionPager) GetAll() (allItems []TagsSubscriptionListIte
return pager.GetAllWithContext(context.Background())
}

//
// SubscriptionsPager can be used to simplify the use of the "ListSubscriptions" method.
//
type SubscriptionsPager struct {
hasNext bool
options *ListSubscriptionsOptions
Expand Down Expand Up @@ -8556,9 +8578,7 @@ func (pager *SubscriptionsPager) GetAll() (allItems []SubscriptionListItem, err
return pager.GetAllWithContext(context.Background())
}

//
// IntegrationsPager can be used to simplify the use of the "ListIntegrations" method.
//
type IntegrationsPager struct {
hasNext bool
options *ListIntegrationsOptions
Expand Down
Loading

0 comments on commit 5502d4a

Please sign in to comment.