Skip to content

Commit

Permalink
Upload files using files.falu.io host (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethonyango authored Jul 9, 2024
1 parent 661fc75 commit c11a596
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/io/falu/networking/FaluApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

public class FaluApiClient extends AbstractHttpApiClient {
private static final String HOST = "api.falu.io";

private static final String FILES_HOST = "files.falu.io";

private static final String SCHEME = "https";

public FaluApiClient(FaluClientOptions options, AppDetailsInterceptor interceptor, Boolean enableLogging) {
Expand All @@ -89,9 +92,13 @@ private static Request.Builder buildRequest(RequestOptions options) {
}

private static HttpUrl buildUrl(String path, @Nullable BasicListOptions listOptions) {
return buildUrl(HOST, path, listOptions);
}

private static HttpUrl buildUrl(String host, String path, @Nullable BasicListOptions listOptions) {
HttpUrl.Builder builder = new HttpUrl.Builder();
builder.scheme(SCHEME);
builder.host(HOST);
builder.host(host);
builder.addPathSegments(path);

if (listOptions != null) {
Expand Down Expand Up @@ -226,7 +233,7 @@ public ResourceResponse<PaymentRefund> getPaymentRefund(String refundId, Request
}

public ResourceResponse<PaymentRefund> updatePaymentRefund(String refundId,
PaymentRefundUpdateOptions updateOptions, RequestOptions options) throws IOException {
PaymentRefundUpdateOptions updateOptions, RequestOptions options) throws IOException {

HttpUrl url = buildUrl("v1/payment_refunds/" + refundId, null);

Expand Down Expand Up @@ -473,7 +480,7 @@ public ResourceResponse<Transfer> getTransfer(String transferId, RequestOptions
}

public ResourceResponse<Transfer> updateTransfer(String transferId, TransferUpdateOptions updateOptions,
RequestOptions options) throws IOException {
RequestOptions options) throws IOException {

HttpUrl url = buildUrl("v1/transfers" + transferId, null);

Expand Down Expand Up @@ -506,7 +513,7 @@ public ResourceResponse<TransferReversal> createTransferReversal(TransferReversa
//endregion

public ResourceResponse<TransferReversal> updateTransferReversal(String transferId,
TransferReversalUpdateOptions updateOptions, RequestOptions options) throws IOException {
TransferReversalUpdateOptions updateOptions, RequestOptions options) throws IOException {

HttpUrl url = buildUrl("v1/transfer_reversals/" + transferId, null);

Expand Down Expand Up @@ -549,7 +556,7 @@ public ResourceResponse<File> getFile(String fileId, RequestOptions requestOptio
}

public ResourceResponse<File> uploadFile(FileCreateOptions request, RequestOptions requestOptions) throws IOException {
HttpUrl url = buildUrl("v1/files", null);
HttpUrl url = buildUrl(FILES_HOST, "v1/files", null);

MultipartBody.Builder bodyBuilder = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
Expand Down Expand Up @@ -642,7 +649,7 @@ public ResourceResponse<WebhookEndpoint> getWebhookEndpoint(String endpointId, R
}

public ResourceResponse<WebhookEndpoint> updateWebhookEndpoint(String endpointId,
WebhookEndpointUpdateOptions updateOptions, RequestOptions requestOptions) throws IOException {
WebhookEndpointUpdateOptions updateOptions, RequestOptions requestOptions) throws IOException {

HttpUrl url = buildUrl("v1/webhooks/endpoints/" + endpointId, null);

Expand Down Expand Up @@ -715,7 +722,7 @@ public ResourceResponse<IdentityVerification> getIdentityVerification(String id,
}

public ResourceResponse<IdentityVerification> updateIdentityVerification(String id,
IdentityVerificationUpdateOptions updateOptions, RequestOptions requestOptions) throws IOException {
IdentityVerificationUpdateOptions updateOptions, RequestOptions requestOptions) throws IOException {
HttpUrl url = buildUrl("v1/identity/verifications/" + id, null);

Request.Builder builder = buildRequest(requestOptions)
Expand Down

0 comments on commit c11a596

Please sign in to comment.