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

add /sandbox/item/fire_webhook endpoint #140

Merged
merged 1 commit into from
Mar 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
5 changes: 5 additions & 0 deletions src/main/java/com/plaid/client/PlaidApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.plaid.client.request.ItemRemoveRequest;
import com.plaid.client.request.ItemStripeTokenCreateRequest;
import com.plaid.client.request.ItemWebhookUpdateRequest;
import com.plaid.client.request.SandboxItemFireWebhookRequest;
import com.plaid.client.request.SandboxItemResetLoginRequest;
import com.plaid.client.request.SandboxPublicTokenCreateRequest;
import com.plaid.client.request.TransactionsGetRequest;
Expand Down Expand Up @@ -57,6 +58,7 @@
import com.plaid.client.response.ItemRemoveResponse;
import com.plaid.client.response.ItemStripeTokenCreateResponse;
import com.plaid.client.response.ItemWebhookUpdateResponse;
import com.plaid.client.response.SandboxItemFireWebhookResponse;
import com.plaid.client.response.SandboxItemResetLoginResponse;
import com.plaid.client.response.SandboxPublicTokenCreateResponse;
import com.plaid.client.response.TransactionsGetResponse;
Expand Down Expand Up @@ -103,6 +105,9 @@ public interface PlaidApiService {
// sandbox-only endpoints
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
@POST("/sandbox/item/fire_webhook")
Call<SandboxItemFireWebhookResponse> sandboxItemFireWebhook(@Body SandboxItemFireWebhookRequest request);

@POST("/sandbox/item/reset_login")
Call<SandboxItemResetLoginResponse> sandboxItemResetLogin(@Body SandboxItemResetLoginRequest request);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.plaid.client.request;

import com.plaid.client.request.common.BaseAccessTokenRequest;

/**
* Request for the /sandbox/item/fire_webhook endpoint.
*
* @see <a href="https://plaid.com/docs/api/#TODO">https://plaid.com/docs/api/#TODO</a>
*/
public final class SandboxItemFireWebhookRequest extends BaseAccessTokenRequest {
private String webhookCode;

public SandboxItemFireWebhookRequest(String accessToken, String webhookCode) {
super(accessToken);
this.webhookCode = webhookCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.plaid.client.response;

import java.util.Date;

/**
* Response from /sandbox/item/fire_webhook endpoint.
*/
public final class SandboxItemFireWebhookResponse extends BaseResponse {
private boolean webhookFired;

public boolean getWebhookFired() {
return webhookFired;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.plaid.client.integration;

import com.plaid.client.request.ItemWebhookUpdateRequest;
import com.plaid.client.request.SandboxItemFireWebhookRequest;
import com.plaid.client.request.common.Product;
import com.plaid.client.response.ErrorResponse;
import com.plaid.client.response.ItemWebhookUpdateResponse;
import com.plaid.client.response.SandboxItemFireWebhookResponse;
import org.junit.Test;
import retrofit2.Response;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertTrue;

public class SandboxItemFireWebhookTest extends AbstractItemIntegrationTest {
@Override
protected List<Product> setupItemProducts() {
return Arrays.asList(Product.TRANSACTIONS);
}

@Override
protected String setupItemInstitutionId() {
return TARTAN_BANK_INSTITUTION_ID;
}

@Test
public void testSuccess() throws Exception {
// Set a webhook
Response<ItemWebhookUpdateResponse> webhookResponse = client().service().itemWebhookUpdate(
new ItemWebhookUpdateRequest(getItemPublicTokenExchangeResponse().getAccessToken(), "https://baz.xyz/foo-test-hook")).execute();
// Fire a webhook
Response<SandboxItemFireWebhookResponse> response =
client().service().sandboxItemFireWebhook(new SandboxItemFireWebhookRequest(getItemPublicTokenExchangeResponse().getAccessToken(), "DEFAULT_UPDATE")).execute();

assertSuccessResponse(response);
assertTrue(response.body().getWebhookFired());
}
}