Пример #1
0
// List returns a list of all transcriptions associated with the account.
func (act Account) List() (List, error) {
	var tl List
	// err := act.getTranscriptionList(fmt.Sprintf(transcriptions.List, act.AccountSid), &tl)
	err := common.SendGetRequest(fmt.Sprintf(transcriptions.List, act.AccountSid), act, &tl)
	tl.act = &act
	return tl, err
}
Пример #2
0
// GetTrigger returns a Trigger object based on the sid.
func (act Account) GetTrigger(sid string) (Trigger, error) {
	var t Trigger
	if !validateTriggerSid(sid) {
		return t, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(usage.Get, act.AccountSid, sid), act, &t)
	return t, err
}
Пример #3
0
// GetConnectApp returns the resource for a specific ConnectApp.
func (act Account) GetConnectApp(sid string) (ConnectApp, error) {
	var c ConnectApp
	if !validateConnectAppSid(sid) {
		return c, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(connectApps.Get, act.AccountSid, sid), act, &c)
	return c, err
}
Пример #4
0
// Get returns all information about an Application.
func (act Account) Get(sid string) (Resource, error) {
	var r Resource
	if !validateApplicationSid(sid) {
		return r, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(applications.Get, act.AccountSid, sid), act, &r)
	return r, err
}
Пример #5
0
// Get a message given that message's sid.
func (act Account) Get(sid string) (Message, error) {
	var m Message
	if !validateSmsSid(sid) {
		return m, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(sms.Get, act.AccountSid, sid), act, &m)
	return m, err
}
Пример #6
0
// Front returns the front member of a queue
// http://www.twilio.com/docs/api/rest/member#instance-get
func (act Account) Front(queueSid string) (Member, error) {
	var m Member
	if !validateQueueSid(queueSid) {
		return m, errors.New("Invalid queue sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(member.Front, act.AccountSid, queueSid), act, &m)
	return m, err
}
Пример #7
0
// GetMediaList returns a list of media contained in the MMS message identified by the provided sid.
func (act Account) GetMediaList(mmsSid string) (MediaList, error) {
	var m MediaList
	if !validateMediaSid(mmsSid) {
		return m, errors.New("Invalid mms message sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(media.List, act.AccountSid, mmsSid), act, &m)
	return m, err
}
Пример #8
0
// Get returns data about a transcription as a json.
// Can get .mp3 or .wav of recording from the uri provided in Recording
func (act Account) Get(trSid string) (Transcription, error) {
	var r Transcription
	if !validateTranscriptionSid(trSid) {
		return r, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(transcriptions.Get, act.AccountSid, string(trSid)), act, &r)
	return r, err
}
// GetControlList allows you to get an IPAccessControlList
// https://www.twilio.com/docs/api/rest/ip-access-control-list#instance-get
func (act Account) GetControlList(alSid string) (IPAccessControlList, error) {
	var i IPAccessControlList
	if !validateMappingSid(alSid) {
		return i, errors.New("Invalid ip access control sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(ipAccessControlList.Get, act.AccountSid, alSid), act, i)
	return i, err
}
Пример #10
0
// Get returns a call resource record.
// https://www.twilio.com/docs/api/rest/call#instance-get
func (act Account) Get(sid string) (Resource, error) {
	var m Resource
	if !validateCallSid(sid) {
		return m, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(getURL, act.AccountSid, sid), act, &m)
	return m, err
}
Пример #11
0
// Get returns a shortcode message resource given a sid.
func (act Account) Get(sid string) (Message, error) {
	var r Message
	if !validateShortcodeSid(sid) {
		return r, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(short.Get, act.AccountSid, sid), act, &r)
	return r, err
}
Пример #12
0
// Get a info about a number with it's NumberSid
func (act Account) Get(numberSid string) (Number, error) {
	var p Number
	if !validateNumberSid(numberSid) {
		return p, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(numbers.Get, act.AccountSid, numberSid), act, &p)
	return p, err
}
Пример #13
0
// Get returns data about recording as json.
// Can get .mp3 or .wav of recording from the uri provided in Recording
func (act Account) Get(recSid string) (Recording, error) {
	var r Recording
	if !validateRecordingSid(recSid) {
		return r, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(recordings.Get, act.AccountSid, recSid), act, &r)
	return r, err
}
Пример #14
0
// GetCredentialList allows you to get an CredentialList
// https://www.twilio.com/docs/api/rest/credential-list#instance-get
func (act Account) GetCredentialList(clSid string) (CredentialListResource, error) {
	var c CredentialListResource
	if !validateCredentialSid(clSid) {
		return c, errors.New("Invalid credential list sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(credentialList.Get, act.AccountSid, clSid), act, &c)
	return c, err
}
Пример #15
0
// GetDomain gets a domain with a given SIP sid for this account
// https://www.twilio.com/docs/api/rest/domain#instance-get
func (act Account) GetDomain(domainSid string) (Domain, error) {
	var d Domain
	if !validateDomainSid(domainSid) {
		return d, errors.New("Invalid SIP sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(domain.Get, act.AccountSid, domainSid), act, &d)
	return d, err
}
Пример #16
0
// Get retrieves a Twilio error log based off of the sid of the notification.
func (act Account) Get(sid string) (Notification, error) {
	var r Notification
	if !validateNotificationSid(sid) {
		return r, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(notifications.Get, act.AccountSid, sid), act, &r)
	return r, err
}
Пример #17
0
// Get info about a conference identified by a ConferenceSID
func (act Account) Get(confSid string) (Conference, error) {
	var c Conference
	if !validateConferenceSid(confSid) {
		return c, errors.New("Invalid sid")
	}

	err := common.SendGetRequest(fmt.Sprintf(conference.Get, act.AccountSid, confSid), act, &c)
	return c, err
}
// ListIPAddresses grabs a list of all IPAddresses for this account
// https://www.twilio.com/docs/api/rest/ip-access-control-list#list-get-ipaddress
func (act Account) ListIPAddresses(alSid string) (IPAddressList, error) {
	var il IPAddressList
	if !validateMappingSid(alSid) {
		return il, errors.New("Invalid ip access control sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(ipAddress.List, act.AccountSid, alSid), act, &il)
	il.act = &act
	return il, err
}
Пример #19
0
// Get a queue with the given SID.
func (act Account) Get(queueSid string) (Queue, error) {
	var q Queue
	if !validateQueueSid(queueSid) {
		return q, errors.New("Invalid queue sid")
	}

	err := common.SendGetRequest(fmt.Sprintf(queue.Get, act.AccountSid, queueSid), act, &q)
	return q, err
}
Пример #20
0
// ListCredentialMappings grabs a list of all credential mappings for this account and domain
// https://www.twilio.com/docs/api/rest/domain#list-get-clm
func (act Account) ListCredentialMappings(domainSid string) (CredentialList, error) {
	var cl CredentialList
	if !validateDomainSid(domainSid) {
		return cl, errors.New("Invalid sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(domainCredentialList.List, act.AccountSid, domainSid), act, &cl)
	cl.act = &act
	return cl, err
}
Пример #21
0
// List returns a list of recent Twilio error notifications that pass a filter you supply.
func (act Account) List(f Filter) (NotificationList, error) {
	var rl NotificationList
	err := f.validate()
	if err != nil {
		return rl, err
	}
	err = common.SendGetRequest(fmt.Sprintf(notifications.List, act.AccountSid)+f.getQueryString(), act, &rl)
	return rl, err
}
Пример #22
0
// ListParticipants queries for a list of participants in the conference with confSid.
func (act Account) ListParticipants(p ParticipantStatus, confSid string) (ParticipantList, error) {
	var pl ParticipantList
	if !validateConferenceSid(confSid) {
		return pl, errors.New("Invalid conference sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(participant.List, act.AccountSid, confSid)+p.getQueryString(), act, &pl)
	pl.act = &act
	return pl, err
}
Пример #23
0
// GetMobileNumbers returns all available mobile numbers matching the given filter.
//
// https://www.twilio.com/docs/api/rest/available-phone-numbers#mobile
func (act Account) GetMobileNumbers(l MobileSearchFilter, iso string) (NumberList, error) {
	var nl NumberList
	if !validateIsoCountry(iso) {
		return nl, errors.New("Invalid country ISO")
	}
	err := common.SendGetRequest(fmt.Sprintf(numbers.mobile, act.AccountSid, iso)+l.getQueryString(), act, &nl)
	nl.act = &act
	return nl, err
}
Пример #24
0
// ListCredentials grabs a list of all Credentials for this account
// https://www.twilio.com/docs/api/rest/credential-list#list-get-credential
func (act Account) ListCredentials(clSid string) (CredentialsResource, error) {
	var cl CredentialsResource
	if !validateCredentialSid(clSid) {
		return cl, errors.New("Invalid credential list sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(credential.List, act.AccountSid, clSid), act, &cl)
	cl.act = &act
	return cl, err
}
// GetIPAddress grabs a single IP Address with the given sid
// https://www.twilio.com/docs/api/rest/ip-access-control-list#instance-get-ipaddress
func (act Account) GetIPAddress(alSid, ipSid string) (IPAddressResource, error) {
	var i IPAddressResource
	if !validateMappingSid(alSid) {
		return i, errors.New("Invalid ip access control sid")
	} else if !validateIPSid(ipSid) {
		return i, errors.New("Invalid ip sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(ipAddress.Get, act.AccountSid, alSid, ipSid), act, &i)
	return i, err
}
Пример #26
0
// GetParticipant returns the participant with callSid from conference with confSid
func (act Account) GetParticipant(confSid string, callSid string) (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.SendGetRequest(fmt.Sprintf(participant.Get, act.AccountSid, confSid, callSid), act, &p)
	return p, err
}
Пример #27
0
// GetMapping gets a control list mapping for this sid
func (act Account) GetMapping(mappingSid, domainSid string) (Mapping, error) {
	var m Mapping
	if !validateMappingSid(mappingSid) {
		return m, errors.New("Invalid control sid")
	}
	if !validateDomainSid(domainSid) {
		return m, errors.New("Invalid domain sid")
	}
	err := common.SendGetRequest(fmt.Sprintf(domainControlList.Get, act.AccountSid, domainSid, mappingSid), act, &m)
	return m, err
}
Пример #28
0
// Next sets the ResourceList to the next page of the list resource, returns an error in the
// case that there are no more pages left.
func (rl *ResourceList) next() error {
	if rl.Page == rl.NumPages-1 {
		return errors.New("no more new pages")
	}
	return common.SendGetRequest(rl.NextPageURI, *rl.act, rl)
}
Пример #29
0
// List returns the list of all applications the fulfill the filter provided.
func (act Account) List(f ListFilter) (ResourceList, error) {
	var rl ResourceList
	err := common.SendGetRequest(fmt.Sprintf(applications.List, act.AccountSid)+f.getQueryString(), act, &rl)
	rl.act = &act
	return rl, err
}
Пример #30
0
// GetGlobalNumbers returns a list of all resources for sarching for numbers in other
// countries.
func (act Account) GetGlobalNumbers() (CountryList, error) {
	var cl CountryList
	err := common.SendGetRequest(fmt.Sprintf(numbers.all, act.AccountSid), act, &cl)
	return cl, err
}