|
| 1 | +import java.io.*; |
| 2 | +import com.printnode.api.*; |
| 3 | + |
| 4 | +public class CreatingAnAccount{ |
| 5 | + public static void main(String args[]) throws IOException{ |
| 6 | + |
| 7 | + //Firstly, we'll create a new Auth object. |
| 8 | + Auth myAuth = new Auth(); |
| 9 | + |
| 10 | + //We're going to set our credentials for future use with Auth.setApiKey. |
| 11 | + myAuth.setApiKey("MyApiKey"); |
| 12 | + |
| 13 | + //We then make an APIClient, which saves our authorization to use with requests. |
| 14 | + APIClient aClient = new APIClient(myAuth); |
| 15 | + |
| 16 | + //First, we'll make a CreateAccountJson object to prepare our request. |
| 17 | + CreateAccountJson accountInfo = new CreateAccountJson("A","Person","Email@AnEmailProvider.com","AStrongPassword"); |
| 18 | + |
| 19 | + //So, there are all the required variables to make an account. |
| 20 | + //The rest are optional. We want some ApiKeys for our new account, so let's set some. |
| 21 | + accountInfo.setApiKeys(new String[]{"Development","Production"}); |
| 22 | + |
| 23 | + //We're now ready to send the request, which we can do by using APIClient.createAccount(). |
| 24 | + //We want to see the returned value, which is a CreateAccountObject. |
| 25 | + CreateAccountObject accountObject = aClient.createAccount(accountInfo); |
| 26 | + |
| 27 | + //Let's authenticate as this account via it's id. |
| 28 | + APIClient childClient = new APIClient(myAuth); |
| 29 | + childClient.setChildAccountById(accountObject.getId()); |
| 30 | + |
| 31 | + } |
| 32 | +} |
0 commit comments