Back to godoc.org
bitbucket.org/nndi/phada

Package phada

v0.2.0
Latest Go to latest

The highest tagged major version is .

Published: Sep 23, 2019 | License: MIT | Module: bitbucket.org/nndi/phada

Index

type InMemorySessionStore

type InMemorySessionStore struct {
	SessionStore
	// contains filtered or unexported fields
}

InMemorySessionStore

func NewInMemorySessionStore

func NewInMemorySessionStore() *InMemorySessionStore

NewInMemorySessionStore

Creates an inmemory store that uses a concurrent map to store sessions

func (*InMemorySessionStore) Delete

func (m *InMemorySessionStore) Delete(sessionID string)

Delete

func (*InMemorySessionStore) Get

func (m *InMemorySessionStore) Get(sessionID string) (*UssdRequestSession, error)

Get

func (*InMemorySessionStore) PutHop

func (m *InMemorySessionStore) PutHop(ussdRequest *UssdRequestSession) error

PutHop

type RedisSessionStore

type RedisSessionStore struct {
	SessionStore
	// contains filtered or unexported fields
}

RedisSessionStore

func NewRedisSessionStore

func NewRedisSessionStore(redisClient *redis.Client) *RedisSessionStore

NewRedisSessionStore

Creates an inmemory store that uses a concurrent map to store sessions

func (*RedisSessionStore) Delete

func (m *RedisSessionStore) Delete(sessionID string)

Delete

func (*RedisSessionStore) Get

func (m *RedisSessionStore) Get(sessionID string) (*UssdRequestSession, error)

Get

func (*RedisSessionStore) PutHop

func (m *RedisSessionStore) PutHop(ussdRequest *UssdRequestSession) error

PutHop

type SessionStore

type SessionStore interface {
	Get(sessionID string) (*UssdRequestSession, error)
	PutHop(*UssdRequestSession) error
	Delete(sessionID string)
}

/ SessionStore / / Interface for storing session data

type UssdRequestSession

type UssdRequestSession struct {
	PhoneNumber string `json:"phoneNumber"`
	SessionID   string `json:"sessionID"`
	Text        string `json:"text"`
	Channel     string `json:"channel"`
	// The State of the request
	State int `json:"state"`
	// contains filtered or unexported fields
}

/ UssdRequestSession / / go representation of the structure of an AfricasTalking USSD call

func ParseUssdRequest

func ParseUssdRequest(req *http.Request) (*UssdRequestSession, error)

ParseUssdRequestSession

Parse the Request data to a UssdRequestSession if the parameters are present in the body

func (*UssdRequestSession) CountHops

func (u *UssdRequestSession) CountHops() int

Count Hops

Count the number of hops (interactions) for the Ussd session the number of hops is based on the asterisk count so it's approximate

func (*UssdRequestSession) GetHopN

func (u *UssdRequestSession) GetHopN(n int) string

GetHopN

Get the data provided at the nth hop

func (*UssdRequestSession) ReadIn

func (u *UssdRequestSession) ReadIn() string

ReadIn

Reads the last input string recorded for this session

func (*UssdRequestSession) RecordHop

func (u *UssdRequestSession) RecordHop(text string)

func (*UssdRequestSession) RecordHopAndReadIn

func (u *UssdRequestSession) RecordHopAndReadIn(text string) string

RecordHopAndReadIn

Records input string for the ussd session and immediately returns the new input string

func (*UssdRequestSession) SetState

func (u *UssdRequestSession) SetState(state int)

SetState

Set the state for this Ussd session

func (*UssdRequestSession) ToJSON

func (u *UssdRequestSession) ToJSON() string

ToJSON

Convert the UssdRequestSession to JSON string or empty string on error

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier