Beispiel #1
0
// Update make modifications to properties of a phone number via a post
func (act Account) Update(numberSid string, u Update) (Number, error) {
	var p Number
	if !validateNumberSid(numberSid) {
		return p, errors.New("Invalid sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(numbers.Get, act.AccountSid, numberSid), u, act, &p)
	return p, err
}
// UpdateCredentialList allows you to update an CredentialList with a new FriendlyName
// https://www.twilio.com/docs/api/rest/credential-list#instance-post
func (act Account) UpdateCredentialList(u UpdateCredentialList, clSid string) (CredentialListResource, error) {
	var c CredentialListResource
	if !validateCredentialListSid(clSid) {
		return c, errors.New("Invalid ip access control sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(credentialList.Post, act.AccountSid, clSid), u, act, &c)
	return c, err
}
Beispiel #3
0
// Post updates a queue
func (act Account) Post(u Update, queueSid string) (Queue, error) {
	var q Queue
	if !validateQueueSid(queueSid) {
		return q, errors.New("Invalid queue sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(queue.Post, act.AccountSid, queueSid), u, act, &q)
	return q, err
}
Beispiel #4
0
// Update applies a trigger update.
func (act Account) Update(sid string, tu TriggerUpdate) (Trigger, error) {
	var t Trigger
	if !validateTriggerSid(sid) {
		return t, errors.New("Invalid sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(usage.Update, act.AccountSid, sid), tu, act, &t)
	return t, err
}
Beispiel #5
0
// AddCredentialMapping adds a credential list to the domain
// https://www.twilio.com/docs/api/rest/domain#list-post-clm
func (act Account) AddCredentialMapping(u CredentialListUpdate, domainSid string) (Credential, error) {
	var c Credential
	if !validateDomainSid(domainSid) {
		return c, errors.New("Invalid domain sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(domainCredentialList.List, act.AccountSid, domainSid), u, act, &c)
	return c, err
}
// AddCredential allows you to add a new credential to your account
// https://www.twilio.com/docs/api/rest/credential-list#list-post-credential
func (act Account) AddCredential(u CredentialUpdate, clSid string) (CredentialResource, error) {
	var c CredentialResource
	if !validateCredentialListSid(clSid) {
		return c, errors.New("Invalid credential list sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(credential.List, act.AccountSid, clSid), u, act, &c)
	return c, err
}
Beispiel #7
0
// UpdateDomain a SIP domain with any parameters in a NewDomain
// https://www.twilio.com/docs/api/rest/domain#instance-post
func (act Account) UpdateDomain(n NewDomain, domainSid string) (Domain, error) {
	var d Domain
	if !validateDomainSid(domainSid) {
		return d, errors.New("Invalid SIP sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(domain.Post, act.AccountSid, domainSid), n, act, &d)
	return d, err
}
Beispiel #8
0
// AddMapping adds a mapping to the control list on this domain
// https://www.twilio.com/docs/api/rest/domain#subresource-list-post-ipacl
func (act Account) AddMapping(c ControlListUpdate, domainSid string) (Mapping, error) {
	var m Mapping
	if !validateDomainSid(domainSid) {
		return m, errors.New("Invalid sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(domainControlList.List, act.AccountSid, domainSid), c, act, &m)
	return m, err
}
// AddIPAddress allows you to add a new ip address to your account
// https://www.twilio.com/docs/api/rest/ip-access-control-list#list-post-ipaddress
func (act Account) AddIPAddress(u IPAddressUpdate, alSid string) (IPAddressResource, error) {
	var i IPAddressResource
	if !validateMappingSid(alSid) {
		return i, errors.New("Invalid ip access control sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(ipAddress.List, act.AccountSid, alSid), u, act, &i)
	return i, err
}
Beispiel #10
0
// DequeueFront dequeues a member from the front of the queue and perform an action on it
func (act Account) DequeueFront(a Action, queueSid string) (Member, error) {
	var m Member
	if !validateQueueSid(queueSid) {
		return m, errors.New("Invalid queue sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(member.Front, act.AccountSid, queueSid), a, act, &m)
	return m, err
}
// UpdateControlList allows you to update an IPAccessControlList with a new FriendlyName
// https://www.twilio.com/docs/api/rest/ip-access-control-list#instance-post
func (act Account) UpdateControlList(u UpdateControlList, alSid string) (IPAccessControlList, error) {
	var i IPAccessControlList
	if !validateMappingSid(alSid) {
		return i, errors.New("Invalid ip access control sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(ipAccessControlList.Post, act.AccountSid, alSid), u, act, &i)
	return i, err
}
Beispiel #12
0
// Create send a request to create a new Twilio Application.
func (act Account) Create(nr Application) (Resource, error) {
	var r Resource
	if nr.Validate() != nil {
		return r, nr.Validate()
	}
	err := common.SendPostRequest(fmt.Sprintf(applications.Create, act.AccountSid), nr, act, &r)
	return r, err
}
Beispiel #13
0
// SetMute allows (un)muting of participant with callSid in conference with confSid
func (act Account) SetMute(confSid string, callSid string, a ParticipantUpdate) (Participant, error) {
	var p Participant
	if !validateConferenceSid(confSid) {
		return p, errors.New("Invalid conference sid")
	} else if !validateCallSid(callSid) {
		return p, errors.New("Invalid call sid")
	}
	err := common.SendPostRequest(fmt.Sprintf(participant.Get, act.AccountSid, confSid, callSid), a, act, &p)
	return p, err
}
Beispiel #14
0
// Modify is used with a Modification struc to alter the settings of an Application.
func (act Account) Modify(sid string, m Modification) (Resource, error) {
	var r Resource
	if !validateApplicationSid(sid) {
		return r, errors.New("Invalid application sid")
	}
	if m.Validate() != nil {
		return r, m.Validate()
	}
	err := common.SendPostRequest(fmt.Sprintf(applications.Update, act.AccountSid, sid), m, act, &r)
	return r, err
}
Beispiel #15
0
// CreateQueue creates a new queue on this account, optionally with a specified FriendlyName
// and MaxSize
// http://www.twilio.com/docs/api/rest/queue#list-post
func (act Account) CreateQueue(u Update) (Queue, error) {
	var q Queue
	err := common.SendPostRequest(fmt.Sprintf(queue.List, act.AccountSid), u, act, &q)
	return q, err
}
Beispiel #16
0
// Modify sends an update to the account for the info of an account. The new version of the
// account is returned.
func (act Account) Modify(m Modification) (Resource, error) {
	var r Resource
	err := common.SendPostRequest(fmt.Sprintf(account.Update, act.AccountSid), m, act, &r)
	return r, err
}
// AddControlList allows you to add a new IPAccessControlList to your account
// https://www.twilio.com/docs/api/rest/ip-access-control-list#list-post
func (act Account) AddControlList(u UpdateControlList) (IPAccessControlList, error) {
	var i IPAccessControlList
	err := common.SendPostRequest(fmt.Sprintf(ipAccessControlList.List, act.AccountSid), u, act, &i)
	return i, err
}
Beispiel #18
0
// CreateDomain creates a new SIP domain which will be added to list of domains via a post
// https://www.twilio.com/docs/api/rest/domain#list-post
func (act Account) CreateDomain(n NewDomain) (Domain, error) {
	var d Domain
	err := common.SendPostRequest(fmt.Sprintf(domain.List, act.AccountSid), n, act, &d)
	return d, err
}
Beispiel #19
0
// Call creates a new call with Twilio.
// https://www.twilio.com/docs/api/rest/making-calls#post
func (act Account) Call(p Call) (Resource, error) {
	var r Resource
	err := common.SendPostRequest(fmt.Sprintf(postURL, act.AccountSid), p, act, &r)
	return r, err
}
Beispiel #20
0
// Update sends an update to a Twilio call.
func (act Account) Update(p Update, sid string) (Resource, error) {
	var r Resource
	err := common.SendPostRequest(fmt.Sprintf(updateURL, act.AccountSid, sid), p, act, &r)
	return r, err
}
// AddCredentialList allows you to add a new CredentialList to your account
// https://www.twilio.com/docs/api/rest/credential-list#list-post
func (act Account) AddCredentialList(u UpdateCredentialList) (CredentialListResource, error) {
	var c CredentialListResource
	err := common.SendPostRequest(fmt.Sprintf(credentialList.List, act.AccountSid), u, act, &c)
	return c, err
}
Beispiel #22
0
// PurchaseMobile buys a mobile number if an appropriate number is found
func (act Account) PurchaseMobile(n Selector) (Number, error) {
	var p Number
	err := common.SendPostRequest(fmt.Sprintf(numbers.Mobile, act.AccountSid), n, act, &p)
	return p, err
}
Beispiel #23
0
// Send a post request to Twilio to send a sms request.
func (act Account) Send(p Post) (Message, error) {
	var m Message
	err := common.SendPostRequest(fmt.Sprintf(sms.Post, act.AccountSid), p, act, &m)
	return m, err
}
Beispiel #24
0
// NewTrigger creates a new Twilio usage trigger.
func (act Account) NewTrigger(nt NewTrigger) (Trigger, error) {
	var t Trigger
	err := common.SendPostRequest(fmt.Sprintf(usage.Create, act.AccountSid), nt, act, &t)
	return t, err
}