This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Accounts
somentelucas edited this page Aug 27, 2018
·
20 revisions
TO DO
TO DO
authorization | able |
---|---|
Basic Auth | ❌ |
OAuth | ✅ |
Map<String, Object> hasAccount = Moip.API.accounts().checkExistence("[email protected]", setup);
The search argument can be a tax document number (with punctuation) or an e-mail. Exemple:
123.123.123-99
,36.933.105/0001-40
or[email protected]
.
response | account |
---|---|
200 | exist |
400 | invalid |
404 | does not exist |
authorization | able |
---|---|
Basic Auth | ❌ |
OAuth | ✅ |
Map<String, Object> email = payloadFactory(
value("address", "[email protected]")
);
Map<String, Object> taxDocument = payloadFactory(
value("type", "CPF"),
value("number", "123.456.789-00")
);
Map<String, Object> identityDocument = payloadFactory(
value("type", "RG"),
value("number", "434322344"),
value("issuer", "SSP"),
value("issueDate", "2010-01-01")
);
Map<String, Object> phone = payloadFactory(
value("countryCode", "55"),
value("areaCode", "11"),
value("number", "43215678")
);
Map<String, Object> address = payloadFactory(
value("street", "Av. Brigadeiro Faria Lima"),
value("streetNumber", "2927"),
value("district", "Itaim Bibi"),
value("city", "São Paulo"),
value("state", "SP"), // UF
value("country", "BRA"),
value("zipCode", "01234-000")
);
Map<String, Object> person = payloadFactory(
value("name", "Name"),
value("lastName", "Last Name"),
value("taxDocument", taxDocument),
value("identityDocument", identityDocument),
value("birthDate", "2000-01-01"),
value("phone", phone),
value("address", address)
);
Map<String, Object> body = payloadFactory(
value("email", email),
value("person", person),
value("type", "MERCHANT")
);
Map<String, Object> hasAccount = Moip.API.accounts().create(body, setup);
To create a company account you have to create the same structure of the previous example and add the company object in the request body.
Map<String, Object> taxDocument = payloadFactory(
value("type", "CNPJ"),
value("number", "25.789.340/0001-74")
);
Map<String, Object> mainActivity = payloadFactory(
value("cnae", "82.91-1/00"),
value("description", "Description of main activity")
);
Map<String, Object> phone = new payloadFactory(
value("countryCode", "55"),
value("areaCode", "11"),
value("number", "56784321")
);
Map<String, Object> address = payloadFactory(
value("street", "Av. Company"),
value("streetNumber", "123"),
value("complement", "Address complement"),
value("district", "The District"),
value("city", "New City"),
value("state", "SP"),
value("country", "BRA"),
value("zipCode", "43210-01")
);
Map<String, Object> company = payloadFactory(
value("name", "Name INC."),
value("businessName", "Business Name"),
value("openingDate", "2018-08-21"),
value("taxDocument", taxDocument),
value("mainActivity", mainActivity),
value("phone", phone),
value("address", address)
);
So, the request body should be:
Map<String, Object> body = payloadFactory(
value("email", email),
value("person", person),
value("company", company),
value("type", "MERCHANT")
);
Map<String, Object> hasAccount = Moip.API.accounts().create(body, setup);