public VoiceMessage ViewVoiceMessage(string id) { ParameterValidator.IsNotNullOrWhiteSpace(id, "id"); var voiceMessageToView = new VoiceMessages(new VoiceMessage(id)); var result = restClient.Retrieve(voiceMessageToView); return(result.Object as VoiceMessage); }
public VoiceMessage SendVoiceMessage(string body, long[] msisdns, VoiceMessageOptionalArguments optionalArguments = null) { ParameterValidator.IsNotNullOrWhiteSpace(body, "body"); ParameterValidator.ContainsAtLeast(msisdns, 1, "msisdns"); var recipients = new Recipients(msisdns); var voiceMessage = new VoiceMessage(body, recipients, optionalArguments); var voiceMessages = new VoiceMessages(voiceMessage); var result = restClient.Create(voiceMessages); return(result.Object as VoiceMessage); }
public void DeserializeRecipientsAsMsisdnsArray() { var recipients = new Recipients(); recipients.AddRecipient(31612345678); var voiceMessage = new VoiceMessage("Welcome to MessageBird", recipients); var voiceMessages = new VoiceMessages(voiceMessage); string serializedMessage = voiceMessages.Serialize(); voiceMessages.Deserialize(serializedMessage); }
public void DeserializeAndSerialize() { const string JsonResultFromCreateVoiceMessageExample = @"{ 'id':'955c3130353eb3dcd090294a42643365', 'href':'https:\/\/rest.messagebird.com\/voicemessages\/955c3130353eb3dcd090294a42643365', 'body':'This is a test message. The message is converted to speech and the recipient is called on his mobile.', 'reference':null, 'language':'en-gb', 'voice':'female', 'repeat':1, 'ifMachine':'continue', 'scheduledDatetime':null, 'createdDatetime':'2014-08-13T10:28:29+00:00', 'recipients':{ 'totalCount':1, 'totalSentCount':1, 'totalDeliveredCount':0, 'totalDeliveryFailedCount':0, 'items':[ { 'recipient':31612345678, 'status':'calling', 'statusDatetime':'2014-08-13T10:28:29+00:00' } ] } }"; var recipients = new Recipients(); var voiceMessage = new VoiceMessage("", recipients); var voiceMessages = new VoiceMessages(voiceMessage); voiceMessages.Deserialize(JsonResultFromCreateVoiceMessageExample); var voiceMessageResult = voiceMessages.Object as VoiceMessage; string voiceMessageResultString = voiceMessageResult.ToString(); JsonConvert.DeserializeObject <VoiceMessage>(voiceMessageResultString); // check if Deserialize/Serialize cycle works. }