Making API Calls
Making Requests
You can make API calls using the built-in asynchronous object
APIs included in the SDK. Not all objects are available from the
client-side libraries.
Select
Payload.all(pl.Customer.select(), new Payload.Callback<List<pl.Customer>>() {
public void then(List<pl.Customer> custs) {
}
});
Payload.all(Payload.Customer.select(), {(obj: Any) in
let custs = obj as? [Payload.Customer]
/* Do something with response */
})
[Payload all: [Customer select] :^(id obj) {
NSArray *custs = obj;
Customer *cust = [custs firstObject];
/* Do something with response */
}];
Create
Payload.create(pl.Customer(){{
set("email", "test@gmail.com");
set("name", "Test Account");
}}, new Payload.Callback<pl.Customer>() {
public void then(pl.Customer cust) {}
});
Payload.create(Payload.Customer([
"email": "test@gmail.com",
"name": "Test Account"
]), {(obj: Any) in
let cust = obj as? Payload.Customer
/* Do something with response */
})
[Payload create: [[Customer alloc] init:@{
@"email": @"test@gmail.com",
@"name": @"Test Account"
}] :^(id obj) {
Customer *cust = obj;
}];
Update
Payload.update(cust.set("email", "test@gmail.com"),
new Payload.Callback<pl.Customer>() {
public void then(pl.Customer cust) {}
});
cust.update([
"email": "test@gmail.com"
], {(obj: Any) in
let cust = obj as? Payload.Customer
/* Do something with response */
})
[cust update:@{
@"email": @"test@gmail.com"
} :^(id obj) {
Customer *cust = obj;
/* Do something with response */
}];
Delete
Payload.delete(cust, new Payload.Callback<pl.Customer>() {
public void then(pl.Customer cust) {}
});
cust.delete({(obj: Any) in
/* Do something with response */
})
[cust delete:^(id obj) {
/* Do something with response */
}];