Notes
Response Class
public class CustomerResponse {
public string firstName;
public string lastName;
public string email;
public string phone;
public string gender;
public string status;
public static List<CustomerResponse> parse(String json){
return (List<CustomerResponse>) System.JSON.deserialize(json, List<CustomerResponse>.class);
}
}
Main Class
public static void PostCustomerFromContacts(){
public static void getCustomersByRepsonse(){
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.pathtosalesforce.com/customerList.php?token='+token);
request.setMethod('GET');
HttpResponse response = http.send(request);
System.debug(response.getStatusCode());
System.debug(response.getStatus());
System.debug(response.getBody());
List<CustomerResponse> customers = CustomerResponse.parse(response.getBody());
List<Contact> conList = new List<Contact>();
for(CustomerResponse customer : customers){
Contact con = new Contact();
con.FirstName = customer.firstName;
con.LastName = customer.lastName;
con.Email = customer.email;
con.Phone = customer.phone;
conList.add(con);
}
insert conList;
}
}