From 2229ffcd71138be5dffbe0d9f853fcf9f336f1e6 Mon Sep 17 00:00:00 2001 From: Kristjan Kosic Date: Tue, 18 Feb 2020 12:15:58 +0100 Subject: [PATCH] release: 1.0.1 (#89) * chore: fixed root project name * chore: clean build.gradle, prepare for github packages, adjust to latest format * style: back to aosp 1.1 format rules * fix: parameter passing * chore: github action to test against multiple java-versions * chore: github action for publish package when tag release --- .github/workflows/publish-release.yml | 27 +++ .github/workflows/test.yml | 20 ++- build.gradle | 158 ++++++------------ settings.gradle | 2 +- .../org/arkecosystem/client/Connection.java | 18 +- .../client/ConnectionManager.java | 86 +++++----- .../java/org/arkecosystem/client/api/Api.java | 52 +++--- .../arkecosystem/client/api/Blockchain.java | 14 +- .../org/arkecosystem/client/api/Blocks.java | 44 ++--- .../arkecosystem/client/api/Bridgechains.java | 26 +-- .../arkecosystem/client/api/Businesses.java | 32 ++-- .../arkecosystem/client/api/Delegates.java | 38 ++--- .../org/arkecosystem/client/api/Locks.java | 34 ++-- .../org/arkecosystem/client/api/Node.java | 48 +++--- .../org/arkecosystem/client/api/Peers.java | 20 +-- .../org/arkecosystem/client/api/Rounds.java | 14 +- .../arkecosystem/client/api/Transactions.java | 66 ++++---- .../org/arkecosystem/client/api/Votes.java | 20 +-- .../org/arkecosystem/client/api/Wallets.java | 62 +++---- .../org/arkecosystem/client/http/Client.java | 83 ++++----- 20 files changed, 416 insertions(+), 448 deletions(-) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..b44a7ff --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,27 @@ +name: Publish Release + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Build with Gradle + run: gradle build + + - name: Publish to GitHub Packages + run: gradle publish + env: + USERNAME: ${{ github.actor }} + PASSWORD: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f9805d..5ddda25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,23 +1,27 @@ name: Test on: - push: - branches: - - "master" - - "develop" - pull_request: - types: [ready_for_review, synchronize, opened] + push: + branches: + - "master" + - "develop" + pull_request: + types: [ready_for_review, synchronize, opened] jobs: unit: runs-on: ubuntu-latest + strategy: + matrix: + # test against latest update of each major Java version, as well as specific updates of LTS versions: + java: [ 8, 9, 10, 11, 12, 13 ] steps: - uses: actions/checkout@v1 - - name: Set up JDK 1.8 + - name: Use Java Version ${{ matrix.java }} uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: ${{ matrix.java }} - name: Install run: gradle dependencies - name: Test diff --git a/build.gradle b/build.gradle index 794f140..f9be1ae 100644 --- a/build.gradle +++ b/build.gradle @@ -1,128 +1,41 @@ -buildscript { - dependencies { - classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1" - } -} - plugins { id 'java' - id 'maven' id 'maven-publish' - id 'signing' id 'jacoco' + id 'com.diffplug.gradle.spotless' version '3.27.1' } -apply plugin:'java' -apply plugin:'maven' -apply plugin:'maven-publish' -apply plugin: com.diffplug.gradle.spotless.SpotlessPlugin - repositories { jcenter() mavenCentral() } -task fatJar(type: Jar) { - manifest.from jar.manifest - classifier = 'standalone' - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } { - exclude "META-INF/*.SF" - exclude "META-INF/*.DSA" - exclude "META-INF/*.RSA" - } - with jar -} - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -artifacts { - archives javadocJar, sourcesJar -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "file://${buildDir}/repo") {} - - //repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") { - // authentication(userName: '', password: '') - // } - - // snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - // authentication(userName: ossrhUsername, password: ossrhPassword) - // } - - pom.project { - groupId = 'org.arkecosystem' - version = '1.0.0' - artifactId = 'client' - - name = 'java-client' - description = 'A simple Java API client for the ARK Blockchain.' - url = 'https://github.com/ArkEcosystem/java-client' - inceptionYear = '2018' - - licenses { - license { - name = 'MIT' - distribution = 'repo' - } - } - - developers { - developer { - name = 'Brian Faust' - email = 'brian@ark.io' - organization = 'Ark Ecosystem' - organizationUrl = 'https://ark.io' - } - developer { - name = 'Joshua Noack' - email = 'joshua@ark.io' - organization = 'Ark Ecosystem' - organizationUrl = 'https://ark.io' - } - developer { - name = 'Kristjan Kosic' - email = 'kristjan@ark.io' - organization = 'Ark Ecosystem' - organizationUrl = 'https://ark.io' - } - developer { - name = 'Zan Kovac' - email = 'zan@ark.io' - organization = 'Ark Ecosystem' - organizationUrl = 'https://ark.io' - } - } - - scm { - connection = 'scm:git:git://github.com/ArkEcosystem/java-client.git' - developerConnection = 'scm:git:ssh://github.com:ArkEcosystem/java-client.git' - url = 'https://github.com/ArkEcosystem/java-client/tree/1.0.0' +group = 'org.arkecosystem' +version = '1.0.1' + +publishing { + publishing { + repositories { + maven { + name = "github" + url = uri("https://maven.pkg.github.com/arkecosystem/java-client") + credentials { + username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") + password = project.findProperty("gpr.key") ?: System.getenv("PASSWORD") } } } + publications { + gpr(MavenPublication) { + from(components.java) + } + } } -} - -if (project.hasProperty("signing.keyId")) { - apply plugin:'signing' - signing { - sign configurations.archives + javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } } } @@ -151,7 +64,7 @@ jacocoTestReport { } wrapper { - gradleVersion = '5.6.2' + gradleVersion = '6.2.0' } spotless { @@ -160,7 +73,7 @@ spotless { include 'src/main/**/*.java' exclude '**/build/**' } - googleJavaFormat() + googleJavaFormat('1.1').aosp() removeUnusedImports() } @@ -168,4 +81,27 @@ spotless { task formatCode(dependsOn: ['spotlessApply']) +task fatJar(type: Jar) { + manifest.from jar.manifest + classifier = 'standalone' + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } { + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" + } + with jar +} + +task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc +} + +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + build.dependsOn 'spotlessApply' diff --git a/settings.gradle b/settings.gradle index 6aa4ed9..7293304 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -rootProject.name = 'arkecosystem-client' +rootProject.name = 'java-client' diff --git a/src/main/java/org/arkecosystem/client/Connection.java b/src/main/java/org/arkecosystem/client/Connection.java index 3892918..66a55f1 100644 --- a/src/main/java/org/arkecosystem/client/Connection.java +++ b/src/main/java/org/arkecosystem/client/Connection.java @@ -5,15 +5,15 @@ import org.arkecosystem.client.http.Client; public class Connection { - private Api api; - private Client client; + private Api api; + private Client client; - public Connection(Map config) { - this.client = new Client(config.get("host").toString()); - this.api = new Api(this.client); - } + public Connection(Map config) { + this.client = new Client(config.get("host").toString()); + this.api = new Api(this.client); + } - public Api api() { - return this.api; - } + public Api api() { + return this.api; + } } diff --git a/src/main/java/org/arkecosystem/client/ConnectionManager.java b/src/main/java/org/arkecosystem/client/ConnectionManager.java index 401c608..0146632 100644 --- a/src/main/java/org/arkecosystem/client/ConnectionManager.java +++ b/src/main/java/org/arkecosystem/client/ConnectionManager.java @@ -4,64 +4,64 @@ import java.util.Map; public class ConnectionManager { - private Map connections; - private String defaultConnection = "main"; + private Map connections; + private String defaultConnection = "main"; - public ConnectionManager() { - this.connections = new HashMap<>(); - } - - public String getDefaultConnection() { - return this.defaultConnection; - } - - public void setDefaultConnection(String name) { - this.defaultConnection = name; - } + public ConnectionManager() { + this.connections = new HashMap<>(); + } - public Map getConnections() { - return this.connections; - } + public String getDefaultConnection() { + return this.defaultConnection; + } - public Connection connect(Map config, String name) { - if (this.connections.containsKey(name)) { - throw new IllegalArgumentException("Connection [" + name + "] is already configured."); + public void setDefaultConnection(String name) { + this.defaultConnection = name; } - this.connections.put(name, new Connection(config)); + public Map getConnections() { + return this.connections; + } - return this.connections.get(name); - } + public Connection connect(Map config, String name) { + if (this.connections.containsKey(name)) { + throw new IllegalArgumentException("Connection [" + name + "] is already configured."); + } - public Connection connect(Map config) { - return connect(config, "main"); - } + this.connections.put(name, new Connection(config)); - public void disconnect(String name) { - if (name == null || name.isEmpty()) { - name = getDefaultConnection(); + return this.connections.get(name); } - this.connections.remove(name); - } + public Connection connect(Map config) { + return connect(config, "main"); + } - public void disconnect() { - disconnect(null); - } + public void disconnect(String name) { + if (name == null || name.isEmpty()) { + name = getDefaultConnection(); + } - public Connection connection(String name) { - if (name == null || name.isEmpty()) { - name = getDefaultConnection(); + this.connections.remove(name); } - if (!this.connections.containsKey(name)) { - throw new IllegalArgumentException("Connection [" + name + "] not configured."); + public void disconnect() { + disconnect(null); } - return this.connections.get(name); - } + public Connection connection(String name) { + if (name == null || name.isEmpty()) { + name = getDefaultConnection(); + } + + if (!this.connections.containsKey(name)) { + throw new IllegalArgumentException("Connection [" + name + "] not configured."); + } - public Connection connection() { - return connection(null); - } + return this.connections.get(name); + } + + public Connection connection() { + return connection(null); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Api.java b/src/main/java/org/arkecosystem/client/api/Api.java index 381ee14..d78083e 100644 --- a/src/main/java/org/arkecosystem/client/api/Api.java +++ b/src/main/java/org/arkecosystem/client/api/Api.java @@ -4,31 +4,31 @@ 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; - public Transactions transactions; - public Votes votes; - public Wallets wallets; + 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; + public Transactions transactions; + public Votes votes; + 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); - this.transactions = new Transactions(client); - this.votes = new Votes(client); - this.wallets = new Wallets(client); - } + 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); + this.transactions = new Transactions(client); + this.votes = new Votes(client); + this.wallets = new Wallets(client); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Blockchain.java b/src/main/java/org/arkecosystem/client/api/Blockchain.java index ab52dd8..1f234d2 100644 --- a/src/main/java/org/arkecosystem/client/api/Blockchain.java +++ b/src/main/java/org/arkecosystem/client/api/Blockchain.java @@ -6,13 +6,13 @@ public class Blockchain { - private Client client; + private Client client; - public Blockchain(Client client) { - this.client = client; - } + public Blockchain(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("blockchain"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("blockchain"); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Blocks.java b/src/main/java/org/arkecosystem/client/api/Blocks.java index b76f753..7fd4fb1 100644 --- a/src/main/java/org/arkecosystem/client/api/Blocks.java +++ b/src/main/java/org/arkecosystem/client/api/Blocks.java @@ -6,33 +6,33 @@ import org.arkecosystem.client.http.Client; public class Blocks { - private Client client; + private Client client; - public Blocks(Client client) { - this.client = client; - } + public Blocks(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("blocks"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("blocks"); + } - public LinkedTreeMap first() throws IOException { - return this.client.get("blocks/first"); - } + public LinkedTreeMap first() throws IOException { + return this.client.get("blocks/first"); + } - public LinkedTreeMap last() throws IOException { - return this.client.get("blocks/last"); - } + public LinkedTreeMap last() throws IOException { + return this.client.get("blocks/last"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("blocks/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("blocks/" + id); + } - public LinkedTreeMap transactions(String id) throws IOException { - return this.client.get("blocks/" + id + "/transactions"); - } + public LinkedTreeMap transactions(String id) throws IOException { + return this.client.get("blocks/" + id + "/transactions"); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("blocks/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("blocks/search", parameters); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Bridgechains.java b/src/main/java/org/arkecosystem/client/api/Bridgechains.java index b0715eb..5cb5fd8 100644 --- a/src/main/java/org/arkecosystem/client/api/Bridgechains.java +++ b/src/main/java/org/arkecosystem/client/api/Bridgechains.java @@ -6,21 +6,21 @@ import org.arkecosystem.client.http.Client; public class Bridgechains { - private Client client; + private Client client; - public Bridgechains(Client client) { - this.client = client; - } + public Bridgechains(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("bridgechains"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("bridgechains"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("bridgechains/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("bridgechains/" + id); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("bridgechains/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("bridgechains/search", parameters); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Businesses.java b/src/main/java/org/arkecosystem/client/api/Businesses.java index 4e460eb..934d5b1 100644 --- a/src/main/java/org/arkecosystem/client/api/Businesses.java +++ b/src/main/java/org/arkecosystem/client/api/Businesses.java @@ -6,25 +6,25 @@ import org.arkecosystem.client.http.Client; public class Businesses { - private Client client; + private Client client; - public Businesses(Client client) { - this.client = client; - } + public Businesses(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("businesses"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("businesses"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("businesses/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("businesses/" + id); + } - public LinkedTreeMap showBridgechains(String id) throws IOException { - return this.client.get("businesses/" + id + "/bridgechains"); - } + public LinkedTreeMap showBridgechains(String id) throws IOException { + return this.client.get("businesses/" + id + "/bridgechains"); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("businesses/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("businesses/search", parameters); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Delegates.java b/src/main/java/org/arkecosystem/client/api/Delegates.java index 9883fd5..3629b3b 100644 --- a/src/main/java/org/arkecosystem/client/api/Delegates.java +++ b/src/main/java/org/arkecosystem/client/api/Delegates.java @@ -6,29 +6,29 @@ import org.arkecosystem.client.http.Client; public class Delegates { - private Client client; + private Client client; - public Delegates(Client client) { - this.client = client; - } + public Delegates(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("delegates"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("delegates"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("delegates/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("delegates/" + id); + } - public LinkedTreeMap blocks(String id) throws IOException { - return this.client.get("delegates/" + id + "/blocks"); - } + public LinkedTreeMap blocks(String id) throws IOException { + return this.client.get("delegates/" + id + "/blocks"); + } - public LinkedTreeMap voters(String id) throws IOException { - return this.client.get("delegates/" + id + "/voters"); - } + public LinkedTreeMap voters(String id) throws IOException { + return this.client.get("delegates/" + id + "/voters"); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("delegates/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("delegates/search", parameters); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Locks.java b/src/main/java/org/arkecosystem/client/api/Locks.java index 53d48a1..83023ac 100644 --- a/src/main/java/org/arkecosystem/client/api/Locks.java +++ b/src/main/java/org/arkecosystem/client/api/Locks.java @@ -6,26 +6,26 @@ import org.arkecosystem.client.http.Client; public class Locks { - private Client client; + private Client client; - public Locks(Client client) { - this.client = client; - } + public Locks(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("locks"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("locks"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("locks/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("locks/" + id); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("locks/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("locks/search", parameters); + } - public LinkedTreeMap searchUnlocked(Map parameters) - throws IOException { - return this.client.post("locks/unlocked", parameters); - } + public LinkedTreeMap searchUnlocked(Map parameters) + throws IOException { + return this.client.post("locks/unlocked", parameters); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Node.java b/src/main/java/org/arkecosystem/client/api/Node.java index f1e406e..fb2a93e 100644 --- a/src/main/java/org/arkecosystem/client/api/Node.java +++ b/src/main/java/org/arkecosystem/client/api/Node.java @@ -6,35 +6,35 @@ import org.arkecosystem.client.http.Client; public class Node { - private Client client; + private Client client; - public Node(Client client) { - this.client = client; - } + public Node(Client client) { + this.client = client; + } - public LinkedTreeMap status() throws IOException { - return this.client.get("node/status"); - } + public LinkedTreeMap status() throws IOException { + return this.client.get("node/status"); + } - public LinkedTreeMap syncing() throws IOException { - return this.client.get("node/syncing"); - } + public LinkedTreeMap syncing() throws IOException { + return this.client.get("node/syncing"); + } - public LinkedTreeMap configuration() throws IOException { - return this.client.get("node/configuration"); - } + public LinkedTreeMap configuration() throws IOException { + return this.client.get("node/configuration"); + } - public LinkedTreeMap crypto() throws IOException { - return this.client.get("node/configuration/crypto"); - } + public LinkedTreeMap crypto() throws IOException { + return this.client.get("node/configuration/crypto"); + } - public LinkedTreeMap fees(Integer... days) throws IOException { - HashMap parameters = new HashMap<>(); - parameters.put("days", days.length > 0 ? days[0] : null); - return this.client.get("node/fees"); - } + public LinkedTreeMap fees(Integer... days) throws IOException { + HashMap parameters = new HashMap<>(); + parameters.put("days", days.length > 0 ? days[0] : null); + return this.client.get("node/fees", parameters); + } - public LinkedTreeMap debug() throws IOException { - return this.client.get("node/debug"); - } + public LinkedTreeMap debug() throws IOException { + return this.client.get("node/debug"); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Peers.java b/src/main/java/org/arkecosystem/client/api/Peers.java index 576e382..784c364 100644 --- a/src/main/java/org/arkecosystem/client/api/Peers.java +++ b/src/main/java/org/arkecosystem/client/api/Peers.java @@ -5,17 +5,17 @@ import org.arkecosystem.client.http.Client; public class Peers { - private Client client; + private Client client; - public Peers(Client client) { - this.client = client; - } + public Peers(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("peers"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("peers"); + } - public LinkedTreeMap show(String ip) throws IOException { - return this.client.get("peers/" + ip); - } + public LinkedTreeMap show(String ip) throws IOException { + return this.client.get("peers/" + ip); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Rounds.java b/src/main/java/org/arkecosystem/client/api/Rounds.java index 73668d6..ab9fa3b 100644 --- a/src/main/java/org/arkecosystem/client/api/Rounds.java +++ b/src/main/java/org/arkecosystem/client/api/Rounds.java @@ -5,13 +5,13 @@ import org.arkecosystem.client.http.Client; public class Rounds { - private Client client; + private Client client; - public Rounds(Client client) { - this.client = client; - } + public Rounds(Client client) { + this.client = client; + } - public LinkedTreeMap delegates(int id) throws IOException { - return this.client.get("rounds/" + id + "/delegates"); - } + public LinkedTreeMap delegates(int id) throws IOException { + return this.client.get("rounds/" + id + "/delegates"); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Transactions.java b/src/main/java/org/arkecosystem/client/api/Transactions.java index 2e11322..ece56e7 100644 --- a/src/main/java/org/arkecosystem/client/api/Transactions.java +++ b/src/main/java/org/arkecosystem/client/api/Transactions.java @@ -8,47 +8,47 @@ import org.arkecosystem.client.http.Client; public class Transactions { - private Client client; + private Client client; - public Transactions(Client client) { - this.client = client; - } + public Transactions(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("transactions"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("transactions"); + } - public LinkedTreeMap create(List transactions) throws IOException { - HashMap> params = new HashMap<>(); - params.put("transactions", transactions); - return this.client.post("transactions", params); - } + public LinkedTreeMap create(List transactions) throws IOException { + HashMap> params = new HashMap<>(); + params.put("transactions", transactions); + return this.client.post("transactions", params); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("transactions/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("transactions/" + id); + } - public LinkedTreeMap allUnconfirmed() throws IOException { - return this.client.get("transactions/unconfirmed"); - } + public LinkedTreeMap allUnconfirmed() throws IOException { + return this.client.get("transactions/unconfirmed"); + } - public LinkedTreeMap showUnconfirmed(String id) throws IOException { - return this.client.get("transactions/unconfirmed/" + id); - } + public LinkedTreeMap showUnconfirmed(String id) throws IOException { + return this.client.get("transactions/unconfirmed/" + id); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("transactions/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("transactions/search", parameters); + } - public LinkedTreeMap types() throws IOException { - return this.client.get("transactions/types"); - } + public LinkedTreeMap types() throws IOException { + return this.client.get("transactions/types"); + } - public LinkedTreeMap schemas() throws IOException { - return this.client.get("transactions/schemas"); - } + public LinkedTreeMap schemas() throws IOException { + return this.client.get("transactions/schemas"); + } - public LinkedTreeMap fees() throws IOException { - return this.client.get("transactions/fees"); - } + public LinkedTreeMap fees() throws IOException { + return this.client.get("transactions/fees"); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Votes.java b/src/main/java/org/arkecosystem/client/api/Votes.java index 6cecae4..9cc0cbc 100644 --- a/src/main/java/org/arkecosystem/client/api/Votes.java +++ b/src/main/java/org/arkecosystem/client/api/Votes.java @@ -5,17 +5,17 @@ import org.arkecosystem.client.http.Client; public class Votes { - private Client client; + private Client client; - public Votes(Client client) { - this.client = client; - } + public Votes(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("votes"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("votes"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("votes/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("votes/" + id); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Wallets.java b/src/main/java/org/arkecosystem/client/api/Wallets.java index d312ee1..2a77de8 100644 --- a/src/main/java/org/arkecosystem/client/api/Wallets.java +++ b/src/main/java/org/arkecosystem/client/api/Wallets.java @@ -6,45 +6,45 @@ import org.arkecosystem.client.http.Client; public class Wallets { - private Client client; + private Client client; - public Wallets(Client client) { - this.client = client; - } + public Wallets(Client client) { + this.client = client; + } - public LinkedTreeMap all() throws IOException { - return this.client.get("wallets"); - } + public LinkedTreeMap all() throws IOException { + return this.client.get("wallets"); + } - public LinkedTreeMap top() throws IOException { - return this.client.get("wallets/top"); - } + public LinkedTreeMap top() throws IOException { + return this.client.get("wallets/top"); + } - public LinkedTreeMap show(String id) throws IOException { - return this.client.get("wallets/" + id); - } + public LinkedTreeMap show(String id) throws IOException { + return this.client.get("wallets/" + id); + } - public LinkedTreeMap transactions(String id) throws IOException { - return this.client.get("wallets/" + id + "/transactions"); - } + public LinkedTreeMap transactions(String id) throws IOException { + return this.client.get("wallets/" + id + "/transactions"); + } - public LinkedTreeMap sentTransactions(String id) throws IOException { - return this.client.get("wallets/" + id + "/transactions/sent"); - } + public LinkedTreeMap sentTransactions(String id) throws IOException { + return this.client.get("wallets/" + id + "/transactions/sent"); + } - public LinkedTreeMap receivedTransactions(String id) throws IOException { - return this.client.get("wallets/" + id + "/transactions/received"); - } + public LinkedTreeMap receivedTransactions(String id) throws IOException { + return this.client.get("wallets/" + id + "/transactions/received"); + } - public LinkedTreeMap votes(String id) throws IOException { - return this.client.get("wallets/" + id + "/votes"); - } + public LinkedTreeMap votes(String id) throws IOException { + return this.client.get("wallets/" + id + "/votes"); + } - public LinkedTreeMap locks(String id) throws IOException { - return this.client.get("wallets/" + id + "/locks"); - } + public LinkedTreeMap locks(String id) throws IOException { + return this.client.get("wallets/" + id + "/locks"); + } - public LinkedTreeMap search(Map parameters) throws IOException { - return this.client.post("wallets/search", parameters); - } + public LinkedTreeMap search(Map parameters) throws IOException { + return this.client.post("wallets/search", parameters); + } } diff --git a/src/main/java/org/arkecosystem/client/http/Client.java b/src/main/java/org/arkecosystem/client/http/Client.java index d5c02fb..98d3fc5 100644 --- a/src/main/java/org/arkecosystem/client/http/Client.java +++ b/src/main/java/org/arkecosystem/client/http/Client.java @@ -8,57 +8,58 @@ import okhttp3.*; public class Client { - private String host; - private OkHttpClient client; - private Headers headers; - private MediaType JSON = MediaType.parse("application/json"); + private String host; + private OkHttpClient client; + private Headers headers; + private MediaType JSON = MediaType.parse("application/json"); - public Client(String host) { - this.host = host; - this.client = new OkHttpClient(); + public Client(String host) { + this.host = host; + this.client = new OkHttpClient(); - HashMap headers = new HashMap<>(); - headers.put("content-type", this.JSON.toString()); + HashMap headers = new HashMap<>(); + headers.put("content-type", this.JSON.toString()); - this.headers = Headers.of(headers); - } + this.headers = Headers.of(headers); + } - public LinkedTreeMap get(String url, Map params) - throws IOException { - HttpUrl.Builder httpBuilder = HttpUrl.parse(this.host + url).newBuilder(); + public LinkedTreeMap get(String url, Map params) + throws IOException { + HttpUrl.Builder httpBuilder = HttpUrl.parse(this.host + url).newBuilder(); - if (params != null) { - for (Map.Entry entry : params.entrySet()) { - if (entry.getValue() != null) { - httpBuilder.addQueryParameter(entry.getKey(), entry.getValue().toString()); + if (params != null) { + for (Map.Entry entry : params.entrySet()) { + if (entry.getValue() != null) { + httpBuilder.addQueryParameter(entry.getKey(), entry.getValue().toString()); + } + } } - } - } - Request request = new Request.Builder().headers(this.headers).url(httpBuilder.build()).build(); + Request request = + new Request.Builder().headers(this.headers).url(httpBuilder.build()).build(); - Response response = client.newCall(request).execute(); - return new Gson() - .fromJson(response.body().string(), new LinkedTreeMap().getClass()); - } + Response response = client.newCall(request).execute(); + return new Gson() + .fromJson(response.body().string(), new LinkedTreeMap().getClass()); + } - public LinkedTreeMap get(String url) throws IOException { - return get(url, new HashMap()); - } + public LinkedTreeMap get(String url) throws IOException { + return get(url, new HashMap()); + } - public LinkedTreeMap post(String url, Map payload) throws IOException { - RequestBody body = RequestBody.create(JSON, new Gson().toJson(payload)); - Request request = new Request.Builder().url(this.host + url).post(body).build(); - Response response = client.newCall(request).execute(); - return new Gson() - .fromJson(response.body().string(), new LinkedTreeMap().getClass()); - } + public LinkedTreeMap post(String url, Map payload) throws IOException { + RequestBody body = RequestBody.create(JSON, new Gson().toJson(payload)); + Request request = new Request.Builder().url(this.host + url).post(body).build(); + Response response = client.newCall(request).execute(); + return new Gson() + .fromJson(response.body().string(), new LinkedTreeMap().getClass()); + } - public OkHttpClient getClient() { - return client; - } + public OkHttpClient getClient() { + return client; + } - public void setClient(OkHttpClient client) { - this.client = client; - } + public void setClient(OkHttpClient client) { + this.client = client; + } }