notification

package module
v0.0.0-...-a47768e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 7 Imported by: 0

README

notification

Go Report Card PkgGoDev

A simple notification library written in golang.

Installation

$ go get -u github.com/ispec-inc/notification

Usage

n := notification.NewAWS(
    "YOUR AWS Access Key",
    "YOUR AWS Secret Key",
    "YOUR AWS Platform Application ARN",
)
ipt := notification.Input{
    Title: "Hello",
    Message: "Message",
    DeviceToken: "iOS Device Token",
}
err := n.Send(ipt)
if err != nil {
    //handling error
}

In the test time, you can use mock_notification package. Also in the development time, you can use LocalPublisher which logging the notification information in console.

LICENCE

Copyright © 2017 Yusuke Yamada MIT license

Documentation

Overview

Package notification provides a system by which it is possible to mock your objects and verify calls are happening as expected.

Example Usage n := notification.NewAWS(

"YOUR AWS Access Key",
"YOUR AWS Secret Key",
"YOUR AWS Platform Application ARN",

)

ipt := notification.Input{
    Title: "Hello",
    Message: "Message",
    DeviceToken: "iOS Device Token",
}

err := n.Send(ipt)

if err != nil {
    //handling error
}

Index

Constants

View Source
const Version = "0.1.0"

The main version number that is being run at the moment.

Variables

View Source
var GitCommit string

The git commit that was compiled. This will be filled in by the compiler.

View Source
var VersionPrerelease = ""

A pre-release marker for the version. If this is "" (empty string) then it means that it is a final release. Otherwise, this is a pre-release such as "dev" (in development)

Functions

This section is empty.

Types

type AWSPublisher

type AWSPublisher struct {
	PlatformApplicationArn string
	SNS                    *sns.SNS
}

AWSPublisher is a AWS SNS implementation of the `Service` interface

func NewAWS

func NewAWS(
	accessKey string,
	secretKey string,
	arn string,
) AWSPublisher

NewAWS is a contructor of the `AWSPublisher`

func (AWSPublisher) Send

func (a AWSPublisher) Send(input Input) error

Send a notification by using AWS SNS

type Input

type Input struct {
	Title       string
	Message     string
	URL         string
	DeviceToken string
}

Input is a struct which input to `Send` method of `Service` interface.

type LocalLogger

type LocalLogger struct {
}

LocalLogger is a logginng the notification information in console. Thisis an implementation of the `Service` interface

func NewLocal

func NewLocal() LocalLogger

func (LocalLogger) Send

func (l LocalLogger) Send(input Input) error

type Service

type Service interface {
	Send(input Input) error
}

Service is an interface of notification.

Directories

Path Synopsis
Package mock_notification is a generated GoMock package.
Package mock_notification is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL