Documentation
¶
Overview ¶
Package views retrieves data and controls which of it is visible.
This is the only package that should interact directly with Twilio - all other code should talk to this package to determine whether a particular piece of information should be visible, or not.
Example ¶
package main import ( "context" "fmt" "time" "github.com/kevinburke/handlers" "github.com/kevinburke/logrole/config" "github.com/kevinburke/logrole/views" "github.com/kevinburke/nacl" twilio "github.com/kevinburke/twilio-go" ) func main() { c := twilio.NewClient("AC123", "123", nil) key := nacl.NewKey() permission := config.NewPermission(24 * time.Hour) user := config.NewUser(config.AllUserSettings()) vc := views.NewClient(handlers.Logger, c, key, permission) message, _ := vc.GetMessage(context.TODO(), user, "SM123") sid, _ := message.Sid() fmt.Println(sid) }
Output:
Index ¶
- type Alert
- func (a *Alert) CanViewDescription() bool
- func (c *Alert) CanViewProperty(property string) bool
- func (a *Alert) CanViewStatusCode() bool
- func (a *Alert) DateCreated() (twilio.TwilioTime, error)
- func (a *Alert) DateUpdated() (twilio.TwilioTime, error)
- func (a *Alert) Description() (string, error)
- func (a *Alert) ErrorCode() (twilio.Code, error)
- func (a *Alert) LogLevel() (twilio.LogLevel, error)
- func (a *Alert) MoreInfo() (string, error)
- func (a *Alert) RequestMethod() (string, error)
- func (a *Alert) RequestURL() (string, error)
- func (a *Alert) RequestVariables() (twilio.Values, error)
- func (a *Alert) ResourceSid() (string, error)
- func (a *Alert) ResponseBody() (string, error)
- func (a *Alert) ResponseHeaders() (twilio.Values, error)
- func (a *Alert) ServiceSid() (string, error)
- func (a *Alert) Sid() (string, error)
- func (a *Alert) StatusCode() (int, error)
- type AlertPage
- type CacheResult
- type Call
- func (c *Call) CanViewCallAlerts() bool
- func (c *Call) CanViewNumRecordings() bool
- func (c *Call) CanViewProperty(property string) bool
- func (c *Call) DateCreated() (twilio.TwilioTime, error)
- func (c *Call) Direction() (twilio.Direction, error)
- func (c *Call) Duration() (twilio.TwilioDuration, error)
- func (c *Call) Failed() (bool, error)
- func (c *Call) FriendlyPrice() (string, error)
- func (c *Call) From() (twilio.PhoneNumber, error)
- func (c *Call) Sid() (string, error)
- func (c *Call) StartTime() (twilio.TwilioTime, error)
- func (c *Call) Status() (twilio.Status, error)
- func (c *Call) To() (twilio.PhoneNumber, error)
- type CallPage
- type Client
- type Conference
- func (c *Conference) CanViewProperty(property string) bool
- func (c *Conference) DateCreated() (twilio.TwilioTime, error)
- func (c *Conference) FriendlyName() (string, error)
- func (c *Conference) Region() (string, error)
- func (c *Conference) Sid() (string, error)
- func (c *Conference) Status() (twilio.Status, error)
- type ConferencePage
- type IncomingNumber
- func (n *IncomingNumber) Beta() (bool, error)
- func (n *IncomingNumber) CanViewProperty(property string) bool
- func (n *IncomingNumber) Capabilities() (*twilio.NumberCapability, error)
- func (a *IncomingNumber) DateCreated() (twilio.TwilioTime, error)
- func (n *IncomingNumber) EmergencyStatus() (string, error)
- func (n *IncomingNumber) FriendlyName() (string, error)
- func (n *IncomingNumber) PhoneNumber() (twilio.PhoneNumber, error)
- func (n *IncomingNumber) SMSApplicationSid() (string, error)
- func (n *IncomingNumber) SMSFallbackMethod() (string, error)
- func (n *IncomingNumber) SMSFallbackURL() (string, error)
- func (n *IncomingNumber) SMSMethod() (string, error)
- func (n *IncomingNumber) SMSURL() (string, error)
- func (n *IncomingNumber) Sid() (string, error)
- func (n *IncomingNumber) StatusCallback() (string, error)
- func (n *IncomingNumber) StatusCallbackMethod() (string, error)
- func (n *IncomingNumber) TrunkSid() (types.NullString, error)
- func (n *IncomingNumber) VoiceApplicationSid() (string, error)
- func (n *IncomingNumber) VoiceFallbackMethod() (string, error)
- func (n *IncomingNumber) VoiceFallbackURL() (string, error)
- func (n *IncomingNumber) VoiceMethod() (string, error)
- func (n *IncomingNumber) VoiceURL() (string, error)
- type IncomingNumberPage
- type Message
- func (m *Message) Body() (string, error)
- func (m *Message) CanViewMedia() bool
- func (m *Message) CanViewProperty(property string) bool
- func (m *Message) DateCreated() (twilio.TwilioTime, error)
- func (m *Message) Direction() (twilio.Direction, error)
- func (m *Message) ErrorCode() (twilio.Code, error)
- func (m *Message) ErrorMessage() (string, error)
- func (m *Message) FriendlyPrice() (string, error)
- func (m *Message) From() (twilio.PhoneNumber, error)
- func (m *Message) MessagingServiceSid() (types.NullString, error)
- func (m *Message) NumMedia() (twilio.NumMedia, error)
- func (m *Message) NumSegments() (twilio.Segments, error)
- func (m *Message) Price() (string, error)
- func (m *Message) PriceUnit() (string, error)
- func (m *Message) Sid() (string, error)
- func (m *Message) Status() (twilio.Status, error)
- func (m *Message) To() (twilio.PhoneNumber, error)
- type MessagePage
- type Recording
- func (r *Recording) CanPlay() bool
- func (r *Recording) CanViewProperty(property string) bool
- func (r *Recording) DateCreated() (twilio.TwilioTime, error)
- func (r *Recording) Duration() (twilio.TwilioDuration, error)
- func (r *Recording) FriendlyPrice() (string, error)
- func (r *Recording) MediaType() string
- func (r *Recording) Price() (string, error)
- func (r *Recording) PriceUnit() (string, error)
- func (r *Recording) Sid() (string, error)
- func (r *Recording) URL() (string, error)
- type RecordingPage
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct {
// contains filtered or unexported fields
}
func (*Alert) CanViewDescription ¶
func (*Alert) CanViewProperty ¶
func (*Alert) CanViewStatusCode ¶
func (*Alert) DateCreated ¶
func (a *Alert) DateCreated() (twilio.TwilioTime, error)
func (*Alert) DateUpdated ¶
func (a *Alert) DateUpdated() (twilio.TwilioTime, error)
func (*Alert) Description ¶
func (*Alert) RequestMethod ¶
func (*Alert) RequestURL ¶
func (*Alert) ResourceSid ¶
func (*Alert) ResponseBody ¶
func (*Alert) ServiceSid ¶
func (*Alert) StatusCode ¶
type AlertPage ¶
type AlertPage struct {
// contains filtered or unexported fields
}
func NewAlertPage ¶
func (*AlertPage) NextPageURI ¶
func (ap *AlertPage) NextPageURI() types.NullString
func (*AlertPage) PreviousPageURI ¶
func (ap *AlertPage) PreviousPageURI() types.NullString
func (*AlertPage) ShowHeader ¶
type CacheResult ¶
type CacheResult struct { Time uint64 Value interface{} }
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
func (*Call) CanViewCallAlerts ¶
func (*Call) CanViewNumRecordings ¶
func (*Call) CanViewProperty ¶
func (*Call) DateCreated ¶
func (c *Call) DateCreated() (twilio.TwilioTime, error)
func (*Call) FriendlyPrice ¶
type CallPage ¶
type CallPage struct {
// contains filtered or unexported fields
}
func NewCallPage ¶
func (*CallPage) NextPageURI ¶
func (cp *CallPage) NextPageURI() types.NullString
func (*CallPage) PreviousPageURI ¶
func (cp *CallPage) PreviousPageURI() types.NullString
func (*CallPage) ShowHeader ¶
ShowHeader returns true if we should show the table header in the call list view. This is true if the user is allowed to view the fieldName on any message in the list, and true if there are no messages.
type Client ¶
type Client interface { SetBasicAuth(r *http.Request) GetMessage(context.Context, *config.User, string) (*Message, error) GetCall(context.Context, *config.User, string) (*Call, error) GetConference(context.Context, *config.User, string) (*Conference, error) GetIncomingNumber(ctx context.Context, u *config.User, sid string) (*IncomingNumber, error) GetIncomingNumberByPN(ctx context.Context, u *config.User, pn string) (*IncomingNumber, error) GetAlert(context.Context, *config.User, string) (*Alert, error) GetMediaURLs(context.Context, *config.User, string) ([]*url.URL, error) GetMessagePageInRange(context.Context, *config.User, time.Time, time.Time, url.Values) (*MessagePage, uint64, error) GetCallPageInRange(context.Context, *config.User, time.Time, time.Time, url.Values) (*CallPage, uint64, error) GetNumberPage(context.Context, *config.User, url.Values) (*IncomingNumberPage, uint64, error) GetConferencePageInRange(context.Context, *config.User, time.Time, time.Time, url.Values) (*ConferencePage, uint64, error) GetAlertPageInRange(context.Context, *config.User, time.Time, time.Time, url.Values) (*AlertPage, uint64, error) GetNextMessagePageInRange(context.Context, *config.User, time.Time, time.Time, string) (*MessagePage, uint64, error) GetNextNumberPage(context.Context, *config.User, string) (*IncomingNumberPage, uint64, error) GetNextCallPageInRange(context.Context, *config.User, time.Time, time.Time, string) (*CallPage, uint64, error) GetNextConferencePageInRange(context.Context, *config.User, time.Time, time.Time, string) (*ConferencePage, uint64, error) GetNextAlertPageInRange(context.Context, *config.User, time.Time, time.Time, string) (*AlertPage, uint64, error) GetNextRecordingPage(context.Context, *config.User, string) (*RecordingPage, error) GetCallRecordings(context.Context, *config.User, string, url.Values) (*RecordingPage, error) GetCallAlerts(context.Context, *config.User, string) (*AlertPage, error) CacheCommonQueries(uint, <-chan bool) IsTwilioNumber(num twilio.PhoneNumber) bool }
A Client retrieves resources from a backend API, and hides information that shouldn't be seen before returning them to the caller.
type Conference ¶
type Conference struct {
// contains filtered or unexported fields
}
func NewConference ¶
func NewConference(conference *twilio.Conference, p *config.Permission, u *config.User) (*Conference, error)
func (*Conference) CanViewProperty ¶
func (c *Conference) CanViewProperty(property string) bool
func (*Conference) DateCreated ¶
func (c *Conference) DateCreated() (twilio.TwilioTime, error)
func (*Conference) FriendlyName ¶
func (c *Conference) FriendlyName() (string, error)
func (*Conference) Region ¶
func (c *Conference) Region() (string, error)
func (*Conference) Sid ¶
func (c *Conference) Sid() (string, error)
type ConferencePage ¶
type ConferencePage struct {
// contains filtered or unexported fields
}
func NewConferencePage ¶
func NewConferencePage(mp *twilio.ConferencePage, p *config.Permission, u *config.User) (*ConferencePage, error)
func (*ConferencePage) Conferences ¶
func (c *ConferencePage) Conferences() []*Conference
func (*ConferencePage) NextPageURI ¶
func (cp *ConferencePage) NextPageURI() types.NullString
func (*ConferencePage) PreviousPageURI ¶
func (cp *ConferencePage) PreviousPageURI() types.NullString
func (*ConferencePage) ShowHeader ¶
func (cp *ConferencePage) ShowHeader(fieldName string) bool
type IncomingNumber ¶
type IncomingNumber struct {
// contains filtered or unexported fields
}
func NewIncomingNumber ¶
func NewIncomingNumber(pn *twilio.IncomingPhoneNumber, p *config.Permission, u *config.User) (*IncomingNumber, error)
func (*IncomingNumber) Beta ¶
func (n *IncomingNumber) Beta() (bool, error)
func (*IncomingNumber) CanViewProperty ¶
func (n *IncomingNumber) CanViewProperty(property string) bool
func (*IncomingNumber) Capabilities ¶
func (n *IncomingNumber) Capabilities() (*twilio.NumberCapability, error)
func (*IncomingNumber) DateCreated ¶
func (a *IncomingNumber) DateCreated() (twilio.TwilioTime, error)
func (*IncomingNumber) EmergencyStatus ¶
func (n *IncomingNumber) EmergencyStatus() (string, error)
func (*IncomingNumber) FriendlyName ¶
func (n *IncomingNumber) FriendlyName() (string, error)
func (*IncomingNumber) PhoneNumber ¶
func (n *IncomingNumber) PhoneNumber() (twilio.PhoneNumber, error)
func (*IncomingNumber) SMSApplicationSid ¶
func (n *IncomingNumber) SMSApplicationSid() (string, error)
func (*IncomingNumber) SMSFallbackMethod ¶
func (n *IncomingNumber) SMSFallbackMethod() (string, error)
func (*IncomingNumber) SMSFallbackURL ¶
func (n *IncomingNumber) SMSFallbackURL() (string, error)
func (*IncomingNumber) SMSMethod ¶
func (n *IncomingNumber) SMSMethod() (string, error)
func (*IncomingNumber) SMSURL ¶
func (n *IncomingNumber) SMSURL() (string, error)
func (*IncomingNumber) Sid ¶
func (n *IncomingNumber) Sid() (string, error)
func (*IncomingNumber) StatusCallback ¶
func (n *IncomingNumber) StatusCallback() (string, error)
func (*IncomingNumber) StatusCallbackMethod ¶
func (n *IncomingNumber) StatusCallbackMethod() (string, error)
func (*IncomingNumber) TrunkSid ¶
func (n *IncomingNumber) TrunkSid() (types.NullString, error)
func (*IncomingNumber) VoiceApplicationSid ¶
func (n *IncomingNumber) VoiceApplicationSid() (string, error)
func (*IncomingNumber) VoiceFallbackMethod ¶
func (n *IncomingNumber) VoiceFallbackMethod() (string, error)
func (*IncomingNumber) VoiceFallbackURL ¶
func (n *IncomingNumber) VoiceFallbackURL() (string, error)
func (*IncomingNumber) VoiceMethod ¶
func (n *IncomingNumber) VoiceMethod() (string, error)
func (*IncomingNumber) VoiceURL ¶
func (n *IncomingNumber) VoiceURL() (string, error)
type IncomingNumberPage ¶
type IncomingNumberPage struct {
// contains filtered or unexported fields
}
func NewIncomingNumberPage ¶
func NewIncomingNumberPage(pn *twilio.IncomingPhoneNumberPage, p *config.Permission, u *config.User) (*IncomingNumberPage, error)
func (*IncomingNumberPage) NextPageURI ¶
func (p *IncomingNumberPage) NextPageURI() types.NullString
func (*IncomingNumberPage) Numbers ¶
func (p *IncomingNumberPage) Numbers() []*IncomingNumber
func (*IncomingNumberPage) PreviousPageURI ¶
func (p *IncomingNumberPage) PreviousPageURI() types.NullString
func (*IncomingNumberPage) ShowHeader ¶
func (page *IncomingNumberPage) ShowHeader(property string) bool
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewMessage ¶
NewMessage creates a new Message, setting fields to be hidden or shown as appropriate for the given Permission and User.
func (*Message) CanViewMedia ¶
func (*Message) CanViewProperty ¶
CanViewProperty returns true if the caller can access the given property. CanViewProperty panics if the property does not exist. The input is case-sensitive; "MessagingServiceSid" is the correct casing.
func (*Message) DateCreated ¶
func (m *Message) DateCreated() (twilio.TwilioTime, error)
func (*Message) ErrorMessage ¶
func (*Message) FriendlyPrice ¶
func (*Message) MessagingServiceSid ¶
func (m *Message) MessagingServiceSid() (types.NullString, error)
type MessagePage ¶
type MessagePage struct {
// contains filtered or unexported fields
}
func NewMessagePage ¶
func NewMessagePage(mp *twilio.MessagePage, p *config.Permission, u *config.User) (*MessagePage, error)
func (*MessagePage) Messages ¶
func (mp *MessagePage) Messages() []*Message
func (*MessagePage) NextPageURI ¶
func (mp *MessagePage) NextPageURI() types.NullString
func (*MessagePage) PreviousPageURI ¶
func (mp *MessagePage) PreviousPageURI() types.NullString
func (*MessagePage) ShowHeader ¶
func (mp *MessagePage) ShowHeader(fieldName string) bool
ShowHeader returns true if we should show the table header in the message list view. This is true if the user is allowed to view the fieldName on any message in the list, and true if there are no messages.
type Recording ¶
type Recording struct {
// contains filtered or unexported fields
}
func NewRecording ¶
func (*Recording) CanViewProperty ¶
func (*Recording) DateCreated ¶
func (r *Recording) DateCreated() (twilio.TwilioTime, error)
func (*Recording) FriendlyPrice ¶
type RecordingPage ¶
type RecordingPage struct {
// contains filtered or unexported fields
}
func NewRecordingPage ¶
func NewRecordingPage(rp *twilio.RecordingPage, p *config.Permission, u *config.User, key *[32]byte) (*RecordingPage, error)
func (*RecordingPage) NextPageURI ¶
func (r *RecordingPage) NextPageURI() types.NullString
func (*RecordingPage) Recordings ¶
func (r *RecordingPage) Recordings() []*Recording