public OnfleetRecipient CreateRecipient(string name, string phone, string notes, bool skipSMSNotifications, bool skipPhoneNumberValidation) { var recipient = new OnfleetRecipient() { name = name, phone = "+1" + phone, notes = notes, skipPhoneNumberValidation = skipPhoneNumberValidation, skipSMSNotifications = skipSMSNotifications }; var request = new RestRequest("recipients", Method.POST); request.JsonSerializer.ContentType = "application/json; charset=utf-8"; request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(recipient); var response = _client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <OnfleetRecipient>(response.Content)); } else { _logger.ErrorFormat("Onfleet Create Recipient : {0}", response.ErrorMessage); return(null); } }
public OnfleetRecipient CreateRecipient(string name, string phone, string notes, bool skipSMSNotifications, bool skipPhoneNumberValidation) { var recipient = new OnfleetRecipient() { name = name, phone = "+1" + phone, notes = notes, skipPhoneNumberValidation = skipPhoneNumberValidation, skipSMSNotifications = skipSMSNotifications }; var request = new RestRequest("recipients", Method.POST); request.JsonSerializer.ContentType = "application/json; charset=utf-8"; request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(recipient); var response = _client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return JsonConvert.DeserializeObject<OnfleetRecipient>(response.Content); } else { _logger.ErrorFormat("Onfleet Create Recipient : {0}", response.ErrorMessage); return null; } }