Documentation
¶
Index ¶
- type InMemorySessionStore
- type RedisSessionStore
- type RistrettoSessionStore
- type SessionStore
- type UssdRequestSession
- func (u *UssdRequestSession) CountHops() int
- func (u *UssdRequestSession) GetHopN(n int) string
- func (u *UssdRequestSession) ReadIn() string
- func (u *UssdRequestSession) RecordHop(text string)
- func (u *UssdRequestSession) RecordHopAndReadIn(text string) string
- func (u *UssdRequestSession) SetState(state int)
- func (u *UssdRequestSession) ToJSON() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) Get ¶
func (m *RedisSessionStore) Get(sessionID string) (*UssdRequestSession, error)
Get
func (*RedisSessionStore) PutHop ¶
func (m *RedisSessionStore) PutHop(ussdRequest *UssdRequestSession) error
PutHop
type RistrettoSessionStore ¶
type RistrettoSessionStore struct {
SessionStore
// contains filtered or unexported fields
}
RistrettoSessionStore
func NewRistrettoSessionStore ¶
func NewRistrettoSessionStore() *RistrettoSessionStore
NewRistrettoSessionStore
Creates an inmemory store that uses a concurrent map to store sessions
func (*RistrettoSessionStore) Delete ¶
func (m *RistrettoSessionStore) Delete(sessionID string)
Delete
func (*RistrettoSessionStore) Get ¶
func (m *RistrettoSessionStore) Get(sessionID string) (*UssdRequestSession, error)
Get
func (*RistrettoSessionStore) PutHop ¶
func (m *RistrettoSessionStore) 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:"-"` // Deprecated - no longer being used
NetworkCode string `json:"networkCode"`
ServiceCode string `json:"serviceCode"`
// The State of the request
State int `json:"-"`
// 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