Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement 2.6 endpoints #61

Merged
merged 6 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
import org.arkecosystem.client.http.Client;

public class Api {

public Blockchain blockchain;
public Blocks blocks;
public Bridgechains bridgechains;
public Businesses businesses;
public Delegates delegates;
public Locks locks;
public Node node;
public Peers peers;
public Rounds rounds;
Expand All @@ -13,8 +18,12 @@ public class Api {
public Wallets wallets;

public Api(Client client) {
this.blockchain = new Blockchain(client);
this.blocks = new Blocks(client);
this.bridgechains = new Bridgechains(client);
this.businesses = new Businesses(client);
this.delegates = new Delegates(client);
this.locks = new Locks(client);
this.node = new Node(client);
this.peers = new Peers(client);
this.rounds = new Rounds(client);
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Blockchain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.arkecosystem.client.api;

import com.google.gson.internal.LinkedTreeMap;
import java.io.IOException;
import org.arkecosystem.client.http.Client;

public class Blockchain {

private Client client;

public Blockchain(Client client) {
this.client = client;
}

public LinkedTreeMap<String, Object> all() throws IOException {
return this.client.get("blockchain");
}
}
10 changes: 9 additions & 1 deletion src/main/java/org/arkecosystem/client/api/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.arkecosystem.client.http.Client;

public class Blocks {
Client client;
private Client client;

public Blocks(Client client) {
this.client = client;
Expand All @@ -16,6 +16,14 @@ public LinkedTreeMap<String, Object> all() throws IOException {
return this.client.get("blocks");
}

public LinkedTreeMap<String, Object> first() throws IOException {
return this.client.get("blocks/first");
}

public LinkedTreeMap<String, Object> last() throws IOException {
return this.client.get("blocks/last");
}

public LinkedTreeMap<String, Object> show(String id) throws IOException {
return this.client.get("blocks/" + id);
}
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Bridgechains.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.arkecosystem.client.api;

import com.google.gson.internal.LinkedTreeMap;
import java.io.IOException;
import java.util.Map;
import org.arkecosystem.client.http.Client;

public class Bridgechains {
private Client client;

public Bridgechains(Client client) {
this.client = client;
}

public LinkedTreeMap<String, Object> all() throws IOException {
return this.client.get("bridgechains");
}

public LinkedTreeMap<String, Object> show(String id) throws IOException {
return this.client.get("bridgechains/" + id);
}

public LinkedTreeMap<String, Object> search(Map<String, Object> parameters) throws IOException {
return this.client.post("bridgechains/search", parameters);
}
}
30 changes: 30 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Businesses.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.arkecosystem.client.api;

import com.google.gson.internal.LinkedTreeMap;
import java.io.IOException;
import java.util.Map;
import org.arkecosystem.client.http.Client;

public class Businesses {
private Client client;

public Businesses(Client client) {
this.client = client;
}

public LinkedTreeMap<String, Object> all() throws IOException {
return this.client.get("businesses");
}

public LinkedTreeMap<String, Object> show(String id) throws IOException {
return this.client.get("businesses/" + id);
}

public LinkedTreeMap<String, Object> showBridgechains(String id) throws IOException {
return this.client.get("businesses/" + id + "/bridgechains");
}

public LinkedTreeMap<String, Object> search(Map<String, Object> parameters) throws IOException {
return this.client.post("businesses/search", parameters);
}
}
7 changes: 6 additions & 1 deletion src/main/java/org/arkecosystem/client/api/Delegates.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.google.gson.internal.LinkedTreeMap;
import java.io.IOException;
import java.util.Map;
import org.arkecosystem.client.http.Client;

public class Delegates {
Client client;
private Client client;

public Delegates(Client client) {
this.client = client;
Expand All @@ -26,4 +27,8 @@ public LinkedTreeMap<String, Object> blocks(String id) throws IOException {
public LinkedTreeMap<String, Object> voters(String id) throws IOException {
return this.client.get("delegates/" + id + "/voters");
}

public LinkedTreeMap<String, Object> search(Map<String, Object> parameters) throws IOException {
return this.client.post("delegates/search", parameters);
}
}
31 changes: 31 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Locks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.arkecosystem.client.api;

import com.google.gson.internal.LinkedTreeMap;
import java.io.IOException;
import java.util.Map;
import org.arkecosystem.client.http.Client;

public class Locks {
private Client client;

public Locks(Client client) {
this.client = client;
}

public LinkedTreeMap<String, Object> all() throws IOException {
return this.client.get("all");
}

public LinkedTreeMap<String, Object> show(String id) throws IOException {
return this.client.get("locks/" + id);
}

public LinkedTreeMap<String, Object> search(Map<String, Object> parameters) throws IOException {
return this.client.post("locks/search", parameters);
}

public LinkedTreeMap<String, Object> searchUnlocked(Map<String, Object> parameters)
throws IOException {
return this.client.post("locks/unlocked", parameters);
}
}
18 changes: 11 additions & 7 deletions src/main/java/org/arkecosystem/client/api/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
import org.arkecosystem.client.http.Client;

public class Node {
Client client;
private Client client;

public Node(Client client) {
this.client = client;
}

public LinkedTreeMap<String, Object> fees(Integer... days) throws IOException {
KovacZan marked this conversation as resolved.
Show resolved Hide resolved
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("days", days.length > 0 ? days[0] : null);
return this.client.get("node/fees", parameters);
}

public LinkedTreeMap<String, Object> status() throws IOException {
return this.client.get("node/status");
}
Expand All @@ -33,4 +27,14 @@ public LinkedTreeMap<String, Object> configuration() throws IOException {
public LinkedTreeMap<String, Object> crypto() throws IOException {
return this.client.get("node/configuration/crypto");
}

public LinkedTreeMap<String, Object> fees(Integer... days) throws IOException {
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("days", days.length > 0 ? days[0] : null);
return this.client.get("node/fees");
}

public LinkedTreeMap<String, Object> debug() throws IOException {
return this.client.get("node/debug");
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/arkecosystem/client/api/Peers.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.arkecosystem.client.http.Client;

public class Peers {
Client client;
private Client client;

public Peers(Client client) {
this.client = client;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/arkecosystem/client/api/Rounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.arkecosystem.client.http.Client;

public class Rounds {
Client client;
private Client client;

public Rounds(Client client) {
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.arkecosystem.client.http.Client;

public class Transactions {
Client client;
private Client client;

public Transactions(Client client) {
this.client = client;
Expand Down Expand Up @@ -44,6 +44,10 @@ public LinkedTreeMap<String, Object> types() throws IOException {
return this.client.get("transactions/types");
}

public LinkedTreeMap<String, Object> schemas() throws IOException {
return this.client.get("transactions/schemas");
}

public LinkedTreeMap<String, Object> fees() throws IOException {
return this.client.get("transactions/fees");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/arkecosystem/client/api/Votes.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.arkecosystem.client.http.Client;

public class Votes {
Client client;
private Client client;

public Votes(Client client) {
this.client = client;
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/arkecosystem/client/api/Wallets.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.arkecosystem.client.http.Client;

public class Wallets {
Client client;
private Client client;

public Wallets(Client client) {
this.client = client;
Expand All @@ -16,6 +16,10 @@ public LinkedTreeMap<String, Object> all() throws IOException {
return this.client.get("wallets");
}

public LinkedTreeMap<String, Object> top() throws IOException {
return this.client.get("wallets/top");
}

public LinkedTreeMap<String, Object> show(String id) throws IOException {
return this.client.get("wallets/" + id);
}
Expand All @@ -36,11 +40,11 @@ public LinkedTreeMap<String, Object> votes(String id) throws IOException {
return this.client.get("wallets/" + id + "/votes");
}

public LinkedTreeMap<String, Object> search(Map<String, Object> parameters) throws IOException {
return this.client.post("wallets/search", parameters);
public LinkedTreeMap<String, Object> locks(String id) throws IOException {
return this.client.get("wallets/" + id + "/locks");
}

public LinkedTreeMap<String, Object> top() throws IOException {
return this.client.get("wallets/top");
public LinkedTreeMap<String, Object> search(Map<String, Object> parameters) throws IOException {
return this.client.post("wallets/search", parameters);
}
}
20 changes: 20 additions & 0 deletions src/test/java/org/arkecosystem/client/api/BlockchainTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.arkecosystem.client.api;

import com.google.gson.internal.LinkedTreeMap;
import org.arkecosystem.client.Connection;
import org.arkecosystem.client.MockHelper;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class BlockchainTest {

@Test
void all() throws IOException {
Connection connection = MockHelper.connection();
LinkedTreeMap<String, Object> actual = connection.api().blockchain.all();
assertTrue((boolean) actual.get("success"));
}
}
14 changes: 14 additions & 0 deletions src/test/java/org/arkecosystem/client/api/BlocksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ void all() throws IOException {
assertTrue((boolean) actual.get("success"));
}

@Test
void first() throws IOException {
Connection connection = MockHelper.connection();
LinkedTreeMap<String, Object> actual = connection.api().blocks.first();
assertTrue((boolean) actual.get("success"));
}

@Test
void last() throws IOException {
Connection connection = MockHelper.connection();
LinkedTreeMap<String, Object> actual = connection.api().blocks.last();
assertTrue((boolean) actual.get("success"));
}

@Test
void show() throws IOException {
Connection connection = MockHelper.connection();
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/org/arkecosystem/client/api/BridgechainsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.arkecosystem.client.api;

import com.google.gson.internal.LinkedTreeMap;
import org.arkecosystem.client.Connection;
import org.arkecosystem.client.MockHelper;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.HashMap;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class BridgechainsTest {

@Test
void all() throws IOException {
Connection connection = MockHelper.connection();
LinkedTreeMap<String, Object> actual = connection.api().bridgechains.all();
assertTrue((boolean) actual.get("success"));
}

@Test
void show() throws IOException {
Connection connection = MockHelper.connection();
LinkedTreeMap<String, Object> actual = connection.api().bridgechains.show("dummy");
assertTrue((boolean) actual.get("success"));
}

@Test
void search() throws IOException {
Connection connection = MockHelper.connection();
LinkedTreeMap<String, Object> actual = connection.api().bridgechains.search(new HashMap<>());
assertTrue((boolean) actual.get("success"));
}
}
Loading