public dynamic UpdateContact(int id, string first_name, string last_name, string address1, string city, string state_province, string postal_code,
string country, string email_address, string phone, string organization_name = null, string job_title = null,
string fax = null, string phone_ext = null, string label = null, string address2 = null)
{
Require.Argument("id", id);
Require.Argument("first_name", first_name);
Require.Argument("last_name", last_name);
Require.Argument("address1", address1);
Require.Argument("city", city);
Require.Argument("state_province", state_province);
Require.Argument("postal_code", postal_code);
Require.Argument("country", country);
Require.Argument("email_address", email_address);
Require.Argument("phone", phone);
if (!string.IsNullOrWhiteSpace(organization_name))
{
Require.Argument("job_title", job_title);
}
var request = new RestRequest(Method.PUT)
{
RequestFormat = DataFormat.Json,
Resource = "contacts/{id}"
};
request.AddUrlSegment("id", id.ToString());
dynamic payload = new ExpandoObject();
payload.contact = new ExpandoObject();
payload.contact.first_name = first_name;
payload.contact.last_name = last_name;
payload.contact.address1 = address1;
payload.contact.city = city;
payload.contact.state_province = state_province;
payload.contact.postal_code = postal_code;
payload.contact.country = country;
payload.contact.email_address = email_address;
payload.contact.phone = phone;
if (!string.IsNullOrWhiteSpace(organization_name))
{
payload.contact.organization_name = organization_name;
}
if (!string.IsNullOrWhiteSpace(job_title))
{
payload.contact.job_title = job_title;
}
if (!string.IsNullOrWhiteSpace(fax))
{
payload.contact.fax = fax;
}
if (!string.IsNullOrWhiteSpace(phone_ext))
{
payload.contact.phone_ext = phone_ext;
}
if (!string.IsNullOrWhiteSpace(label))
{
payload.contact.label = label;
}
if (!string.IsNullOrWhiteSpace(address2))
{
payload.contact.address2 = address2;
}
request.AddBody(payload);
return Execute<dynamic>(request);
}