Skip to content

Commit 7a3d856

Browse files
feat: sns (#255)
1 parent c2b251f commit 7a3d856

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

app.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type AppSettings struct {
2828
SqsURL *string `json:"sqs_url,omitempty"`
2929
SqsKey *string `json:"sqs_key,omitempty"`
3030
SqsSecret *string `json:"sqs_secret,omitempty"`
31+
SnsTopicArn *string `json:"sns_topic_arn,omitempty"`
32+
SnsKey *string `json:"sns_key,omitempty"`
33+
SnsSecret *string `json:"sns_secret,omitempty"`
3134
BeforeMessageSendHookURL *string `json:"before_message_send_hook_url,omitempty"`
3235
CustomActionHandlerURL *string `json:"custom_action_handler_url,omitempty"`
3336

@@ -225,6 +228,25 @@ func (c *Client) CheckSqs(ctx context.Context, req *CheckSQSRequest) (*CheckSQSR
225228
return &resp, err
226229
}
227230

231+
type CheckSNSRequest struct {
232+
SnsTopicARN string `json:"sns_topic_arn"`
233+
SnsKey string `json:"sns_key"`
234+
SnsSecret string `json:"sns_secret"`
235+
}
236+
237+
type CheckSNSResponse struct {
238+
Status string `json:"status"`
239+
Error string `json:"error"`
240+
Data map[string]interface{} `json:"data"`
241+
Response
242+
}
243+
244+
func (c *Client) CheckSns(ctx context.Context, req *CheckSNSRequest) (*CheckSNSResponse, error) {
245+
var resp CheckSNSResponse
246+
err := c.makeRequest(ctx, http.MethodPost, "check_sns", nil, req, &resp)
247+
return &resp, err
248+
}
249+
228250
type CheckPushRequest struct {
229251
MessageID string `json:"message_id,omitempty"`
230252
ApnTemplate string `json:"apn_template,omitempty"`

app_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ func TestClient_CheckSqs(t *testing.T) {
8585
require.NotNil(t, resp.Data)
8686
}
8787

88+
func TestClient_CheckSns(t *testing.T) {
89+
c := initClient(t)
90+
ctx := context.Background()
91+
92+
req := &CheckSNSRequest{SnsTopicARN: "arn:aws:sns:us-east-1:123456789012:sns-topic", SnsKey: "key", SnsSecret: "secret"}
93+
resp, err := c.CheckSns(ctx, req)
94+
95+
require.NoError(t, err)
96+
require.NotEmpty(t, resp.Error)
97+
require.Equal(t, "error", resp.Status)
98+
require.NotNil(t, resp.Data)
99+
}
100+
88101
func TestClient_CheckPush(t *testing.T) {
89102
c := initClient(t)
90103
ch := initChannel(t, c)

0 commit comments

Comments
 (0)