/// <summary> /// Delete a single application /// </summary> /// <param name="appId">The application id to delete</param> /// <param name="credentials">(Optional) Overridden credentials for only this request</param> /// <returns></returns> public static bool Delete(string appId, Credentials credentials = null) { var response = VersionedApiRequest.DoRequest("DELETE", ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications/{appId}"), null, credentials); return(response.Status == HttpStatusCode.NoContent); }
/// <summary> /// Modify a single application /// </summary> /// <param name="appId">Id of the application to be updated</param> /// <param name="request">Application request</param> /// <param name="credentials">(Optional) Overridden credentials for only this request</param> /// <returns></returns> public static AppResponse Update(AppRequest request, Credentials credentials = null) { var response = VersionedApiRequest.DoRequest("PUT", ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications/{request.Id}"), request, credentials); return(JsonConvert.DeserializeObject <AppResponse>(response.JsonResponse)); }
/// <summary> /// Delete the secret associated with the provided secret ID. /// </summary> /// <param name="apiKey">The API key to manage secrets for</param> /// <param name="secretId">ID of the API Secret</param> public static bool DeleteSecret(string apiKey, string secretId, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("DELETE", ApiRequest.GetBaseUriFor(typeof(ApiSecret), $"/accounts/{apiKey}/secrets/{secretId}"), null, creds); return(response.Status == HttpStatusCode.NoContent); }
/// <summary> /// Create a secret with the details provided in new secret. /// </summary> /// <param name="apiKey">The API key to manage secrets for</param> /// <param name="newSecret">The new secret must follow these rules: /// minimum 8 characters /// maximum 25 characters /// minimum 1 lower case character /// minimum 1 upper case character /// minimum 1 digit /// </param> /// <returns>The created secret</returns> public static Secret CreateSecret(string apiKey, string newSecret, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("POST", ApiRequest.GetBaseUriFor(typeof(ApiSecret), $"/accounts/{apiKey}/secrets"), new SecretRequest { Secret = newSecret }, creds); return(JsonConvert.DeserializeObject <Secret>(response.JsonResponse)); }
/// <summary> /// List all of the applications associated with this account /// </summary> /// <param name="pageSize">Set the number of items returned on each call to this endpoint. The default is 10 records.</param> /// <param name="page">Set the offset from the first page. The default value is 0, calls to this endpoint return a page of <page_size>. For example, set page_index to 3 to retrieve items 31 - 40 when page_size is the default value.</param> /// <param name="AppId">Optional id of specific application to retrieve</param> /// <param name="credentials">(Optional) Overridden credentials for only this request</param> /// <returns></returns> public static List <AppResponse> List(int pageSize = 10, int page = 0, Credentials credentials = null) { var filter = new AppListFilter() { page = page, page_size = pageSize }; var response = VersionedApiRequest.DoRequest(ApiRequest.GetBaseUriFor(typeof(ApplicationV2), "/v2/applications"), filter, VersionedApiRequest.AuthType.Basic, credentials); return(JsonConvert.DeserializeObject <AppListResponse>(response)._embedded.Applications); }
/// <summary> /// PUT /v1/calls/{uuid}/dtmf - send Dual-tone multi-frequency(DTMF) tones to an active Call /// </summary> /// <param name="id">id of call</param> /// <param name="cmd">Command to execute against call</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> public static CallCommandResponse SendDtmf(string id, DtmfCommand cmd, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("PUT", ApiRequests.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}/dtmf"), cmd, creds); return(JsonConvert.DeserializeObject <CallCommandResponse>(response.JsonResponse)); }
/// <summary> /// DELETE /v1/calls/{uuid}/talk - stop sending a synthesized speech message to an active Call /// </summary> /// <param name="id">id of call</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> public static CallCommandResponse EndTalk(string id, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("DELETE", ApiRequests.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}/talk"), new { }, creds); return(JsonConvert.DeserializeObject <CallCommandResponse>(response.JsonResponse)); }
/// <summary> /// GET /v1/calls/{uuid} - retrieve information about a single Call /// </summary> public static CallResponse Get(string id, Credentials creds = null) { var response = VersionedApiRequest.DoRequest(ApiRequest.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}"), new {}, creds); return(JsonConvert.DeserializeObject <CallResponse>(response)); }
/// <summary> /// GET /v1/calls - retrieve information about all your Calls /// </summary> public static PaginatedResponse <CallList> List(SearchFilter filter, Credentials creds = null) { var response = VersionedApiRequest.DoRequest(ApiRequest.GetBaseUriFor(typeof(Call), "/v1/calls"), filter, creds); return(JsonConvert.DeserializeObject <PaginatedResponse <CallList> >(response)); }
/// <summary> /// POST /v1/calls - create an outbound SIP or PSTN Call /// </summary> /// <param name="cmd"></param> /// <returns></returns> public static CallResponse Do(CallCommand cmd, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("POST", ApiRequest.GetBaseUriFor(typeof(Call), "/v1/calls"), cmd, creds); return(JsonConvert.DeserializeObject <CallResponse>(response.JsonResponse)); }
/// <summary> /// POST /v1/redact/transaction - redacts a specific transaction /// </summary> /// <param name="redactRequest"></param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> /// <returns></returns> public static NexmoResponse RedactTransaction(RedactRequest redactRequest, Credentials creds = null) { return(VersionedApiRequest.DoRequest("POST", ApiRequest.GetBaseUriFor(typeof(Redact), "/v1/redact/transaction"), redactRequest, creds)); }
/// <summary> /// PUT /v1/calls/{uuid}/talk - send a synthesized speech message to an active Call /// </summary> public static CallCommandResponse BeginTalk(string id, TalkCommand cmd) { var response = VersionedApiRequest.DoRequest("PUT", ApiRequest.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}/talk"), cmd); return(JsonConvert.DeserializeObject <CallCommandResponse>(response.JsonResponse)); }
/// <summary> /// DELETE /v1/calls/{uuid}/stream - stop streaming an audio file to an active Call /// </summary> public static CallCommandResponse EndStream(string id) { var response = VersionedApiRequest.DoRequest("DELETE", ApiRequest.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}/stream"), new {}); return(JsonConvert.DeserializeObject <CallCommandResponse>(response.JsonResponse)); }