Skip to content

Commit

Permalink
add confirmation update
Browse files Browse the repository at this point in the history
  • Loading branch information
wellimbharath committed Sep 22, 2023
1 parent b83ef0c commit b299d4d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.List;
import net.cryptonotifier.notifier.api.client.domain.BasicResponse;
import net.cryptonotifier.notifier.api.client.domain.ConfirmationResponse;
import net.cryptonotifier.notifier.api.client.domain.NewSubscription;
import net.cryptonotifier.notifier.api.client.domain.SubscriptionResponse;

Expand Down Expand Up @@ -42,4 +43,8 @@ SubscriptionResponse createSubscription(NewSubscription newSubscription)

BasicResponse deleteSubscription(String subscriptionId);


ConfirmationResponse getConfirmations(String txnId);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.cryptonotifier.notifier.api.client.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ConfirmationResponse {
String network;
String txnHash;
long blockNumber;
long currentHeight;
long confirmations;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.cryptonotifier.notifier.api.client.CryptoNotifierError;
import net.cryptonotifier.notifier.api.client.CryptoNotifierRestApiClient;
import net.cryptonotifier.notifier.api.client.domain.BasicResponse;
import net.cryptonotifier.notifier.api.client.domain.ConfirmationResponse;
import net.cryptonotifier.notifier.api.client.domain.NewSubscription;
import net.cryptonotifier.notifier.api.client.domain.SubscriptionResponse;
import retrofit2.Call;
Expand All @@ -18,41 +19,47 @@
public class CryptoNotifierRestApiClientImpl implements CryptoNotifierRestApiClient {


private final CryptoNotifierService cryptoNotifierService;

public CryptoNotifierRestApiClientImpl(String apiKey) {
cryptoNotifierService = createService(CryptoNotifierService.class, apiKey);
}


@Override
public SubscriptionResponse createSubscription(NewSubscription newSubscription) throws
CryptoNotifierError, JsonProcessingException {
final Call<SubscriptionResponse> call;
ObjectMapper objectMapper = new ObjectMapper();
call = cryptoNotifierService.createSubscription(objectMapper.convertValue(newSubscription,
JsonNode.class));
return executeSync(call);
}

@Override
public SubscriptionResponse getSubscription(String subscriptionId) {
final Call<SubscriptionResponse> call;
call = cryptoNotifierService.getSubscription(subscriptionId);
return executeSync(call);
}

@Override
public List<SubscriptionResponse> getSubscriptions(int start, int size) {
final Call<List<SubscriptionResponse>> call;
call = cryptoNotifierService.getSubscriptionList(start, size);
return executeSync(call);
}

@Override
public BasicResponse deleteSubscription(String subscriptionId) {
final Call<BasicResponse> call;
call = cryptoNotifierService.deleteSubscription(subscriptionId);
return executeSync(call);
}
private final CryptoNotifierService cryptoNotifierService;

public CryptoNotifierRestApiClientImpl(String apiKey) {
cryptoNotifierService = createService(CryptoNotifierService.class, apiKey);
}


@Override
public SubscriptionResponse createSubscription(NewSubscription newSubscription) throws
CryptoNotifierError, JsonProcessingException {
final Call<SubscriptionResponse> call;
ObjectMapper objectMapper = new ObjectMapper();
call = cryptoNotifierService.createSubscription(objectMapper.convertValue(newSubscription,
JsonNode.class));
return executeSync(call);
}

@Override
public SubscriptionResponse getSubscription(String subscriptionId) {
final Call<SubscriptionResponse> call;
call = cryptoNotifierService.getSubscription(subscriptionId);
return executeSync(call);
}

@Override
public List<SubscriptionResponse> getSubscriptions(int start, int size) {
final Call<List<SubscriptionResponse>> call;
call = cryptoNotifierService.getSubscriptionList(start, size);
return executeSync(call);
}

@Override
public BasicResponse deleteSubscription(String subscriptionId) {
final Call<BasicResponse> call;
call = cryptoNotifierService.deleteSubscription(subscriptionId);
return executeSync(call);
}

@Override
public ConfirmationResponse getConfirmations(String txnId) {
final Call<ConfirmationResponse> call = cryptoNotifierService.getConfirmation(txnId);
return executeSync(call);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import net.cryptonotifier.notifier.api.client.CryptoNotifierError;
import net.cryptonotifier.notifier.api.client.domain.BasicResponse;
import net.cryptonotifier.notifier.api.client.domain.ConfirmationResponse;
import net.cryptonotifier.notifier.api.client.domain.NewSubscription;
import net.cryptonotifier.notifier.api.client.domain.SubscriptionResponse;
import retrofit2.Call;
Expand Down Expand Up @@ -32,4 +33,6 @@ Call<SubscriptionResponse> createSubscription(@Body JsonNode newSubscription)
@DELETE("/api/v1/subscriptions/{subscriptionId}")
Call<BasicResponse> deleteSubscription(@Path("subscriptionId") String subscriptionId);

@GET("/api/v1/confirmations/{txnId}")
Call<ConfirmationResponse> getConfirmation(String txnId);
}

0 comments on commit b299d4d

Please sign in to comment.