use of com.stripe.net.RequestOptions in project stripe-java by stripe.
the class AccountTest method testOverloadedSingleArgumentRetrieve.
@Test
public void testOverloadedSingleArgumentRetrieve() throws StripeException {
Account.retrieve("sk_foobar");
RequestOptions options = (new RequestOptionsBuilder()).setApiKey("sk_foobar").build();
verifyGet(Account.class, "https://api.stripe.com/v1/account", options);
Account.retrieve("anything_else");
verifyGet(Account.class, "https://api.stripe.com/v1/accounts/anything_else");
verifyNoMoreInteractions(networkMock);
}
use of com.stripe.net.RequestOptions in project stripe-java by stripe.
the class EphemeralKeyTest method testVersionlessCreate.
@Test(expected = IllegalArgumentException.class)
public void testVersionlessCreate() throws StripeException {
Stripe.apiVersion = null;
final Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", "cus_123");
final RequestOptions options = RequestOptions.getDefault();
EphemeralKey.create(params, options);
}
use of com.stripe.net.RequestOptions in project stripe-java by stripe.
the class EphemeralKeyTest method testCreate.
@Test
public void testCreate() throws StripeException {
Stripe.apiVersion = "2016-06-05";
final Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", "cus_123");
final RequestOptions options = RequestOptions.builder().setStripeVersion("2017-05-25").build();
EphemeralKey.create(params, options);
verifyPost(EphemeralKey.class, "https://api.stripe.com/v1/ephemeral_keys", params, options);
verifyNoMoreInteractions(networkMock);
}
use of com.stripe.net.RequestOptions in project stripe-java by stripe.
the class PagingIteratorTest method testAutoPagination.
@Test
public void testAutoPagination() throws IOException, StripeException {
// set some arbitrary parameters so that we can verify that they're
// used for requests on ALL pages
Map<String, Object> page0Params = new HashMap<String, Object>();
page0Params.put("foo", "bar");
Map<String, Object> page1Params = new HashMap<String, Object>();
page1Params.put("foo", "bar");
page1Params.put("starting_after", "pm_124");
Map<String, Object> page2Params = new HashMap<String, Object>();
page2Params.put("foo", "bar");
page2Params.put("starting_after", "pm_126");
RequestOptions options = (new RequestOptionsBuilder()).setApiKey("sk_paging_key").build();
PageableModelCollection collection = PageableModel.list(page0Params, options);
List<PageableModel> models = new ArrayList<PageableModel>();
for (PageableModel model : collection.autoPagingIterable()) {
models.add(model);
}
assertEquals(5, models.size());
assertEquals("pm_123", models.get(0).getId());
assertEquals("pm_124", models.get(1).getId());
assertEquals("pm_125", models.get(2).getId());
assertEquals("pm_126", models.get(3).getId());
assertEquals("pm_127", models.get(4).getId());
verifyGet(PageableModelCollection.class, "https://api.stripe.com/v1/pageablemodels", page0Params, options);
verifyGet(PageableModelCollection.class, "https://api.stripe.com/v1/pageablemodels", page1Params, options);
verifyGet(PageableModelCollection.class, "https://api.stripe.com/v1/pageablemodels", page2Params, options);
verifyNoMoreInteractions(networkMock);
}
Aggregations