Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #101 from moip/release/v3.5.0
Browse files Browse the repository at this point in the history
[RELEASE] v4.0.0
  • Loading branch information
mbnakaya authored Dec 7, 2017
2 parents 5ecdc2d + 61a5429 commit d4ffbd6
Show file tree
Hide file tree
Showing 39 changed files with 698 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ target
*.swp
.gradle
build/
out/
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<a name="v4.0.0"></a>
# [](https://github.com/moip/moip-sdk-java/compare/v3.4.0...v3.5.0) (2017-12-05)


### Features

* **Account:** added return accessToken and setPassword ([a078943](https://github.com/moip/moip-sdk-java/commits/a078943))
* **Account:** created AccountLinks class and added some account creation tests ([1e5632b](https://github.com/moip/moip-sdk-java/commits/1e5632b))
* **Order:** return checkout preferences and checkout links ([26e96de](https://github.com/moip/moip-sdk-java/commits/26e96de))
* **Order:** create alternatives methods to get the checkout links and add some tests ([d9b17ce](https://github.com/moip/moip-sdk-java/commits/a078943))
* **Transfer:** adds create and revert a transfer ([1f9357a](https://github.com/moip/moip-sdk-java/commits/1f9357a))
* **Transfer:** adds MoipAccountRequest, fix some parameters and fix Transfer examples ([5f274c5](https://github.com/moip/moip-sdk-java/commits/5f274c5))
* **Multipayment** adds Checkout instance to MultipaymentLinks ([dad95a2](https://github.com/moip/moip-sdk-java/commits/dad95a2))

### Refactor

* **Order:** fixed parameter `addiction` to `addition` ([42a08c3](https://github.com/moip/moip-sdk-java/commits/42a08c3))


<a name="v3.4.0"></a>
# [](https://github.com/moip/moip-sdk-java/compare/v3.3.0...v3.4.0) (2017-11-08)

Expand Down
89 changes: 80 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@
- [Consulta](#consulta-8)
- [Exclusão](#exclusão-1)
- [Atualização](#atualização)
- [Listagem](#listagem-1)
- [Listagem](#listagem-1)
- [Transferência](#transferência)
- [Criação](#criação-8)
-[Conta Bancária](#conta-bancária)
-[Conta Moip](#conta-moip-1)
- [Consulta](#consulta-9)
- [Listagem](#listagem-2)
- [Reversão](#reversão)
- [Custódia](#custódia)
- [Pagamento com custódia](#pagamento-com-custódia)
- [Liberação de custódia](#liberação-de-custódia)
Expand All @@ -84,7 +91,7 @@ Adicionar no seu pom.xml:
<dependency>
<groupId>br.com.moip</groupId>
<artifactId>java-sdk</artifactId>
<version>3.4.0</version>
<version>4.0.0</version>
</dependency>

```
Expand Down Expand Up @@ -219,7 +226,7 @@ Payment createdPayment = api.payment().create(new PaymentRequest()
);
```

> Para capturar links do boleto:
> Para capturar os links do boleto:
```java
// Link do Boleto
Expand Down Expand Up @@ -543,6 +550,16 @@ Multipayment multipayment = api.multipayment().create(new PaymentRequest()
);
```

> Para capturar os links do boleto:
```java
// Link do Boleto
multipayment.getLinks().checkout().getPayBoletoLink();

// Link para impressão do boleto
multipayment.getLinks().checkout().getPayBoletoPrintLink();
```

### Consulta
```java
Multipayment multipayment = api.multipayment().get("MPY-OUGA0AHH2BOF");
Expand Down Expand Up @@ -639,7 +656,7 @@ api.account().checkAccountExists("123.456.798-91");
## Contas Bancárias
### Criação
```java
BankAccount createdBankAccount = api.create("MPA-E0BAC6D15696",
BankAccount createdBankAccount = api.bankAccount().create("MPA-E0BAC6D15696",
new BankAccountRequest()
.bankNumber("237")
.agencyNumber("12346")
Expand All @@ -655,15 +672,15 @@ BankAccount createdBankAccount = api.create("MPA-E0BAC6D15696",
```
### Consulta
```java
BankAccount createdBankAccount = api.get("BKA-E0BAC6D15696");
BankAccount createdBankAccount = api.bankAccount().get("BKA-E0BAC6D15696");
```
### Exclusão
```java
api.delete("BKA-E0BAC6D15696");
api.bankAccount().delete("BKA-E0BAC6D15696");
```
### Atualização
```java
BankAccount createdBankAccount = api.update("BKA-E0BAC6D15696",
BankAccount createdBankAccount = api.bankAccount().update("BKA-E0BAC6D15696",
new BankAccountRequest()
.bankNumber("237")
.agencyNumber("12345")
Expand All @@ -683,7 +700,61 @@ BankAccount createdBankAccount = api.update("BKA-E0BAC6D15696",

### Listagem
```java
List<BankAccount> createdBankAccounts = api.getList("MPA-E0BAC6D15696");
List<BankAccount> createdBankAccounts = api.bankAccount().getList("MPA-E0BAC6D15696");
```

## Transferência
### Criação
#### Conta Bancária
```java
Transfer transfer = api.transfer().create(new TransferRequest()
.amount(1000)
.transferInstrument(new TransferInstrumentRequest()
.bankAccount(new BankAccountRequest()
.bankNumber("001")
.agencyNumber("1111")
.agencyCheckNumber("2")
.accountNumber("9999")
.accountCheckNumber("8")
.checking()
.holder(new HolderRequest()
.fullname("Nome do Portador")
.taxDocument(TaxDocumentRequest.cpf("22222222222"))
)

)
)
);
```


#### Conta Moip
```java
Transfer transfer = api.transfer().create(new TransferRequest()
.amount(1000)
.transferInstrument(new TransferInstrumentRequest()
.moipAccount(new MoipAccountRequest("MPA-5D5053C0B4A4"))
)
);
```

### Consulta
```java
Transfer createdTransfer = api.transfer().get("TRA-28HRLYNLMUFH");

System.out.println(createdTransfer);
```

### Listagem
```java
TransferListResponse transferListResponse = api.transfer().list();

System.out.println(transferListResponse);
```

### Reversão
```java
Transfer revertTransfer = api.transfer().reverse("TRA-B0W5FD5FCADG");
```

## Custódia
Expand Down Expand Up @@ -747,7 +818,7 @@ Connect connect = api.connect().authorize(new ConnectRequest()
.clientSecret("e2bd3951b87e469eb0f2c2b781a753d5")
.code("8870af1372ada7a18fdff4fa4ca1a60f4d542272")
.redirectUri("http://localhost/moip-sdk/callback")
.grantType(GrantType.authorization_code)
.grantType(GrantType.AUTHORIZATION_CODE)
);
System.out.println(connect);
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'signing'

group = 'br.com.moip'
archivesBaseName = "java-sdk"
version = '3.4.0'
version = '4.0.0'

description = "Moip v2 SDK"

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/br/com/moip/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public <T> T post(final String path, final Object object, final Class<T> type, C
return doRequest("POST", path, object, type, contentType);
}

public <T> T post(final String path, final Class<T> type) {
return doRequest("POST", path, null, type, ContentType.APPLICATION_JSON);
}

public <T> T put(final String path, final Object object, final Class<T> type) {
return doRequest("PUT", path, object, type, ContentType.APPLICATION_JSON);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/br/com/moip/api/TransferApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import br.com.moip.Client;
import br.com.moip.api.filter.Pagination;
import br.com.moip.request.TransferRequest;
import br.com.moip.resource.Transfer;
import br.com.moip.response.TransferListResponse;

Expand All @@ -14,6 +15,10 @@ public TransferApi(final Client client) {
this.client = client;
}

public Transfer create(final TransferRequest transfer) { return client.post(TRANSFER_URL, transfer, Transfer.class); }

public Transfer reverse(final String id) { return client.post(TRANSFER_URL + "/" + id + "/reverse", Transfer.class); }

public Transfer get(final String id) {
return client.get(TRANSFER_URL + "/" + id, Transfer.class);
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/br/com/moip/request/MoipAccountRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package br.com.moip.request;

public class MoipAccountRequest {

private final String id;

public MoipAccountRequest(String moipAccount) {
this.id = moipAccount;
}

public String getId() {
return id;
}
}
12 changes: 0 additions & 12 deletions src/main/java/br/com/moip/request/ReceiverRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,3 @@ public boolean getFeePayor() {
return feePayor;
}
}

class MoipAccountRequest {
private final String id;

public MoipAccountRequest(String moipAccount) {
this.id = moipAccount;
}

public String getId() {
return id;
}
}
12 changes: 6 additions & 6 deletions src/main/java/br/com/moip/request/SubtotalsRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class SubtotalsRequest {

private Integer shipping;
private Integer addiction;
private Integer addition;
private Integer discount;

public Integer getShipping() {
Expand All @@ -16,12 +16,12 @@ public SubtotalsRequest shipping(Integer shipping) {
return this;
}

public Integer getAddiction() {
return addiction;
public Integer getAddition() {
return addition;
}

public SubtotalsRequest addiction(Integer addiction) {
this.addiction = addiction;
public SubtotalsRequest addition(Integer addition) {
this.addition = addition;

return this;
}
Expand All @@ -40,7 +40,7 @@ public SubtotalsRequest discount(Integer discount) {
public String toString() {
return new StringBuilder("SubtotalsRequest{")
.append(", shipping=").append(shipping)
.append(", addiction=").append(addiction)
.append(", addition=").append(addition)
.append(", discount=").append(discount)
.append('}').toString();
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/br/com/moip/request/TaxDocumentRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public static TaxDocumentRequest cnpj(final String number) {

@Override
public String toString() {
return "TaxDocument{" +
"type='" + type + '\'' +
", number='" + number + '\'' +
'}';
final StringBuilder sb = new StringBuilder("TaxDocument{");
sb.append("type=").append(type);
sb.append(", number='").append(number).append('\'');
sb.append('}');
return sb.toString();
}

private enum Type {
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/br/com/moip/request/TransferInstrumentRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package br.com.moip.request;

public class TransferInstrumentRequest {

private Method method;
private BankAccountRequest bankAccount;
private MoipAccountRequest moipAccount;

public TransferInstrumentRequest bankAccount(BankAccountRequest bankAccount) {
this.method = Method.BANK_ACCOUNT;
this.bankAccount = bankAccount;

return this;
}

public TransferInstrumentRequest moipAccount(MoipAccountRequest moipAccount) {
this.method = Method.MOIP_ACCOUNT;
this.moipAccount = moipAccount;

return this;
}

public enum Method{
BANK_ACCOUNT, MOIP_ACCOUNT;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("TransferInstrument{");
sb.append("method=").append(method);
sb.append(", bankAccount=").append(bankAccount);
sb.append(", moipAccount=").append(moipAccount);
sb.append('}');
return sb.toString();
}
}
31 changes: 31 additions & 0 deletions src/main/java/br/com/moip/request/TransferRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package br.com.moip.request;

public class TransferRequest {

private Integer amount;
private TransferInstrumentRequest transferInstrument;

public TransferRequest amount(Integer amount){
this.amount = amount;

return this;
}

public Integer getAmount() { return amount; }

public TransferRequest transferInstrument(TransferInstrumentRequest transferInstrument){
this.transferInstrument = transferInstrument;

return this;
}

public TransferInstrumentRequest getTransferInstrument() { return transferInstrument; }

@Override
public String toString(){
return new StringBuilder("TransferRequest{")
.append("amount=").append(amount)
.append(", transferInstrument=").append(transferInstrument)
.append("}").toString();
}
}
Loading

0 comments on commit d4ffbd6

Please sign in to comment.