spontit

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

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

Go to latest
Published: Nov 1, 2020 License: MIT Imports: 7 Imported by: 0

README

Go client for the Spontit API PkgGoDev

Spontit-go is an unofficial Spontit client for the Go programming language.

Installation

go get github.com/FryDay/spontit-go

Usage

Create a .env file in the root of your project and add the following lines:

SPONTIT_USERID=your_user_id
SPONTIT_KEY=your_private_key

Then to create a Spontit client:

package main

import (
	"log"

	"github.com/FryDay/spontit-go"
)

func main() {
	spontitClient, err := spontit.NewClient()
	if err != nil {
		log.Fatal(err)
    }

    // Do things with the client here...
}

Progress

API
  • Push
  • Categories
  • Channel
    • Create
    • Get
    • Change
    • Delete
    • Profile Image
  • Channels
  • Followers
Other
  • Tests
  • Examples

Documentation

Overview

Package spontit provides a client for the Spontit API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	Code  float64 `json:"categoryCode"`
	Title string  `json:"categoryTitle"`
}

Category contains a single category

type Channel

type Channel struct {
	// The display name of your channel.
	Name string `json:"channelName"`
	// Supplied during the creation of a channel. Defines the category for your channel.
	Code float64 `json:"categoryCode,omitempty"`
	// This is generated by the server. The ID of your channel.
	ID string `json:"channelId,omitempty"`
	// This is generated by the server. A unique code with which users can find your channel.
	ReferralCode string `json:"referralCode,omitempty"`
	// This is generated by the server. Instructions for users can join the Spontit app and follow your channel by texting your code to the provided number.
	TextReferral string `json:"textReferralString,omitempty"`
	// This is generated by the server. The unique link to your channel.
	Link string `json:"link,omitempty"`
	// This is generated by the server. A link to a QR code for referring users to your channel.
	QRCodeLink string `json:"qrCodeLink,omitempty"`
	// Currently undocumented.
	AutoAddFutureFollowers bool `json:"autoAddFutureFollowers,omitempty"`
	// Currently undocumented.
	AddAllFollowers bool `json:"addAllFollowers,omitempty"`
}

Channel contains attributes for a channel

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Spontit API client

func NewClient

func NewClient() (*Client, error)

NewClient returns a new Spontit client

func (*Client) Categories

func (c *Client) Categories() ([]*Category, error)

Categories returns available categories

func (*Client) Channels

func (c *Client) Channels() ([]*Channel, error)

Channels returns a list of your channels

func (*Client) CreateChannel

func (c *Client) CreateChannel(name string) (*Channel, error)

CreateChannel creates a channel

func (*Client) DeleteChannel

func (c *Client) DeleteChannel(name string) error

DeleteChannel deletes a channel

func (*Client) Followers

func (c *Client) Followers(channelName string) ([]string, error)

Followers gets the list of usernames that follow a specific channel. Pass an empty string to return followers of your main channel.

func (*Client) GetChannel

func (c *Client) GetChannel(name string) (*Channel, error)

func (*Client) Push

func (c *Client) Push(push *Push) error

Push sends a push notification

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds our clients information

type Push

type Push struct {
	// To provide text in a push, supply one of either "content" or "pushContent" (or both).
	// Limited to 2500 characters. (Required if a value for "pushContent" is not provided).
	Content string `json:"content,omitempty"`
	// If you want to control exactly what shows when the notification pops up, then provide a value for "pushContent".
	// Limited to 100 characters. The value provided for "pushContent" will appear when the notification first pops up.
	// Once the user opens the notification, they will then see the value provided for "pushContent" and for "content" (if any).
	// (Required if a value for "content" is not provided).
	PushContent string `json:"pushContent,omitempty"`
	// The title of push. Appears in bold at the top. Limited to 100 characters.
	PushTitle string `json:"pushTitle,omitempty"`
	// The name of a channel you created.
	// If you have not yet created a channel, simply don't provide this value and the push will be sent to your main account.
	ChannelName string `json:"channelName,omitempty"`
	// The subtitle of your push. Limited to 20 characters. Only appears on iOS devices.
	Subtitle string `json:"subtitle,omitempty"`
	// A link that can be attached to your push. Must be a valid URL.
	Link string `json:"link,omitempty"`
	// An array of userIds to whom to send the notification.
	// If all three attributes 'pushToFollowers', 'pushToPhoneNumbers' and 'pushToEmails' are not supplied, then everyone who follows the channel will receive the push notification.
	// If 'pushToFollowers' is supplied, only those listed in the array will receive the push notification.
	// If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.
	PushToFollowers []string `json:"pushToFollowers,omitempty"`
	// An array of phoneNumbers to whom to send the notification.
	// If all three attributes 'pushToFollowers', 'pushToPhoneNumbers' and 'pushToEmails' are not supplied, then everyone who follows the channel will receive the push notification.
	// If 'pushToPhoneNumbers' is supplied, then we will map the numbers to Spontit accounts and push accordingly.
	// The users specified by 'pushToPhoneNumbers' do not have to follow the specified channel in order to receive the push.
	// However, they can report your push as spam if they do not follow you and do not wish to receive your pushes.
	PushToPhoneNumbers []string `json:"pushToPhoneNumbers,omitempty"`
	// An array of emails to whom to send the notification.
	// If all three attributes 'pushToFollowers', 'pushToPhoneNumbers' and 'pushToEmails' are not supplied, then everyone who follows the channel will receive the push notification.
	// If 'pushToEmails' is supplied, then we will map the emails to Spontit accounts and push accordingly.
	// The users specified by 'pushToEmails' do not have to follow the specified channel in order to receive the push.
	// However, they can report your push as spam if they do not follow you and do not wish to receive your pushes.
	PushToEmails []string `json:"pushToEmails,omitempty"`
	// A Unix timestamp. Schedule a push to be sent at a later date and time.
	Schedule int64 `json:"schedule,omitempty"`
	// A Unix timestamp. When to automatically expire your push notification. The default is 10 days after pushing.
	// The push will become unaccessible within 15-30 minutes of the selected time, but will remain on all device screens until dismissed or clicked.
	ExpirationStamp int64 `json:"expirationStamp,omitempty"`
	// Whether to open the provided link within the iOS app or in Safari. Android PWA opens all links in the default web browser.
	OpenLinkInApp bool `json:"openLinkInApp,omitempty"`
	// Control whether the notification opens to the home feed or to a standalone page with the notification. The default (openInHomeFeed=False) is to open the notification on a standalone page.
	OpenInHomeFeed bool `json:"openInHomeFeed,omitempty"`
	// An iOS deep link. Use this to deep link into other apps. Alternatively, you can provide a universal link in the link attribute and set openLinkInApp to false.
	IOSDeepLink string `json:"iOSDeepLink,omitempty"`
}

Push contains attributes for a push notification

Jump to

Keyboard shortcuts

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