diff --git a/pom.xml b/pom.xml
index 9845b2f..795d3d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.chargify
chargify-sdk
- 0.2.7
+ 0.44
jar
Chargify SDK for Java
@@ -16,14 +16,14 @@
The Apache License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
+ https://www.apache.org/licenses/LICENSE-2.0.txt
- Sergey Chupov
- scadgek@live.com
+ Backendless
+ chargify-sdk-for-java@backendless.com
Backendless
https://backendless.com/
@@ -32,67 +32,100 @@
scm:git:git://github.com/scadgek/chargify-java-sdk.git
scm:git:ssh://github.com:scadgek/chargify-java-sdk.git
- http://github.com/github.com/scadgek/chargify-java-sdk/tree/master
+ https://github.com/github.com/scadgek/chargify-java-sdk/tree/master
UTF-8
- 1.8
- 1.8
+ 17
+ 17
+ backendless_private
+ https://maven.backendless.com/repository/backendless_private/
+
org.springframework
- spring-web
- 5.0.5.RELEASE
-
-
-
- org.springframework.boot
- spring-boot
- 2.0.1.RELEASE
+ spring-webflux
+ 6.0.12
+ provided
com.fasterxml.jackson.core
jackson-databind
- 2.9.5
+ 2.14.3
+ provided
com.fasterxml.jackson.datatype
jackson-datatype-jsr310
- 2.9.5
+ 2.14.3
+ provided
ch.qos.logback
logback-classic
- 1.2.3
+ 1.4.11
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.12.0
+
+
+
+ io.projectreactor.netty
+ reactor-netty
+ 1.1.11
+ provided
+
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.28
+ provided
junit
junit
- 4.12
+ 4.13.2
test
org.springframework
spring-test
- 5.0.5.RELEASE
+ 6.0.12
test
+
+
+ ${repo.bkndls_private}
+ ${repo.bkndls_private.url}snapshots/
+
+
+ ${repo.bkndls_private}
+ ${repo.bkndls_private.url}
+
+
+
org.apache.maven.plugins
maven-source-plugin
+ 3.2.1
attach-sources
@@ -105,6 +138,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
+ 3.3.1
attach-javadocs
@@ -114,7 +148,16 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 17
+ 17
+
+
+
-
\ No newline at end of file
+
diff --git a/src/main/java/com/chargify/Chargify.java b/src/main/java/com/chargify/Chargify.java
index 8f62159..d7f757c 100644
--- a/src/main/java/com/chargify/Chargify.java
+++ b/src/main/java/com/chargify/Chargify.java
@@ -1,99 +1,159 @@
package com.chargify;
-import com.chargify.model.Allocation;
-import com.chargify.model.Component;
-import com.chargify.model.ComponentPricePointUpdate;
-import com.chargify.model.Customer;
-import com.chargify.model.Metadata;
-import com.chargify.model.Product;
-import com.chargify.model.ProductFamily;
-import com.chargify.model.ReferralCode;
-import com.chargify.model.RenewalPreview;
-import com.chargify.model.Subscription;
-import com.chargify.model.SubscriptionComponent;
-import com.chargify.model.SubscriptionMetadata;
-import com.chargify.model.Usage;
-
+import com.chargify.model.*;
+import com.chargify.model.product.Product;
+import com.chargify.model.product.ProductFamily;
+import com.chargify.model.product.ProductPricePoint;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.time.LocalDateTime;
import java.util.List;
public interface Chargify
{
- ProductFamily createProductFamily( ProductFamily productFamily );
+ Mono createProductFamily( ProductFamily productFamily );
+
+ Mono findProductFamilyById( String id );
+
+ Flux findAllProductFamilies();
+
+ Mono archiveProductFamilyById( String id );
+
+ Mono createProduct( String productFamilyId, Product product );
+
+ Mono findProductById( String id );
+
+ Mono findProductByApiHandle( String apiHandle );
+
+ Flux findProductPricePointsByProductId( String productId );
+
+ Flux findComponentPricePoints( int componentId );
+
+ Mono updatePricePoint( int componentId, int pricePointId, PricePointUpdate pricePointUpdate );
+
+ Flux findAllProducts();
+
+ Flux findProductsByProductFamilyId( String productFamilyId );
+
+ Mono archiveProductById( String id );
+
+ Mono createSubscription( CreateSubscription subscription );
- ProductFamily findProductFamilyById( String id );
+ Mono updateSubscription( String subscriptionId, UpdateSubscription subscription );
- List findAllProductFamilies();
+ Mono updateSubscriptionNextBillingDate( String subscriptionId, LocalDateTime nextBillingDate );
- ProductFamily archiveProductFamilyById( String id );
+ Mono createSubscriptionCharge( String subscriptionId, SubscriptionCharge subscriptionCharge );
- Product createProduct( String productFamilyId, Product product );
+ Mono findSubscriptionById( String id );
- Product findProductById( String id );
+ Flux findPaymentProfilesForCustomer( String customerId );
- Product findProductByApiHandle( String apiHandle );
+ Mono createPaymentProfile( CreatePaymentProfile paymentProfile );
- List findAllProducts();
+ Mono updatePaymentProfile( String paymentProfileId, UpdatePaymentProfile paymentProfile );
- List findProductsByProductFamilyId( String productFamilyId );
+ Mono updateSubscriptionPaymentProfile( String subscriptionId, String paymentProfileId );
- Product archiveProductById( String id );
+ Mono findPaymentProfileById( String paymentProfileId );
- Subscription createSubscription( Subscription subscription );
+ Mono deleteUnusedPaymentProfile( String paymentProfileId );
- Subscription findSubscriptionById( String id );
+ Mono deletePaymentProfile( String subscriptionId, String paymentProfileId );
- List findSubscriptionsByCustomerId( String customerId );
+ Flux findSubscriptionsByCustomerId( String customerId );
- List findAllSubscriptions();
+ Flux findSubscriptionsByCustomerId( String customerId, int pageNumber, int pageSize );
- List findSubscriptionsByState( String state, int pageNumber, int pageSize );
+ Flux findAllSubscriptions();
- Subscription cancelSubscriptionById( String id );
+ Mono purgeSubscription( Subscription subscription );
- Subscription cancelSubscriptionProductChange( String subscriptionId );
+ Flux findSubscriptionsByState( String state, int pageNumber, int pageSize );
- Subscription migrateSubscription( String subscriptionId, String productHandle );
+ Mono cancelSubscriptionById( String id );
- Subscription reactivateSubscription( String subscriptionId );
+ Mono cancelSubscriptionProductChange( String subscriptionId );
- ComponentPricePointUpdate migrateSubscriptionComponentToPricePoint( String subscriptionId, int componentId,
+ Mono migrateSubscription( String subscriptionId, Migration migration );
+
+ Mono reactivateSubscription( String subscriptionId, boolean preserveBalance );
+
+ Mono reactivateSubscription( String subscriptionId, SubscriptionReactivationData reactivationData );
+
+ Mono migrateSubscriptionComponentToPricePoint( String subscriptionId, int componentId,
String pricePointHandle );
- Subscription changeSubscriptionProduct( String subscriptionId, String productHandle, boolean delayed );
+ Flux bulkUpdateSubscriptionComponentPricePoint( String subscriptionId, List items );
+
+ Mono cancelScheduledSubscriptionProductChange( String subscriptionId );
+
+ Mono changeSubscriptionProduct( String subscriptionId, SubscriptionProductUpdate payload );
+
+ Mono previewSubscriptionRenewal( String subscriptionId );
+
+ Flux createSubscriptionMetadata( String subscriptionId, Metadata... metadata );
+
+ Mono readSubscriptionMetadata( String subscriptionId );
+
+ Flux updateSubscriptionMetadata( String subscriptionId, Metadata... metadata );
+
+ Mono createComponent( String productFamilyId, Component component );
+
+ Mono createComponentAllocation( String subscriptionId, int componentId, Allocation allocation );
+
+ Mono previewComponentAllocation( String subscriptionId, int componentId, int quantity );
+
+ Flux findComponentsByProductFamily( String productFamilyId );
- RenewalPreview previewSubscriptionRenewal( String subscriptionId );
+ Mono findComponentByIdAndProductFamily( int componentId, String productFamilyId );
- List createSubscriptionMetadata( String subscriptionId, Metadata... metadata );
+ Mono findComponentWithPricePointsByIdAndProductFamily( int componentId, String productFamilyId );
- SubscriptionMetadata readSubscriptionMetadata( String subscriptionId );
+ Flux findSubscriptionComponents( String subscriptionId );
- List updateSubscriptionMetadata( String subscriptionId, Metadata... metadata );
+ Flux findSubscriptionStatements(
+ String subscriptionId, int page, int pageSize, String sort, String direction );
- Component createComponent( String productFamilyId, Component component );
+ Flux findSubscriptionTransactions( String subscriptionId, SubscriptionTransactionsSearchOptions options );
- Allocation createComponentAllocation( String subscriptionId, String componentId, Allocation allocation );
+ Mono findSubscriptionComponentById( String subscriptionId, int componentId );
- List findComponentsByProductFamily( String productFamilyId );
+ Mono reportSubscriptionComponentUsage( String subscriptionId, int componentId, Usage usage );
- Component findComponentByIdAndProductFamily( String componentId, String productFamilyId );
+ Mono createCustomer( Customer customer );
- List findSubscriptionComponents( String subscriptionId );
+ Mono updateCustomer( Customer customer );
- SubscriptionComponent findSubscriptionComponentById( String subscriptionId, String componentId );
+ Mono findCustomerById( String id );
- Usage reportSubscriptionComponentUsage( String subscriptionId, String componentId, Usage usage );
+ Mono findCustomerByReference( String reference );
- Customer createCustomer( Customer customer );
+ Mono findSubscriptionByReference( String reference );
- Customer updateCustomer( Customer customer );
+ /**
+ * Search to retrieve a single or group of customers.
+ *
+ * @param criterion (string or integer) - can be email, Chargify ID, Reference (Your App), Organization
+ * @param pageNumber (start from 1) the page parameter via the query string to access subsequent pages of 50 transactions
+ * @return List of customers
+ */
+ Flux findCustomersBy( Object criterion, int pageNumber );
- Customer findCustomerById( String id );
+ /**
+ * The first page of results is displayed
+ * Default value for per_page is 50
+ * For page settings and how many records to fetch in each request (perPage), use
+ * {@link #findCustomers(int pageNumber, int perPage )}
+ */
+ Flux findAllCustomers();
- Customer findCustomerByReference( String reference );
+ Flux findCustomers( int pageNumber, int perPage );
- List findAllCustomers();
+ Mono deleteCustomerById( String id );
- void deleteCustomerById( String id );
+ Mono validateReferralCode( String code );
- ReferralCode validateReferralCode( String code );
+ Mono adjust( String subscriptionId, Adjustment adjustment );
}
diff --git a/src/main/java/com/chargify/ChargifyService.java b/src/main/java/com/chargify/ChargifyService.java
index db65199..d4f971c 100644
--- a/src/main/java/com/chargify/ChargifyService.java
+++ b/src/main/java/com/chargify/ChargifyService.java
@@ -2,538 +2,824 @@
import com.chargify.exceptions.ChargifyResponseErrorHandler;
import com.chargify.exceptions.ResourceNotFoundException;
-import com.chargify.model.Allocation;
-import com.chargify.model.Component;
-import com.chargify.model.ComponentPricePointUpdate;
-import com.chargify.model.Customer;
-import com.chargify.model.Metadata;
-import com.chargify.model.Migration;
-import com.chargify.model.Product;
-import com.chargify.model.ProductFamily;
-import com.chargify.model.ReferralCode;
-import com.chargify.model.RenewalPreview;
-import com.chargify.model.Subscription;
-import com.chargify.model.SubscriptionComponent;
-import com.chargify.model.SubscriptionMetadata;
-import com.chargify.model.Usage;
-import com.chargify.model.wrappers.AllocationWrapper;
-import com.chargify.model.wrappers.AnyComponentWrapper;
-import com.chargify.model.wrappers.ComponentPricePointUpdatesWrapper;
-import com.chargify.model.wrappers.ComponentWrapper;
-import com.chargify.model.wrappers.CustomerWrapper;
-import com.chargify.model.wrappers.MetadataWrapper;
-import com.chargify.model.wrappers.MeteredComponentWrapper;
-import com.chargify.model.wrappers.MigrationWrapper;
-import com.chargify.model.wrappers.OnOffComponentWrapper;
-import com.chargify.model.wrappers.ProductFamilyWrapper;
-import com.chargify.model.wrappers.ProductWrapper;
-import com.chargify.model.wrappers.QuantityBasedComponentWrapper;
-import com.chargify.model.wrappers.ReferralCodeWrapper;
-import com.chargify.model.wrappers.RenewalPreviewWrapper;
-import com.chargify.model.wrappers.SubscriptionComponentWrapper;
-import com.chargify.model.wrappers.SubscriptionWrapper;
-import com.chargify.model.wrappers.UsageWrapper;
+import com.chargify.model.*;
+import com.chargify.model.product.Product;
+import com.chargify.model.product.ProductFamily;
+import com.chargify.model.product.ProductPricePoint;
+import com.chargify.model.wrappers.*;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.boot.web.client.RootUriTemplateHandler;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.Arrays;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import io.netty.channel.ChannelOption;
+import org.springframework.http.MediaType;
+import org.springframework.http.client.reactive.ReactorClientHttpConnector;
+import org.springframework.http.codec.json.Jackson2JsonDecoder;
+import org.springframework.http.codec.json.Jackson2JsonEncoder;
+import org.springframework.web.reactive.function.client.ExchangeStrategies;
+import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.util.UriUtils;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Base64;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
public final class ChargifyService implements Chargify
{
- private final RestTemplate httpClient;
+ private final WebClient client;
- public ChargifyService( final String domain, final String apiKey )
+ private final ObjectMapper objectMapper;
+
+ public ChargifyService( final String domain, final String apiKey, int connectTimeoutInMillis,
+ int readTimeoutInMillis )
{
- this.httpClient = new RestTemplateBuilder()
- .uriTemplateHandler( new RootUriTemplateHandler( "https://" + domain + ".chargify.com" ) )
- .basicAuthorization( apiKey, "x" )
- .errorHandler( new ChargifyResponseErrorHandler() )
- .build();
+ String chargifyApiUrl = "https://" + domain + ".chargify.com";
+ String plainCreds = apiKey + ":x";
+ String base64Creds = Base64.getEncoder().encodeToString( plainCreds.getBytes() );
+ String basicAuthHeaderValue = "Basic " + base64Creds;
- this.httpClient.getMessageConverters().stream()
- .filter( AbstractJackson2HttpMessageConverter.class::isInstance )
- .map( AbstractJackson2HttpMessageConverter.class::cast )
- .map( AbstractJackson2HttpMessageConverter::getObjectMapper )
- .forEach( mapper -> mapper.disable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS ) );
+ this.objectMapper = new ObjectMapper();
+ this.objectMapper.disable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS );
+ this.objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
+ this.objectMapper.registerModules( new JavaTimeModule() );
+
+ final int size = 16 * 1024 * 1024;
+ final ExchangeStrategies strategies = ExchangeStrategies.builder()
+ .codecs( codecs -> codecs.defaultCodecs().maxInMemorySize( size ) )
+ .build();
+
+ this.client = WebClient.builder()
+ .baseUrl( chargifyApiUrl )
+ .exchangeStrategies( strategies )
+ .defaultHeader( "Authorization", basicAuthHeaderValue )
+ .clientConnector( new ReactorClientHttpConnector(
+ reactor.netty.http.client.HttpClient.create()
+ .followRedirect( true )
+ .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutInMillis )
+ .responseTimeout( Duration.ofMillis( readTimeoutInMillis ) )
+ ) )
+ .codecs( clientDefaultCodecsConfigurer -> {
+ clientDefaultCodecsConfigurer.defaultCodecs().jackson2JsonEncoder( new Jackson2JsonEncoder( objectMapper, MediaType.APPLICATION_JSON ) );
+ clientDefaultCodecsConfigurer.defaultCodecs().jackson2JsonDecoder( new Jackson2JsonDecoder( objectMapper, MediaType.APPLICATION_JSON ) );
+ } )
+ .build();
}
- public ChargifyService( final String domain, final String apiKey, int connectTimeoutInMillis,
- int readTimeoutInMillis )
+ @Override
+ public Mono createProductFamily( ProductFamily productFamily )
{
- this.httpClient = new RestTemplateBuilder()
- .uriTemplateHandler( new RootUriTemplateHandler( "https://" + domain + ".chargify.com" ) )
- .basicAuthorization( apiKey, "x" )
- .setConnectTimeout( connectTimeoutInMillis )
- .setReadTimeout( readTimeoutInMillis )
- .errorHandler( new ChargifyResponseErrorHandler() )
- .build();
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/product_families.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new ProductFamilyWrapper( productFamily ) ), ProductFamilyWrapper.class )
+ .retrieve() ).bodyToMono( ProductFamilyWrapper.class ).map( ProductFamilyWrapper::getProductFamily );
+ }
- this.httpClient.getMessageConverters().stream()
- .filter( AbstractJackson2HttpMessageConverter.class::isInstance )
- .map( AbstractJackson2HttpMessageConverter.class::cast )
- .map( AbstractJackson2HttpMessageConverter::getObjectMapper )
- .forEach( mapper -> mapper.disable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS ) );
+ @Override
+ public Mono findProductFamilyById( String id )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/product_families/" + id + ".json" ).retrieve() )
+ .bodyToMono( ProductFamilyWrapper.class ).map( ProductFamilyWrapper::getProductFamily )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public ProductFamily createProductFamily( ProductFamily productFamily )
+ public Flux findAllProductFamilies()
{
- return httpClient.postForObject( "/product_families.json",
- new ProductFamilyWrapper( productFamily ), ProductFamilyWrapper.class )
- .getProductFamily();
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/product_families.json" ).retrieve() )
+ .bodyToFlux( ProductFamilyWrapper.class ).map( ProductFamilyWrapper::getProductFamily );
}
@Override
- public ProductFamily findProductFamilyById( String id )
+ public Mono archiveProductFamilyById( String id )
{
- try
- {
- return httpClient.getForObject( "/product_families/" + id + ".json",
- ProductFamilyWrapper.class )
- .getProductFamily();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.delete().uri( "/product_families/" + id + ".json" ).retrieve() )
+ .bodyToMono( ProductFamilyWrapper.class ).map( ProductFamilyWrapper::getProductFamily )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public List findAllProductFamilies()
+ public Mono createProduct( String productFamilyId, Product product )
{
- return Arrays.stream( httpClient.getForObject( "/product_families.json", ProductFamilyWrapper[].class ) )
- .map( ProductFamilyWrapper::getProductFamily )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/product_families/" + productFamilyId + "/products.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new ProductWrapper( product ) ), ProductWrapper.class )
+ .retrieve() ).bodyToMono( ProductWrapper.class ).map( ProductWrapper::getProduct );
}
@Override
- public ProductFamily archiveProductFamilyById( String id )
+ public Mono findProductById( String id )
{
- try
- {
- return httpClient.exchange( "/product_families/" + id + ".json", HttpMethod.DELETE,
- HttpEntity.EMPTY, ProductFamilyWrapper.class )
- .getBody()
- .getProductFamily();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/products/" + id + ".json" ).retrieve() )
+ .bodyToMono( ProductWrapper.class ).map( ProductWrapper::getProduct )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Product createProduct( String productFamilyId, Product product )
+ public Mono findProductByApiHandle( String apiHandle )
{
- return httpClient.postForObject( "/product_families/" + productFamilyId + "/products.json",
- new ProductWrapper( product ), ProductWrapper.class )
- .getProduct();
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/products/handle/" + apiHandle + ".json" ).retrieve() )
+ .bodyToMono( ProductWrapper.class ).map( ProductWrapper::getProduct )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Product findProductById( String id )
+ public Flux findProductPricePointsByProductId( String productId )
{
- try
- {
- return httpClient.getForObject( "/products/" + id + ".json", ProductWrapper.class )
- .getProduct();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/products/" + productId + "/price_points.json" ).retrieve() )
+ .bodyToMono( ProductPricePointsWrapper.class ).map( ProductPricePointsWrapper::getPricePoints )
+ .flatMapMany( Flux::fromIterable )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Flux.empty() );
}
@Override
- public Product findProductByApiHandle( String apiHandle )
+ public Flux findComponentPricePoints( int componentId )
{
- try
- {
- return httpClient.getForObject( "/products/handle/" + apiHandle + ".json",
- ProductWrapper.class )
- .getProduct();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/components/" + componentId + "/price_points.json" ).retrieve() )
+ .bodyToMono( ComponentPricePointsWrapper.class )
+ .map( ComponentPricePointsWrapper::getPricePoints )
+ .flatMapMany( Flux::fromIterable );
}
@Override
- public List findAllProducts()
+ public Mono updatePricePoint( int componentId, int pricePointId, PricePointUpdate pricePointUpdate )
{
- return Arrays.stream( httpClient.getForObject( "/products.json", ProductWrapper[].class ) )
- .map( ProductWrapper::getProduct )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/components/" + componentId + "/price_points/" + pricePointId + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new PricePointUpdateWrapper( pricePointUpdate ) ), PricePointUpdateWrapper.class )
+ .retrieve() )
+ .bodyToMono( PricePointUpdateResultWrapper.class )
+ .map( PricePointUpdateResultWrapper::getPricePoint );
}
@Override
- public List findProductsByProductFamilyId( String productFamilyId )
+ public Flux findAllProducts()
{
- return Arrays.stream( httpClient.getForObject( "/product_families/" + productFamilyId + "/products.json",
- ProductWrapper[].class ) )
- .map( ProductWrapper::getProduct )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/products.json" ).retrieve() )
+ .bodyToFlux( ProductWrapper.class ).map( ProductWrapper::getProduct );
}
@Override
- public Product archiveProductById( String id )
+ public Flux findProductsByProductFamilyId( String productFamilyId )
{
- try
- {
- return httpClient.exchange( "/products/" + id + ".json", HttpMethod.DELETE,
- HttpEntity.EMPTY, ProductWrapper.class )
- .getBody()
- .getProduct();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/product_families/" + productFamilyId + "/products.json" ).retrieve() )
+ .bodyToFlux( ProductWrapper.class ).map( ProductWrapper::getProduct );
}
@Override
- public Subscription createSubscription( Subscription subscription )
+ public Mono archiveProductById( String id )
{
- return httpClient.postForObject( "/subscriptions.json",
- new SubscriptionWrapper( subscription ), SubscriptionWrapper.class )
- .getSubscription();
+ return ChargifyResponseErrorHandler.handleError(
+ client.delete().uri( "/products/" + id + ".json" ).retrieve() )
+ .bodyToMono( ProductWrapper.class ).map( ProductWrapper::getProduct )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Subscription findSubscriptionById( String id )
+ public Mono createSubscription( CreateSubscription subscription )
{
- try
- {
- return httpClient.getForObject( "/subscriptions/" + id + ".json", SubscriptionWrapper.class )
- .getSubscription();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new CreateSubscriptionWrapper( subscription ) ), SubscriptionWrapper.class )
+ .retrieve() ).bodyToMono( SubscriptionWrapper.class ).map( SubscriptionWrapper::getSubscription );
}
@Override
- public List findSubscriptionsByCustomerId( String customerId )
+ public Mono updateSubscription( String subscriptionId, UpdateSubscription subscription )
{
- return Arrays.stream( httpClient.getForObject( "/customers/" + customerId + "/subscriptions.json",
- SubscriptionWrapper[].class ) )
- .map( SubscriptionWrapper::getSubscription )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/subscriptions/" + subscriptionId + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new UpdateSubscriptionWrapper( subscription ) ), UpdateSubscriptionWrapper.class )
+ .retrieve() ).bodyToMono( Map.class ).then();
}
@Override
- public List findAllSubscriptions()
+ public Mono updateSubscriptionNextBillingDate( String subscriptionId, LocalDateTime nextBillingDate )
{
- return Arrays.stream( httpClient.getForObject( "/subscriptions.json", SubscriptionWrapper[].class ) )
- .map( SubscriptionWrapper::getSubscription )
- .collect( Collectors.toList() );
+ return updateSubscription(
+ subscriptionId,
+ UpdateSubscription.builder().nextBillingAt( ChargifyUtil.toChargifyDateString( nextBillingDate ) ).build()
+ );
}
@Override
- public List findSubscriptionsByState( String state, int pageNumber, int pageSize )
+ public Mono createSubscriptionCharge( String subscriptionId, SubscriptionCharge subscriptionCharge )
{
- return Arrays.stream( httpClient.getForObject( "/subscriptions.json?page=" + pageNumber + "&" +
- "per_page=" + pageSize + "&state=" + state,
- SubscriptionWrapper[].class ) )
- .map( SubscriptionWrapper::getSubscription )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/charges.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of( "charge", SubscriptionChargePayload.from( subscriptionCharge ) ) ), Map.class )
+ .retrieve() )
+ .bodyToMono( SubscriptionChargeWrapper.class )
+ .map( SubscriptionChargeWrapper::getSubscriptionChargeResult );
}
@Override
- public Subscription cancelSubscriptionById( String id )
+ public Mono findSubscriptionById( String id )
{
- try
- {
- return httpClient.exchange( "/subscriptions/" + id + ".json", HttpMethod.DELETE,
- HttpEntity.EMPTY, SubscriptionWrapper.class )
- .getBody()
- .getSubscription();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/" + id + ".json" ).retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
+ }
+
+ @Override
+ public Flux findPaymentProfilesForCustomer( String customerId )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/payment_profiles.json?customer_id=" + customerId ).retrieve() )
+ .bodyToFlux( PaymentProfileWrapper.class ).map( PaymentProfileWrapper::getPaymentProfile )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Flux.empty() );
+ }
+
+ @Override
+ public Mono createPaymentProfile( CreatePaymentProfile paymentProfile )
+ {
+ Map body = new HashMap<>();
+ body.put( "payment_profile", paymentProfile );
+
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/payment_profiles.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( body ), Map.class )
+ .retrieve() )
+ .bodyToMono( PaymentProfileWrapper.class )
+ .map( PaymentProfileWrapper::getPaymentProfile );
+ }
+
+ @Override
+ public Mono updatePaymentProfile( String paymentProfileId, UpdatePaymentProfile paymentProfile )
+ {
+ Map body = new HashMap<>();
+ body.put( "payment_profile", paymentProfile );
+
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/payment_profiles/" + paymentProfileId + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( body ), Map.class )
+ .retrieve() )
+ .bodyToMono( Map.class )
+ .then();
+ }
+
+ @Override
+ public Mono updateSubscriptionPaymentProfile( String subscriptionId, String paymentProfileId )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/payment_profiles/" + paymentProfileId + "/change_payment_profile.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of() ), Map.class )
+ .retrieve() )
+ .bodyToMono( PaymentProfileWrapper.class )
+ .map( PaymentProfileWrapper::getPaymentProfile );
+ }
+
+ @Override
+ public Mono findPaymentProfileById( String paymentProfileId )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/payment_profiles/" + paymentProfileId + ".json" ).retrieve() )
+ .bodyToMono( PaymentProfileWrapper.class ).map( PaymentProfileWrapper::getPaymentProfile )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
+ }
+
+ @Override
+ public Mono deleteUnusedPaymentProfile( String paymentProfileId )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.delete().uri( "/payment_profiles/" + paymentProfileId + ".json" ).retrieve() )
+ .bodyToMono( Map.class ).then();
+ }
+
+ @Override
+ public Mono deletePaymentProfile( String subscriptionId, String paymentProfileId )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.delete().uri( "/subscriptions/" + subscriptionId + "/payment_profiles/" + paymentProfileId + ".json" ).retrieve() )
+ .bodyToMono( Map.class ).then();
+ }
+
+ @Override
+ public Flux findSubscriptionsByCustomerId( String customerId )
+ {
+ return findSubscriptionsByCustomerId( customerId, 0, 200 );
+ }
+
+ @Override
+ public Flux findSubscriptionsByCustomerId( String customerId, int pageNumber, int pageSize )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/customers/" + customerId + "/subscriptions.json?page=" + pageNumber + "&" + "per_page=" + pageSize ).retrieve() )
+ .bodyToFlux( SubscriptionWrapper.class ).map( SubscriptionWrapper::getSubscription );
+ }
+
+ @Override
+ public Flux findAllSubscriptions()
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions.json" ).retrieve() )
+ .bodyToFlux( SubscriptionWrapper.class ).map( SubscriptionWrapper::getSubscription );
+ }
+
+ @Override
+ public Mono purgeSubscription( Subscription subscription )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscription.getId() + "/purge.json?ack=" + subscription.getCustomer().getId() +
+ "&cascade[]=customer&cascade[]=payment_profile" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of() ), Map.class )
+ .retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription );
+ }
+
+ @Override
+ public Flux findSubscriptionsByState( String state, int pageNumber, int pageSize )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions.json?page=" + pageNumber + "&" +
+ "per_page=" + pageSize + "&state=" + state ).retrieve() )
+ .bodyToFlux( SubscriptionWrapper.class ).map( SubscriptionWrapper::getSubscription );
+ }
+
+ @Override
+ public Mono cancelSubscriptionById( String id )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.delete().uri( "/subscriptions/" + id + ".json" ).retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Subscription cancelSubscriptionProductChange( String subscriptionId )
+ public Mono cancelSubscriptionProductChange( String subscriptionId )
{
final Subscription subscription = new Subscription();
subscription.setNextProductId( "" );
- return httpClient.exchange( "/subscriptions/" + subscriptionId + ".json", HttpMethod.PUT,
- new HttpEntity<>( new SubscriptionWrapper( subscription ) ), SubscriptionWrapper.class )
- .getBody()
- .getSubscription();
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/subscriptions/" + subscriptionId + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new SubscriptionWrapper( subscription ) ), SubscriptionWrapper.class )
+ .retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Subscription migrateSubscription( String subscriptionId, String productHandle )
+ public Mono migrateSubscription( String subscriptionId, Migration migration )
{
- final Migration migration = new Migration();
- migration.setProductHandle( productHandle );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/migrations.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new MigrationWrapper( migration ) ), MigrationWrapper.class )
+ .retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
+ }
- return httpClient.postForObject( "/subscriptions/" + subscriptionId + "/migrations.json",
- new MigrationWrapper( migration ), SubscriptionWrapper.class )
- .getSubscription();
+ @Override
+ public Mono reactivateSubscription( String subscriptionId, boolean preserveBalance )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/subscriptions/" + subscriptionId + "/reactivate.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of( "preserve_balance", preserveBalance ) ), Map.class )
+ .retrieve() ).bodyToMono( SubscriptionWrapper.class ).map( SubscriptionWrapper::getSubscription );
}
@Override
- public Subscription reactivateSubscription( String subscriptionId )
+ public Mono reactivateSubscription( String subscriptionId,
+ SubscriptionReactivationData reactivationData )
{
- return httpClient.exchange( "/subscriptions/" + subscriptionId + "/reactivate.json", HttpMethod.PUT,
- HttpEntity.EMPTY, SubscriptionWrapper.class )
- .getBody()
- .getSubscription();
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( prepareSubscriptionReactivationURI( subscriptionId, reactivationData ) )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of() ), Map.class )
+ .retrieve() ).bodyToMono( SubscriptionWrapper.class ).map( SubscriptionWrapper::getSubscription );
}
@Override
- public ComponentPricePointUpdate migrateSubscriptionComponentToPricePoint( String subscriptionId, int componentId,
- String pricePointHandle )
+ public Mono migrateSubscriptionComponentToPricePoint( String subscriptionId,
+ int componentId,
+ String pricePointHandle )
{
- return httpClient.postForObject( "/subscriptions/" + subscriptionId + "/price_points.json",
- new ComponentPricePointUpdatesWrapper(
- new ComponentPricePointUpdate( componentId, pricePointHandle ) ),
- ComponentPricePointUpdatesWrapper.class )
- .getPricePointUpdates()[ 0 ];
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/price_points.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new ComponentPricePointUpdatesWrapper(
+ List.of( new ComponentPricePointUpdate( componentId, pricePointHandle ) ) ) ), ComponentPricePointUpdatesWrapper.class )
+ .retrieve() )
+ .bodyToMono( ComponentPricePointUpdatesWrapper.class )
+ .map( wrapper -> wrapper.getPricePointUpdates().get( 0 ) );
}
@Override
- public Subscription changeSubscriptionProduct( String subscriptionId, String productHandle, boolean delayed )
+ public Flux bulkUpdateSubscriptionComponentPricePoint( String subscriptionId,
+ List items )
{
- final Subscription subscription = new Subscription();
- subscription.setProductHandle( productHandle );
- subscription.setProductChangeDelayed( delayed );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/price_points.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new ComponentPricePointUpdatesWrapper( items ) ), ComponentPricePointUpdatesWrapper.class )
+ .retrieve() )
+ .bodyToMono( ComponentPricePointUpdatesWrapper.class )
+ .map( ComponentPricePointUpdatesWrapper::getPricePointUpdates )
+ .flatMapMany( Flux::fromIterable );
+ }
- return httpClient.exchange( "/subscriptions/" + subscriptionId + ".json", HttpMethod.PUT,
- new HttpEntity<>( new SubscriptionWrapper( subscription ) ), SubscriptionWrapper.class )
- .getBody()
- .getSubscription();
+ @Override
+ public Mono cancelScheduledSubscriptionProductChange( String subscriptionId )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/subscriptions/" + subscriptionId + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of(
+ "subscription",
+ Map.of(
+ "next_product_id", "",
+ "next_product_price_point_id", ""
+ )
+ ) ), Map.class )
+ .retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription );
}
@Override
- public RenewalPreview previewSubscriptionRenewal( String subscriptionId )
+ public Mono changeSubscriptionProduct( String subscriptionId, SubscriptionProductUpdate payload )
{
- return httpClient.postForObject( "/subscriptions/" + subscriptionId + "/renewals/preview.json",
- HttpEntity.EMPTY, RenewalPreviewWrapper.class )
- .getRenewalPreview();
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/subscriptions/" + subscriptionId + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new SubscriptionProductUpdateWrapper( payload ) ), SubscriptionProductUpdateWrapper.class )
+ .retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription );
}
@Override
- public List createSubscriptionMetadata( String subscriptionId, Metadata... metadata )
+ public Mono previewSubscriptionRenewal( String subscriptionId )
{
- return Arrays.asList( httpClient.postForObject( "/subscriptions/" + subscriptionId + "/metadata.json",
- new MetadataWrapper( metadata ), Metadata[].class ) );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/renewals/preview.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of() ), Map.class )
+ .retrieve() )
+ .bodyToMono( RenewalPreviewWrapper.class )
+ .map( RenewalPreviewWrapper::getRenewalPreview );
}
@Override
- public SubscriptionMetadata readSubscriptionMetadata( String subscriptionId )
+ public Flux createSubscriptionMetadata( String subscriptionId, Metadata... metadata )
{
- try
- {
- return httpClient.getForObject( "/subscriptions/" + subscriptionId + "/metadata.json",
- SubscriptionMetadata.class );
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/metadata.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new MetadataWrapper( metadata ) ), MetadataWrapper.class )
+ .retrieve() )
+ .bodyToFlux( Metadata.class );
}
@Override
- public List updateSubscriptionMetadata( String subscriptionId, Metadata... metadata )
+ public Mono readSubscriptionMetadata( String subscriptionId )
{
- return Arrays.asList( httpClient.exchange( "/subscriptions/" + subscriptionId + "/metadata.json",
- HttpMethod.PUT,
- new HttpEntity<>( new MetadataWrapper( metadata ) ), Metadata[].class )
- .getBody() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/" + subscriptionId + "/metadata.json" ).retrieve() )
+ .bodyToMono( SubscriptionMetadata.class )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Component createComponent( String productFamilyId, Component component )
+ public Flux updateSubscriptionMetadata( String subscriptionId, Metadata... metadata )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/subscriptions/" + subscriptionId + "/metadata.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new MetadataWrapper( metadata ) ), MetadataWrapper.class )
+ .retrieve() )
+ .bodyToFlux( Metadata.class );
+ }
+
+ @Override
+ public Mono createComponent( String productFamilyId, Component component )
{
if( component.getKind() == null )
throw new IllegalArgumentException( "Component Kind must not be null" );
final String pluralKindPathParam;
- final ComponentWrapper componentWrapper;
- switch( component.getKind() )
+ final ComponentWrapper componentWrapper = switch( component.getKind() )
{
- case quantity_based_component:
+ case quantity_based_component -> {
pluralKindPathParam = "quantity_based_components";
- componentWrapper = new QuantityBasedComponentWrapper( component );
- break;
- case metered_component:
+ yield new QuantityBasedComponentWrapper( component );
+ }
+ case metered_component -> {
pluralKindPathParam = "metered_components";
- componentWrapper = new MeteredComponentWrapper( component );
- break;
- case on_off_component:
+ yield new MeteredComponentWrapper( component );
+ }
+ case on_off_component -> {
pluralKindPathParam = "on_off_components";
- componentWrapper = new OnOffComponentWrapper( component );
- break;
- default:
- throw new IllegalArgumentException( "Invalid component kind - " + component.getKind() );
- }
+ yield new OnOffComponentWrapper( component );
+ }
+ default -> throw new IllegalArgumentException( "Invalid component kind - " + component.getKind() );
+ };
- return httpClient.postForObject( "/product_families/" + productFamilyId + "/" + pluralKindPathParam + ".json",
- componentWrapper, AnyComponentWrapper.class )
- .getComponent();
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/product_families/" + productFamilyId + "/" + pluralKindPathParam + ".json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( componentWrapper ), Object.class )
+ .retrieve() )
+ .bodyToMono( AnyComponentWrapper.class )
+ .map( AnyComponentWrapper::getComponent );
}
@Override
- public Allocation createComponentAllocation( String subscriptionId, String componentId, Allocation allocation )
+ public Mono createComponentAllocation( String subscriptionId, int componentId, Allocation allocation )
{
- return httpClient.postForObject( "/subscriptions/" + subscriptionId + "/components/" + componentId +
- "/allocations.json",
- new AllocationWrapper( allocation ), AllocationWrapper.class )
- .getAllocation();
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/components/" + componentId +
+ "/allocations.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( new AllocationWrapper( allocation ) ), AllocationWrapper.class )
+ .retrieve() ).
+ bodyToMono( AllocationWrapper.class )
+ .map( AllocationWrapper::getAllocation );
}
@Override
- public List findComponentsByProductFamily( String productFamilyId )
+ public Mono previewComponentAllocation( String subscriptionId, int componentId, int quantity )
{
- return Arrays.stream( httpClient.getForObject( "/product_families/" + productFamilyId + "/components.json",
- AnyComponentWrapper[].class ) )
- .map( AnyComponentWrapper::getComponent )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/allocations/preview.json" )
+ .contentType( MediaType.APPLICATION_JSON )
+ .body( Mono.just( Map.of( "allocations", List.of( new AllocationPreview.ComponentAllocationDTO( componentId, quantity ) ) ) ), Map.class )
+ .retrieve() )
+ .bodyToMono( AllocationPreviewWrapper.class )
+ .map( AllocationPreviewWrapper::getAllocationPreview );
}
@Override
- public Component findComponentByIdAndProductFamily( String componentId, String productFamilyId )
+ public Flux findComponentsByProductFamily( String productFamilyId )
{
- try
- {
- return httpClient.getForObject( "/product_families/" + productFamilyId +
- "/components/" + componentId + ".json",
- AnyComponentWrapper.class )
- .getComponent();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/product_families/" + productFamilyId + "/components.json" ).retrieve() )
+ .bodyToFlux( AnyComponentWrapper.class )
+ .map( AnyComponentWrapper::getComponent );
}
@Override
- public List findSubscriptionComponents( String subscriptionId )
+ public Mono findComponentByIdAndProductFamily( int componentId, String productFamilyId )
{
- return Arrays.stream( httpClient.getForObject( "/subscriptions/" + subscriptionId + "/components.json",
- SubscriptionComponentWrapper[].class ) )
- .map( SubscriptionComponentWrapper::getComponent )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/product_families/" + productFamilyId + "/components/" + componentId + ".json" ).retrieve() )
+ .bodyToMono( AnyComponentWrapper.class )
+ .map( AnyComponentWrapper::getComponent );
}
@Override
- public SubscriptionComponent findSubscriptionComponentById( String subscriptionId, String componentId )
+ public Mono findComponentWithPricePointsByIdAndProductFamily( int componentId,
+ String productFamilyId )
{
- try
- {
- return httpClient.getForObject( "/subscriptions/" + subscriptionId +
- "/components/" + componentId + ".json",
- SubscriptionComponentWrapper.class )
- .getComponent();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return findComponentByIdAndProductFamily( componentId, productFamilyId )
+ .flatMap( component -> findComponentPricePoints( componentId )
+ .collect( Collectors.toSet() )
+ .map( componentPricePoints -> new ComponentWithPricePoints( component, componentPricePoints ) ) );
}
@Override
- public Usage reportSubscriptionComponentUsage( String subscriptionId, String componentId, Usage usage )
+ public Flux findSubscriptionComponents( String subscriptionId )
{
- return httpClient.postForObject( "/subscriptions/" + subscriptionId + "/components/" + componentId +
- "/usages.json",
- new UsageWrapper( usage ), UsageWrapper.class )
- .getUsage();
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/" + subscriptionId + "/components.json" ).retrieve() )
+ .bodyToFlux( SubscriptionComponentWrapper.class )
+ .map( SubscriptionComponentWrapper::getComponent );
}
@Override
- public Customer createCustomer( Customer customer )
+ public Flux findSubscriptionStatements(
+ String subscriptionId, int page, int pageSize, String sort, String direction )
{
- return httpClient.postForObject( "/customers.json", new CustomerWrapper( customer ), CustomerWrapper.class )
- .getCustomer();
+ if( pageSize > 200 )
+ throw new IllegalArgumentException( "Page size can't be bigger than 200" );
+
+ StringBuilder uriBuilder = new StringBuilder();
+ uriBuilder.append( "page=" ).append( page );
+ uriBuilder.append( "&per_page=" ).append( pageSize );
+ if( sort != null )
+ uriBuilder.append( "&sort=" ).append( sort );
+ if( direction != null )
+ uriBuilder.append( "&direction=" ).append( direction );
+
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/" + subscriptionId + "/statements.json?" + uriBuilder ).retrieve() )
+ .bodyToFlux( SubscriptionStatementWrapper.class )
+ .map( SubscriptionStatementWrapper::getStatement );
}
@Override
- public Customer updateCustomer( Customer customer )
+ public Flux findSubscriptionTransactions( String subscriptionId, SubscriptionTransactionsSearchOptions options )
{
- return httpClient.exchange( "/customers/" + customer.getId() + ".json", HttpMethod.PUT,
- new HttpEntity<>( new CustomerWrapper( customer ) ), CustomerWrapper.class )
- .getBody()
- .getCustomer();
+ if( options.getPageSize() > 200 )
+ throw new IllegalArgumentException( "Page size can't be bigger than 200" );
+
+ StringBuilder uriBuilder = new StringBuilder();
+ uriBuilder.append( "page=" ).append( options.getPage() );
+ uriBuilder.append( "&per_page=" ).append( options.getPageSize() );
+ uriBuilder.append( "&direction=" ).append( options.getDirection().getValue() );
+ if( options.getMaxId() != null )
+ uriBuilder.append( "&max_id=" ).append( options.getMaxId() );
+ if( options.getSinceId() != null )
+ uriBuilder.append( "&since_id=" ).append( options.getSinceId() );
+ if( options.getKinds() != null )
+ options.getKinds().forEach( kind -> uriBuilder.append( "&kinds[]=" ).append( kind ) );
+
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern( "yyyy-MM-dd");
+ if( options.getSinceDate() != null )
+ uriBuilder.append( "&since_date=" ).append( options.getSinceDate().format( dateFormatter ) );
+ if( options.getUntilDate() != null )
+ uriBuilder.append( "&until_date=" ).append( options.getUntilDate().format( dateFormatter ) );
+
+
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/" + subscriptionId + "/transactions.json?" + uriBuilder ).retrieve() )
+ .bodyToFlux( TransactionWrapper.class )
+ .map( TransactionWrapper::getTransaction );
}
@Override
- public Customer findCustomerById( String id )
+ public Mono findSubscriptionComponentById( String subscriptionId, int componentId )
{
- try
- {
- return httpClient.getForObject( "/customers/" + id + ".json", CustomerWrapper.class )
- .getCustomer();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/" + subscriptionId + "/components/" + componentId + ".json" ).retrieve() )
+ .bodyToMono( SubscriptionComponentWrapper.class )
+ .map( SubscriptionComponentWrapper::getComponent )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public Customer findCustomerByReference( String reference )
+ public Mono reportSubscriptionComponentUsage( String subscriptionId, int componentId, Usage usage )
{
- try
- {
- return httpClient.getForObject( "/customers/lookup.json?reference={reference}",
- CustomerWrapper.class, reference )
- .getCustomer();
- }
- catch( ResourceNotFoundException e )
- {
- return null;
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/components/" + componentId + "/usages.json" )
+ .body( Mono.just( new UsageWrapper( usage ) ), UsageWrapper.class ).retrieve() )
+ .bodyToMono( UsageWrapper.class )
+ .map( UsageWrapper::getUsage );
}
@Override
- public List findAllCustomers()
+ public Mono createCustomer( Customer customer )
{
- return Arrays.stream( httpClient.getForObject( "/customers.json", CustomerWrapper[].class ) )
- .map( CustomerWrapper::getCustomer )
- .collect( Collectors.toList() );
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/customers.json" )
+ .body( Mono.just( new CustomerWrapper( customer ) ), CustomerWrapper.class ).retrieve() )
+ .bodyToMono( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer );
}
@Override
- public void deleteCustomerById( String id )
+ public Mono updateCustomer( Customer customer )
{
- try
- {
- httpClient.delete( "/customers/" + id + ".json" );
- }
- catch( ResourceNotFoundException ignored )
- {
- }
+ return ChargifyResponseErrorHandler.handleError(
+ client.put().uri( "/customers/" + customer.getId() + ".json" )
+ .body( Mono.just( new CustomerWrapper( customer ) ), CustomerWrapper.class ).retrieve() )
+ .bodyToMono( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer );
+ }
+
+ @Override
+ public Mono findCustomerById( String id )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/customers/" + id + ".json" ).retrieve() )
+ .bodyToMono( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
+ }
+
+ @Override
+ public Mono findCustomerByReference( String reference )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/customers/lookup.json?reference={reference}", reference ).retrieve() )
+ .bodyToMono( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
+ }
+
+ @Override
+ public Mono findSubscriptionByReference( String reference )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/subscriptions/lookup.json?reference={reference}", reference ).retrieve() )
+ .bodyToMono( SubscriptionWrapper.class )
+ .map( SubscriptionWrapper::getSubscription )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
}
@Override
- public ReferralCode validateReferralCode( String code )
+ public Flux findCustomersBy( Object criterion, int pageNumber )
{
- try
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/customers.json?q={criterion}&page={pageNumber}", criterion, pageNumber ).retrieve() )
+ .bodyToFlux( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer );
+ }
+
+ @Override
+ public Flux findAllCustomers()
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/customers.json" ).retrieve() )
+ .bodyToFlux( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer );
+ }
+
+ @Override
+ public Flux findCustomers( int pageNumber, int perPage )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/customers.json?page={pageNumber}&per_page={perPage}", pageNumber, perPage ).retrieve() )
+ .bodyToFlux( CustomerWrapper.class )
+ .map( CustomerWrapper::getCustomer );
+ }
+
+ @Override
+ public Mono deleteCustomerById( String id )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.delete().uri( "/customers/" + id + ".json" ).retrieve() )
+ .bodyToMono( Map.class )
+ .then()
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.just( "stub" ).then() );
+ }
+
+ @Override
+ public Mono validateReferralCode( String code )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.get().uri( "/referral_codes/validate.json?code=" + code ).retrieve() )
+ .bodyToMono( ReferralCodeWrapper.class )
+ .map( ReferralCodeWrapper::getReferralCode )
+ .onErrorResume( ResourceNotFoundException.class, ex -> Mono.empty() );
+ }
+
+ @Override
+ public Mono adjust( String subscriptionId, Adjustment adjustment )
+ {
+ return ChargifyResponseErrorHandler.handleError(
+ client.post().uri( "/subscriptions/" + subscriptionId + "/adjustments.json" )
+ .body( Mono.just( new AdjustmentWrapper( adjustment ) ), AdjustmentWrapper.class ).retrieve() )
+ .bodyToMono( AdjustmentWrapper.class )
+ .map( AdjustmentWrapper::getAdjustment );
+ }
+
+ private String prepareSubscriptionReactivationURI( String subscriptionId,
+ SubscriptionReactivationData reactivationData )
+ {
+ StringBuilder urlBuilder = new StringBuilder( "/subscriptions/" ).append( subscriptionId ).append( "/reactivate.json" );
+
+ urlBuilder.append( "?include_trial=" ).append( reactivationData.isIncludeTrial() ? "1" : "0" );
+ urlBuilder.append( "&preserve_balance=" ).append( reactivationData.isPreserveBalance() ? "1" : "0" );
+ if( reactivationData.getCouponCode() != null )
{
- return httpClient.getForObject( "/referral_codes/validate.json?code=" + code,
- ReferralCodeWrapper.class )
- .getReferralCode();
+ urlBuilder.append( "&coupon_code=" ).append( UriUtils.encode( reactivationData.getCouponCode(), StandardCharsets.UTF_8 ) );
}
- catch( ResourceNotFoundException e )
+ if( reactivationData.getResume() != null )
{
- return null;
+ urlBuilder.append( "&resume=" ).append( reactivationData.getResume() ? "true" : "false" );
}
+ if( reactivationData.isForgiveBalance() )
+ {
+ urlBuilder.append( "&resume%5Bforgive_balance%5D=" ).append( reactivationData.isForgiveBalance() ? "true" : "false" );
+ }
+
+ return urlBuilder.toString();
}
}
diff --git a/src/main/java/com/chargify/ChargifyUtil.java b/src/main/java/com/chargify/ChargifyUtil.java
new file mode 100644
index 0000000..c8e12f4
--- /dev/null
+++ b/src/main/java/com/chargify/ChargifyUtil.java
@@ -0,0 +1,26 @@
+package com.chargify;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class ChargifyUtil
+{
+ private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern( "yyyy-MM-dd'T'HH:mm:ss'Z'" );
+
+ public static String toChargifyDateString( LocalDateTime date )
+ {
+ return date.atZone( ZoneId.systemDefault() )
+ .withZoneSameInstant( ZoneId.of( "UTC" ) )
+ .toLocalDateTime()
+ .format( DATE_FORMATTER );
+ }
+ public static String toChargifyDateString( ZonedDateTime date )
+ {
+ return date
+ .withZoneSameInstant( ZoneId.of( "UTC" ) )
+ .toLocalDateTime()
+ .format( DATE_FORMATTER );
+ }
+}
diff --git a/src/main/java/com/chargify/SortDirection.java b/src/main/java/com/chargify/SortDirection.java
new file mode 100644
index 0000000..fdc1793
--- /dev/null
+++ b/src/main/java/com/chargify/SortDirection.java
@@ -0,0 +1,13 @@
+package com.chargify;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum SortDirection
+{
+ ASC( "asc" ), DESC( "desc" );
+
+ private final String value;
+}
diff --git a/src/main/java/com/chargify/SubscriptionTransactionsSearchOptions.java b/src/main/java/com/chargify/SubscriptionTransactionsSearchOptions.java
new file mode 100644
index 0000000..c2be27a
--- /dev/null
+++ b/src/main/java/com/chargify/SubscriptionTransactionsSearchOptions.java
@@ -0,0 +1,38 @@
+package com.chargify;
+
+import lombok.Builder;
+import lombok.Getter;
+
+import java.time.LocalDate;
+import java.util.List;
+
+@Getter
+@Builder
+public class SubscriptionTransactionsSearchOptions
+{
+ @Builder.Default
+ private SortDirection direction = SortDirection.DESC;
+ private List kinds;
+ private Integer maxId;
+ @Builder.Default
+ private int page = 1;
+ @Builder.Default
+ private int pageSize = 20;
+ private LocalDate sinceDate;
+ private Integer sinceId;
+ private LocalDate untilDate;
+
+ public SubscriptionTransactionsSearchOptions nextPage()
+ {
+ page++;
+ return this;
+ }
+
+ public SubscriptionTransactionsSearchOptions previousPage()
+ {
+ if( (page - 1) < 1 )
+ throw new IllegalStateException( "Page can't be less than 1" );
+ page--;
+ return this;
+ }
+}
diff --git a/src/main/java/com/chargify/exceptions/ChargifyError.java b/src/main/java/com/chargify/exceptions/ChargifyError.java
index fb75b7a..85dbd74 100644
--- a/src/main/java/com/chargify/exceptions/ChargifyError.java
+++ b/src/main/java/com/chargify/exceptions/ChargifyError.java
@@ -1,5 +1,6 @@
package com.chargify.exceptions;
+import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -14,21 +15,21 @@ public final class ChargifyError
private final Object errors;
@JsonCreator
- public ChargifyError( @JsonProperty( "errors" ) Object errors )
+ public ChargifyError( @JsonProperty( "errors" ) @JsonAlias( "error" ) Object errors )
{
this.errors = errors;
}
ChargifyException exception()
{
- if( errors instanceof Collection )
+ if( errors instanceof Collection> errorsAsStrings )
{
- return ChargifyException.fromErrors( (Collection) errors );
+ return ChargifyException.fromErrors( errorsAsStrings );
}
- else if( errors instanceof Map )
+ else if( errors instanceof Map, ?> errorsAsMap )
{
List errorsList = new ArrayList<>();
- ((Map) errors).forEach( ( key, value ) -> errorsList.add( key + ": " + value ) );
+ errorsAsMap.forEach( ( key, value ) -> errorsList.add( key + ": " + value ) );
return ChargifyException.fromErrors( errorsList );
}
else
diff --git a/src/main/java/com/chargify/exceptions/ChargifyException.java b/src/main/java/com/chargify/exceptions/ChargifyException.java
index 86359d1..b8e02a6 100644
--- a/src/main/java/com/chargify/exceptions/ChargifyException.java
+++ b/src/main/java/com/chargify/exceptions/ChargifyException.java
@@ -9,12 +9,12 @@ public class ChargifyException extends RuntimeException
super( errorMessage );
}
- private ChargifyException( Collection errorMessages )
+ private ChargifyException( Collection> errorMessages )
{
super( String.join( " && ", errorMessages.toString() ) );
}
- static ChargifyException fromErrors( Collection errorMessages )
+ static ChargifyException fromErrors( Collection> errorMessages )
{
if( errorMessages.size() == 1 )
{
@@ -28,14 +28,12 @@ static ChargifyException fromErrors( Collection errorMessages )
private static ChargifyException fromError( String errorMessage )
{
- switch( errorMessage )
+ return switch( errorMessage )
{
- case MissingNameException.MESSAGE:
- return new MissingNameException();
- case ApiHandleNotUniqueException.MESSAGE:
- return new ApiHandleNotUniqueException();
- default:
- return new ChargifyException( errorMessage );
- }
+ case PaymentProfileInUseException.MESSAGE -> new PaymentProfileInUseException();
+ case MissingNameException.MESSAGE -> new MissingNameException();
+ case ApiHandleNotUniqueException.MESSAGE -> new ApiHandleNotUniqueException();
+ default -> new ChargifyException( errorMessage );
+ };
}
}
diff --git a/src/main/java/com/chargify/exceptions/ChargifyResponseErrorHandler.java b/src/main/java/com/chargify/exceptions/ChargifyResponseErrorHandler.java
index 39ff2ef..2d4a717 100644
--- a/src/main/java/com/chargify/exceptions/ChargifyResponseErrorHandler.java
+++ b/src/main/java/com/chargify/exceptions/ChargifyResponseErrorHandler.java
@@ -1,38 +1,119 @@
package com.chargify.exceptions;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.http.HttpStatus;
+import org.springframework.http.HttpStatusCode;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
-import org.springframework.web.client.HttpServerErrorException;
-import org.springframework.web.client.UnknownHttpStatusCodeException;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
import java.io.IOException;
import java.io.InputStream;
public final class ChargifyResponseErrorHandler extends DefaultResponseErrorHandler
{
- private ObjectMapper objectMapper = new ObjectMapper();
+ private static final ObjectMapper objectMapper = new ObjectMapper();
+
+ static {
+ objectMapper.disable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS );
+ objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.registerModules( new JavaTimeModule() );
+ }
+
+ public static void handleError( int statusCode, String strBody )
+ {
+ if( statusCode >= 200 && statusCode < 300 )
+ return;
+
+ if( statusCode >= 400 && statusCode < 500 )
+ {
+ if( statusCode == HttpStatus.NOT_FOUND.value() )
+ throw new ResourceNotFoundException();
+ else if( statusCode == HttpStatus.FORBIDDEN.value() ) // TODO: see issue https://chargify.zendesk.com/hc/en-us/requests/69553
+ throw new ChargifyException( strBody );
+ else
+ {
+ try
+ {
+ throw objectMapper.readValue( strBody, ChargifyError.class ).exception();
+ }
+ catch( JsonProcessingException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+ }
+ else if( statusCode >= 500 && statusCode < 600 )
+ {
+ throw new HttpServerErrorException( statusCode, strBody );
+ }
+ else
+ {
+ throw new UnknownHttpStatusCodeException( statusCode, strBody );
+ }
+ }
+
+ public static WebClient.ResponseSpec handleError( WebClient.ResponseSpec response )
+ {
+ response.onStatus( HttpStatusCode::is4xxClientError, clientResponse -> {
+ HttpStatusCode statusCode = clientResponse.statusCode();
+ if( statusCode == HttpStatus.NOT_FOUND )
+ return Mono.error( new ResourceNotFoundException() );
+ else if( statusCode == HttpStatus.FORBIDDEN ) // TODO: see issue https://chargify.zendesk.com/hc/en-us/requests/69553
+ return clientResponse.bodyToMono( String.class ).map( ChargifyException::new ).flatMap( Mono::error );
+ else
+ {
+ return clientResponse.bodyToMono( String.class )
+ .handle( ( body, sink ) -> {
+ try
+ {
+ sink.next( objectMapper.readValue( body, ChargifyError.class ).exception() );
+ }
+ catch( JsonProcessingException e )
+ {
+ sink.error( new RuntimeException( e ) );
+ }
+ } )
+ .flatMap( Mono::error );
+ }
+ } );
+
+ response.onStatus(
+ HttpStatusCode::is5xxServerError,
+ clientResponse -> clientResponse.bodyToMono( String.class )
+ .map( message -> new HttpServerErrorException( clientResponse.statusCode().value(), message ) )
+ .flatMap( Mono::error ) );
+
+ response.onStatus(
+ HttpStatusCode::isError,
+ clientResponse -> response.bodyToMono( String.class )
+ .map( message -> new UnknownHttpStatusCodeException( clientResponse.statusCode().value(), message ) )
+ .flatMap( Mono::error ) );
+
+ return response;
+ }
@Override
- protected void handleError( ClientHttpResponse response, HttpStatus statusCode ) throws IOException
+ protected void handleError( ClientHttpResponse response, HttpStatusCode statusCode ) throws IOException
{
- switch( statusCode.series() )
+ if( statusCode.is4xxClientError() )
{
- case CLIENT_ERROR:
- if( statusCode == HttpStatus.NOT_FOUND )
- throw new ResourceNotFoundException();
- else if( statusCode == HttpStatus.FORBIDDEN ) // TODO: see issue https://chargify.zendesk.com/hc/en-us/requests/69553
- throw new ChargifyException( readInputStream( response.getBody() ) );
- else
- throw objectMapper.readValue( response.getBody(), ChargifyError.class ).exception();
- case SERVER_ERROR:
- throw new HttpServerErrorException( statusCode, response.getStatusText(),
- response.getHeaders(), getResponseBody( response ), getCharset( response ) );
- default:
- throw new UnknownHttpStatusCodeException( statusCode.value(), response.getStatusText(),
- response.getHeaders(), getResponseBody( response ), getCharset( response ) );
+ if( statusCode == HttpStatus.NOT_FOUND )
+ throw new ResourceNotFoundException();
+ else if( statusCode == HttpStatus.FORBIDDEN ) // TODO: see issue https://chargify.zendesk.com/hc/en-us/requests/69553
+ throw new ChargifyException( readInputStream( response.getBody() ) );
+ else
+ throw objectMapper.readValue( response.getBody(), ChargifyError.class ).exception();
}
+ else if( statusCode.is5xxServerError() )
+ throw new HttpServerErrorException( statusCode.value(), readInputStream( response.getBody() ) );
+ else
+ throw new UnknownHttpStatusCodeException( statusCode.value(), readInputStream( response.getBody() ) );
}
private String readInputStream( final InputStream stream )
diff --git a/src/main/java/com/chargify/exceptions/HttpServerErrorException.java b/src/main/java/com/chargify/exceptions/HttpServerErrorException.java
new file mode 100644
index 0000000..fbba436
--- /dev/null
+++ b/src/main/java/com/chargify/exceptions/HttpServerErrorException.java
@@ -0,0 +1,18 @@
+package com.chargify.exceptions;
+
+import lombok.Getter;
+import org.springframework.http.HttpStatus;
+
+@Getter
+public class HttpServerErrorException extends RuntimeException
+{
+ private final int statusCode;
+ private final String responseBody;
+
+ public HttpServerErrorException( int statusCode, String responseBody )
+ {
+ super( HttpStatus.resolve( statusCode ).getReasonPhrase() + ". Body: " + responseBody );
+ this.statusCode = statusCode;
+ this.responseBody = responseBody;
+ }
+}
diff --git a/src/main/java/com/chargify/exceptions/PaymentProfileInUseException.java b/src/main/java/com/chargify/exceptions/PaymentProfileInUseException.java
new file mode 100644
index 0000000..52b4f1e
--- /dev/null
+++ b/src/main/java/com/chargify/exceptions/PaymentProfileInUseException.java
@@ -0,0 +1,11 @@
+package com.chargify.exceptions;
+
+public final class PaymentProfileInUseException extends ChargifyException
+{
+ static final String MESSAGE = "The payment profile is in use by one or more subscriptions and cannot be deleted";
+
+ PaymentProfileInUseException()
+ {
+ super( MESSAGE );
+ }
+}
diff --git a/src/main/java/com/chargify/exceptions/UnknownHttpStatusCodeException.java b/src/main/java/com/chargify/exceptions/UnknownHttpStatusCodeException.java
new file mode 100644
index 0000000..a0f5d05
--- /dev/null
+++ b/src/main/java/com/chargify/exceptions/UnknownHttpStatusCodeException.java
@@ -0,0 +1,17 @@
+package com.chargify.exceptions;
+
+import lombok.Getter;
+
+@Getter
+public class UnknownHttpStatusCodeException extends RuntimeException
+{
+ private final int statusCode;
+ private final String responseBody;
+
+ public UnknownHttpStatusCodeException( int statusCode, String responseBody )
+ {
+ super( "Unknown status code [" + statusCode + "] Body: " + responseBody );
+ this.statusCode = statusCode;
+ this.responseBody = responseBody;
+ }
+}
diff --git a/src/main/java/com/chargify/model/Adjustment.java b/src/main/java/com/chargify/model/Adjustment.java
index d217789..85b04cb 100644
--- a/src/main/java/com/chargify/model/Adjustment.java
+++ b/src/main/java/com/chargify/model/Adjustment.java
@@ -3,11 +3,19 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
-import java.util.Date;
+import java.time.ZonedDateTime;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
+@EqualsAndHashCode
+@ToString
public class Adjustment
{
private String id;
@@ -15,155 +23,24 @@ public class Adjustment
private String memo;
@JsonProperty( "amount_in_cents" )
- private Integer amount_in_cents;
+ private Long amountInCents;
@JsonProperty( "ending_balance_in_cents" )
- private Integer ending_balance_in_cents;
+ private Long endingBalanceInCents;
private String type;
@JsonProperty( "transaction_type" )
- private String transaction_type;
+ private String transactionType;
@JsonProperty( "subscription_id" )
- private String subscription_id;
+ private String subscriptionId;
@JsonProperty( "product_id" )
- private String product_id;
+ private String productId;
@JsonProperty( "created_at" )
- private Date created_at;
+ private ZonedDateTime createdAt;
@JsonProperty( "payment_id" )
- private String payment_id;
-
- public Adjustment()
- {
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public Boolean getSuccess()
- {
- return success;
- }
-
- public void setSuccess( Boolean success )
- {
- this.success = success;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- public Integer getAmount_in_cents()
- {
- return amount_in_cents;
- }
-
- public void setAmount_in_cents( Integer amount_in_cents )
- {
- this.amount_in_cents = amount_in_cents;
- }
-
- public Integer getEnding_balance_in_cents()
- {
- return ending_balance_in_cents;
- }
-
- public void setEnding_balance_in_cents( Integer ending_balance_in_cents )
- {
- this.ending_balance_in_cents = ending_balance_in_cents;
- }
-
- public String getType()
- {
- return type;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- public String getTransaction_type()
- {
- return transaction_type;
- }
-
- public void setTransaction_type( String transaction_type )
- {
- this.transaction_type = transaction_type;
- }
-
- public String getSubscription_id()
- {
- return subscription_id;
- }
-
- public void setSubscription_id( String subscription_id )
- {
- this.subscription_id = subscription_id;
- }
-
- public String getProduct_id()
- {
- return product_id;
- }
-
- public void setProduct_id( String product_id )
- {
- this.product_id = product_id;
- }
-
- public Date getCreated_at()
- {
- return created_at;
- }
-
- public void setCreated_at( Date created_at )
- {
- this.created_at = created_at;
- }
-
- public String getPayment_id()
- {
- return payment_id;
- }
-
- public void setPayment_id( String payment_id )
- {
- this.payment_id = payment_id;
- }
-
- @Override
- public String toString()
- {
- return "Adjustment{" +
- "id='" + id + '\'' +
- ", success=" + success +
- ", memo='" + memo + '\'' +
- ", amount_in_cents=" + amount_in_cents +
- ", ending_balance_in_cents=" + ending_balance_in_cents +
- ", type='" + type + '\'' +
- ", transaction_type='" + transaction_type + '\'' +
- ", subscription_id='" + subscription_id + '\'' +
- ", product_id='" + product_id + '\'' +
- ", created_at=" + created_at +
- ", payment_id='" + payment_id + '\'' + '}';
- }
+ private String paymentId;
}
diff --git a/src/main/java/com/chargify/model/Allocation.java b/src/main/java/com/chargify/model/Allocation.java
index d76b87e..a31118d 100644
--- a/src/main/java/com/chargify/model/Allocation.java
+++ b/src/main/java/com/chargify/model/Allocation.java
@@ -2,9 +2,15 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
-import java.util.Date;
+import java.time.ZonedDateTime;
+@ToString
+@Getter
+@Setter
@JsonInclude( JsonInclude.Include.NON_NULL )
public class Allocation
{
@@ -21,119 +27,13 @@ public class Allocation
private String memo;
- private Date timestamp;
+ private ZonedDateTime timestamp;
- @JsonProperty( "proration_upgrade_scheme" )
- private String prorationUpgradeScheme;
+ @JsonProperty( "upgrade_charge" )
+ private String upgradeCharge;
- @JsonProperty( "proration_downgrade_scheme" )
- private String prorationDowngradeScheme;
+ @JsonProperty( "downgrade_credit" )
+ private String downgradeCredit;
private Payment payment;
-
- public String getComponentId()
- {
- return componentId;
- }
-
- public void setComponentId( String componentId )
- {
- this.componentId = componentId;
- }
-
- public String getSubscriptionId()
- {
- return subscriptionId;
- }
-
- public void setSubscriptionId( String subscriptionId )
- {
- this.subscriptionId = subscriptionId;
- }
-
- public Integer getQuantity()
- {
- return quantity;
- }
-
- public void setQuantity( Integer quantity )
- {
- this.quantity = quantity;
- }
-
- public Integer getPreviousQuantity()
- {
- return previousQuantity;
- }
-
- public void setPreviousQuantity( Integer previousQuantity )
- {
- this.previousQuantity = previousQuantity;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- public Date getTimestamp()
- {
- return timestamp;
- }
-
- public void setTimestamp( Date timestamp )
- {
- this.timestamp = timestamp;
- }
-
- public String getProrationUpgradeScheme()
- {
- return prorationUpgradeScheme;
- }
-
- public void setProrationUpgradeScheme( String prorationUpgradeScheme )
- {
- this.prorationUpgradeScheme = prorationUpgradeScheme;
- }
-
- public String getProrationDowngradeScheme()
- {
- return prorationDowngradeScheme;
- }
-
- public void setProrationDowngradeScheme( String prorationDowngradeScheme )
- {
- this.prorationDowngradeScheme = prorationDowngradeScheme;
- }
-
- public Payment getPayment()
- {
- return payment;
- }
-
- public void setPayment( Payment payment )
- {
- this.payment = payment;
- }
-
- @Override
- public String toString()
- {
- return "Allocation{" +
- "componentId='" + componentId + '\'' +
- ", subscriptionId='" + subscriptionId + '\'' +
- ", quantity=" + quantity +
- ", previousQuantity=" + previousQuantity +
- ", memo='" + memo + '\'' +
- ", timestamp=" + timestamp +
- ", prorationUpgradeScheme='" + prorationUpgradeScheme + '\'' +
- ", prorationDowngradeScheme='" + prorationDowngradeScheme + '\'' +
- ", payment=" + payment +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/AllocationPreview.java b/src/main/java/com/chargify/model/AllocationPreview.java
new file mode 100644
index 0000000..9345854
--- /dev/null
+++ b/src/main/java/com/chargify/model/AllocationPreview.java
@@ -0,0 +1,113 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@NoArgsConstructor
+@Data
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class AllocationPreview
+{
+ @JsonProperty( "start_date" )
+ private LocalDateTime startDate;
+ @JsonProperty( "end_date" )
+ private LocalDateTime endDate;
+ @JsonProperty( "period_type" )
+ private String periodType;
+ @JsonProperty( "total_in_cents" )
+ private Integer totalInCents;
+ @JsonProperty( "total_discount_in_cents" )
+ private Integer totalDiscountInCents;
+ @JsonProperty( "total_tax_in_cents" )
+ private Integer totalTaxInCents;
+ @JsonProperty( "subtotal_in_cents" )
+ private Integer subtotalInCents;
+ @JsonProperty( "existing_balance_in_cents" )
+ private Long existingBalanceInCents;
+ @JsonProperty( "direction" )
+ private String direction;
+ @JsonProperty( "proration_scheme" )
+ private String prorationScheme;
+ @JsonProperty( "line_items" )
+ private List lineItems;
+ @JsonProperty( "allocations" )
+ private List allocations;
+
+
+ @NoArgsConstructor
+ @Data
+ @JsonInclude( JsonInclude.Include.NON_NULL )
+ public static class LineItem
+ {
+ @JsonProperty( "transaction_type" )
+ private String transactionType;
+ private ComponentKind kind;
+ @JsonProperty( "amount_in_cents" )
+ private Integer amountInCents;
+ private String memo;
+ @JsonProperty( "discount_amount_in_cents" )
+ private Integer discountAmountInCents;
+ @JsonProperty( "taxable_amount_in_cents" )
+ private Integer taxable_amount_in_cents;
+ @JsonProperty( "component_id" )
+ private Integer componentId;
+ @JsonProperty( "component_handle" )
+ private String componentHandle;
+ @JsonProperty( "accrue_charge" )
+ private Boolean accrueCharge;
+ @JsonProperty( "upgrade_charge" )
+ private String upgradeCharge;
+ }
+
+ @NoArgsConstructor
+ @Data
+ @JsonInclude( JsonInclude.Include.NON_NULL )
+ public static class Allocation
+ {
+ @JsonProperty( "allocation_id" )
+ private String allocationId;
+ @JsonProperty( "component_id" )
+ private Integer componentId;
+ @JsonProperty( "subscription_id" )
+ private Integer subscriptionId;
+ private Integer quantity;
+ @JsonProperty( "previous_quantity" )
+ private Integer previousQuantity;
+ private String memo;
+ private LocalDateTime timestamp;
+ @JsonProperty( "proration_upgrade_scheme" )
+ private String prorationUpgradeScheme;
+ @JsonProperty( "proration_downgrade_scheme" )
+ private String prorationDowngradeScheme;
+ @JsonProperty( "price_point_id" )
+ private Integer pricePointId;
+ @JsonProperty( "previous_price_point_id" )
+ private Integer previousPricePointId;
+ @JsonProperty( "component_handle" )
+ private String componentHandle;
+ @JsonProperty( "accrue_charge" )
+ private Boolean accrueCharge;
+ @JsonProperty( "upgrade_charge" )
+ private String upgradeCharge;
+ @JsonProperty( "downgrade_credit" )
+ private String downgradeCredit;
+ @JsonProperty( "created_at" )
+ private LocalDateTime createdAt;
+ }
+
+ @AllArgsConstructor
+ @Getter
+ public static class ComponentAllocationDTO
+ {
+ @JsonProperty( "component_id" )
+ private final int componentId;
+ private final int quantity;
+ }
+}
diff --git a/src/main/java/com/chargify/model/BaseUpsertPaymentProfile.java b/src/main/java/com/chargify/model/BaseUpsertPaymentProfile.java
new file mode 100644
index 0000000..17ad169
--- /dev/null
+++ b/src/main/java/com/chargify/model/BaseUpsertPaymentProfile.java
@@ -0,0 +1,54 @@
+/*
+ * ********************************************************************************************************************
+ *
+ * BACKENDLESS.COM CONFIDENTIAL
+ *
+ * ********************************************************************************************************************
+ *
+ * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
+ *
+ * NOTICE: Â All information contained herein is, and remains the property of Backendless.com and its suppliers,
+ * if any. Â The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
+ * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
+ * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
+ * unless prior written permission is obtained from Backendless.com.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter @Setter
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public abstract class BaseUpsertPaymentProfile
+{
+ @JsonProperty( "first_name" )
+ private String firstName;
+
+ @JsonProperty( "last_name" )
+ private String lastName;
+
+ @JsonProperty( "payment_type" )
+ private String paymentType;
+
+ @JsonProperty( "full_number" )
+ private String cardNumber;
+
+ @JsonProperty( "expiration_month" )
+ private Integer expirationMonth;
+
+ @JsonProperty( "expiration_year" )
+ private Integer expirationYear;
+
+ @JsonProperty( "billing_zip" )
+ private String billingZip;
+
+ private String cvv;
+}
diff --git a/src/main/java/com/chargify/model/Charge.java b/src/main/java/com/chargify/model/Charge.java
index c482630..61893af 100644
--- a/src/main/java/com/chargify/model/Charge.java
+++ b/src/main/java/com/chargify/model/Charge.java
@@ -3,10 +3,19 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
-import java.util.Arrays;
import java.util.Date;
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+@EqualsAndHashCode
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude( JsonInclude.Include.NON_NULL )
public class Charge
@@ -34,10 +43,10 @@ public class Charge
private Date createdAt;
@JsonProperty( "starting_balance_in_cents" )
- private int startingBalanceInCents;
+ private long startingBalanceInCents;
@JsonProperty( "ending_balance_in_cents" )
- private int endingBalanceInCents;
+ private long endingBalanceInCents;
@JsonProperty( "gateway_used" )
private String gatewayUsed;
@@ -76,278 +85,4 @@ public class Charge
private int taxableAmountInCents;
private String[] taxations;
-
- public Charge()
- {
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getSubscriptionId()
- {
- return subscriptionId;
- }
-
- public void setSubscriptionId( String subscriptionId )
- {
- this.subscriptionId = subscriptionId;
- }
-
- public String getType()
- {
- return type;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- public String getKind()
- {
- return kind;
- }
-
- public void setKind( String kind )
- {
- this.kind = kind;
- }
-
- public String getTransactionType()
- {
- return transactionType;
- }
-
- public void setTransactionType( String transactionType )
- {
- this.transactionType = transactionType;
- }
-
- public Boolean getSuccess()
- {
- return success;
- }
-
- public void setSuccess( Boolean success )
- {
- this.success = success;
- }
-
- public int getAmountInCents()
- {
- return amountInCents;
- }
-
- public void setAmountInCents( int amountInCents )
- {
- this.amountInCents = amountInCents;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- public Date getCreatedAt()
- {
- return createdAt;
- }
-
- public void setCreatedAt( Date createdAt )
- {
- this.createdAt = createdAt;
- }
-
- public int getStartingBalanceInCents()
- {
- return startingBalanceInCents;
- }
-
- public void setStartingBalanceInCents( int startingBalanceInCents )
- {
- this.startingBalanceInCents = startingBalanceInCents;
- }
-
- public int getEndingBalanceInCents()
- {
- return endingBalanceInCents;
- }
-
- public void setEndingBalanceInCents( int endingBalanceInCents )
- {
- this.endingBalanceInCents = endingBalanceInCents;
- }
-
- public String getGatewayUsed()
- {
- return gatewayUsed;
- }
-
- public void setGatewayUsed( String gatewayUsed )
- {
- this.gatewayUsed = gatewayUsed;
- }
-
- public String getGatewayTransactionId()
- {
- return gatewayTransactionId;
- }
-
- public void setGatewayTransactionId( String gatewayTransactionId )
- {
- this.gatewayTransactionId = gatewayTransactionId;
- }
-
- public String getGatewayOrderId()
- {
- return gatewayOrderId;
- }
-
- public void setGatewayOrderId( String gatewayOrderId )
- {
- this.gatewayOrderId = gatewayOrderId;
- }
-
- public String getPaymentId()
- {
- return paymentId;
- }
-
- public void setPaymentId( String paymentId )
- {
- this.paymentId = paymentId;
- }
-
- public String getProductId()
- {
- return productId;
- }
-
- public void setProductId( String productId )
- {
- this.productId = productId;
- }
-
- public String getTaxId()
- {
- return taxId;
- }
-
- public void setTaxId( String taxId )
- {
- this.taxId = taxId;
- }
-
- public String getComponentId()
- {
- return componentId;
- }
-
- public void setComponentId( String componentId )
- {
- this.componentId = componentId;
- }
-
- public String getStatementId()
- {
- return statementId;
- }
-
- public void setStatementId( String statementId )
- {
- this.statementId = statementId;
- }
-
- public String getCustomerId()
- {
- return customerId;
- }
-
- public void setCustomerId( String customerId )
- {
- this.customerId = customerId;
- }
-
- public int getOriginalAmountInCents()
- {
- return originalAmountInCents;
- }
-
- public void setOriginalAmountInCents( int originalAmountInCents )
- {
- this.originalAmountInCents = originalAmountInCents;
- }
-
- public int getDiscountAmountInCents()
- {
- return discountAmountInCents;
- }
-
- public void setDiscountAmountInCents( int discountAmountInCents )
- {
- this.discountAmountInCents = discountAmountInCents;
- }
-
- public int getTaxableAmountInCents()
- {
- return taxableAmountInCents;
- }
-
- public void setTaxableAmountInCents( int taxableAmountInCents )
- {
- this.taxableAmountInCents = taxableAmountInCents;
- }
-
- public String[] getTaxations()
- {
- return taxations;
- }
-
- public void setTaxations( String[] taxations )
- {
- this.taxations = taxations;
- }
-
- @Override
- public String toString()
- {
- return "Charge{" +
- "id='" + id + '\'' +
- ", subscriptionId='" + subscriptionId + '\'' +
- ", type='" + type + '\'' +
- ", kind='" + kind + '\'' +
- ", transactionType='" + transactionType + '\'' +
- ", success=" + success +
- ", amountInCents=" + amountInCents +
- ", memo='" + memo + '\'' +
- ", createdAt=" + createdAt +
- ", startingBalanceInCents=" + startingBalanceInCents +
- ", endingBalanceInCents=" + endingBalanceInCents +
- ", gatewayUsed='" + gatewayUsed + '\'' +
- ", gatewayTransactionId='" + gatewayTransactionId + '\'' +
- ", gatewayOrderId='" + gatewayOrderId + '\'' +
- ", paymentId='" + paymentId + '\'' +
- ", productId='" + productId + '\'' +
- ", taxId='" + taxId + '\'' +
- ", componentId='" + componentId + '\'' +
- ", statementId='" + statementId + '\'' +
- ", customerId='" + customerId + '\'' +
- ", originalAmountInCents=" + originalAmountInCents +
- ", discountAmountInCents=" + discountAmountInCents +
- ", taxableAmountInCents=" + taxableAmountInCents +
- ", taxations=" + Arrays.toString( taxations ) + '}';
- }
}
diff --git a/src/main/java/com/chargify/model/Component.java b/src/main/java/com/chargify/model/Component.java
index cdc0486..531cb05 100644
--- a/src/main/java/com/chargify/model/Component.java
+++ b/src/main/java/com/chargify/model/Component.java
@@ -20,14 +20,15 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import java.io.Serializable;
-import java.util.Arrays;
+@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
public class Component implements Serializable
{
- private String id;
+ private Integer id;
private String name;
@@ -60,163 +61,7 @@ public class Component implements Serializable
private Boolean taxable;
- private String description;
+ private Boolean recurring;
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getPricingScheme()
- {
- return pricingScheme;
- }
-
- public void setPricingScheme( String pricingScheme )
- {
- this.pricingScheme = pricingScheme;
- }
-
- public String getUnitName()
- {
- return unitName;
- }
-
- public void setUnitName( String unitName )
- {
- this.unitName = unitName;
- }
-
- public Double getUnitPrice()
- {
- return unitPrice;
- }
-
- public void setUnitPrice( Double unitPrice )
- {
- this.unitPrice = unitPrice;
- }
-
- public String getProductFamilyId()
- {
- return productFamilyId;
- }
-
- public void setProductFamilyId( String productFamilyId )
- {
- this.productFamilyId = productFamilyId;
- }
-
- public ComponentKind getKind()
- {
- return kind;
- }
-
- public void setKind( ComponentKind kind )
- {
- this.kind = kind;
- }
-
- public Boolean getArchived()
- {
- return archived;
- }
-
- public void setArchived( Boolean archived )
- {
- this.archived = archived;
- }
-
- public Boolean getTaxable()
- {
- return taxable;
- }
-
- public void setTaxable( Boolean taxable )
- {
- this.taxable = taxable;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription( String description )
- {
- this.description = description;
- }
-
- public Price[] getPrices()
- {
- return prices;
- }
-
- public void setPrices( Price[] prices )
- {
- this.prices = prices;
- }
-
- public PricePoint[] getPricePoints()
- {
- return pricePoints;
- }
-
- public void setPricePoints( PricePoint[] pricePoints )
- {
- this.pricePoints = pricePoints;
- }
-
- public String toString()
- {
- return "Component{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", pricingScheme='" + pricingScheme + '\'' +
- ", unitName='" + unitName + '\'' +
- ", unitPrice=" + unitPrice +
- ", productFamilyId='" + productFamilyId + '\'' +
- ", prices=" + Arrays.toString( prices ) +
- ", pricePoints=" + Arrays.toString( pricePoints ) +
- ", kind=" + kind +
- ", archived=" + archived +
- ", taxable=" + taxable +
- ", description='" + description + '\'' +
- '}';
- }
-
- public String getDefaultPricePointName()
- {
- return defaultPricePointName;
- }
-
- public void setDefaultPricePointName( String defaultPricePointName )
- {
- this.defaultPricePointName = defaultPricePointName;
- }
-
- public String getDefaultPricePointHandle()
- {
- return defaultPricePointHandle;
- }
-
- public void setDefaultPricePointHandle( String defaultPricePointHandle )
- {
- this.defaultPricePointHandle = defaultPricePointHandle;
- }
+ private String description;
}
diff --git a/src/main/java/com/chargify/model/ComponentPricePointUpdate.java b/src/main/java/com/chargify/model/ComponentPricePointUpdate.java
index 1c84694..3c6ea83 100644
--- a/src/main/java/com/chargify/model/ComponentPricePointUpdate.java
+++ b/src/main/java/com/chargify/model/ComponentPricePointUpdate.java
@@ -2,38 +2,32 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+@Data
public final class ComponentPricePointUpdate
{
- private final int componentId;
- private final String pricePointHandle;
+ @JsonProperty( "component_id" )
+ private int componentId;
+ @JsonProperty( "price_point" )
+ private String pricePointHandle;
+ @JsonProperty( value = "message" )
+ private String message;
@JsonCreator
- public ComponentPricePointUpdate( @JsonProperty( "component_id" ) int componentId,
- @JsonProperty( "price_point" ) String pricePointHandle )
+ public ComponentPricePointUpdate()
{
- this.componentId = componentId;
- this.pricePointHandle = pricePointHandle;
}
- @JsonProperty( "component_id" )
- public int getComponentId()
+ public ComponentPricePointUpdate( int componentId, String pricePointHandle )
{
- return componentId;
+ this( componentId, pricePointHandle, null );
}
- @JsonProperty( "price_point" )
- public String getPricePointHandle()
+ public ComponentPricePointUpdate( int componentId, String pricePointHandle, String message )
{
- return pricePointHandle;
- }
-
- @Override
- public String toString()
- {
- return "ComponentPricePointUpdate{" +
- "componentId='" + componentId + '\'' +
- ", pricePointHandle='" + pricePointHandle + '\'' +
- '}';
+ this.componentId = componentId;
+ this.pricePointHandle = pricePointHandle;
+ this.message = message;
}
}
diff --git a/src/main/java/com/chargify/model/ComponentWithPricePoints.java b/src/main/java/com/chargify/model/ComponentWithPricePoints.java
new file mode 100644
index 0000000..9a7d5b0
--- /dev/null
+++ b/src/main/java/com/chargify/model/ComponentWithPricePoints.java
@@ -0,0 +1,19 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Set;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class ComponentWithPricePoints implements Serializable
+{
+ private Component component;
+ private Set pricePoints;
+}
diff --git a/src/main/java/com/chargify/model/CreatePaymentProfile.java b/src/main/java/com/chargify/model/CreatePaymentProfile.java
new file mode 100644
index 0000000..bf02c24
--- /dev/null
+++ b/src/main/java/com/chargify/model/CreatePaymentProfile.java
@@ -0,0 +1,34 @@
+/*
+ * ********************************************************************************************************************
+ *
+ * BACKENDLESS.COM CONFIDENTIAL
+ *
+ * ********************************************************************************************************************
+ *
+ * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
+ *
+ * NOTICE: Â All information contained herein is, and remains the property of Backendless.com and its suppliers,
+ * if any. Â The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
+ * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
+ * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
+ * unless prior written permission is obtained from Backendless.com.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter @Setter
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class CreatePaymentProfile extends BaseUpsertPaymentProfile
+{
+ @JsonProperty( "customer_id" )
+ private String customerId;
+}
diff --git a/src/main/java/com/chargify/model/CreateSubscription.java b/src/main/java/com/chargify/model/CreateSubscription.java
new file mode 100644
index 0000000..3951952
--- /dev/null
+++ b/src/main/java/com/chargify/model/CreateSubscription.java
@@ -0,0 +1,75 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.ZonedDateTime;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@Data
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class CreateSubscription implements Serializable
+{
+
+ @JsonProperty( "product_handle" )
+ private String productHandle;
+
+ @JsonProperty( "product_id" )
+ private String productId;
+
+ @JsonProperty( "product_price_point_handle" )
+ private String productPricePointHandle;
+
+ @JsonProperty( "product_price_point_id" )
+ private String productPricePointId;
+
+ @JsonProperty( "coupon_code" )
+ private String couponCode;
+
+ @JsonProperty( "payment_collection_method" )
+ private String paymentCollectionMethod;
+
+ @JsonProperty( "receives_invoice_emails" )
+ private Boolean receivesInvoiceEmails;
+
+ @JsonProperty( "net_terms" )
+ private String netTerms;
+
+ @JsonProperty( "customer_id" )
+ private String customerId;
+
+ @JsonProperty( "customer_reference" )
+ private String customerReference;
+
+ @JsonProperty( "next_billing_at" )
+ private ZonedDateTime nextBillingAt;
+
+ @JsonProperty( "stored_credential_transaction_id" )
+ private Integer storedCredentialTransactionId;
+
+ @JsonProperty( "sales_rep_id" )
+ private Integer salesRepId;
+
+ @JsonProperty( "payment_profile_id" )
+ private String paymentProfileId;
+
+ @JsonProperty( "ref" )
+ private String referralCode;
+
+ @JsonProperty( "reference" )
+ private String reference;
+
+ @JsonProperty( "customer_attributes" )
+ private Customer customerAttributes;
+
+ private List components;
+
+ private Map metafields = new HashMap<>();
+
+ private String currency;
+}
diff --git a/src/main/java/com/chargify/model/CreditCard.java b/src/main/java/com/chargify/model/CreditCard.java
index 07d28c3..3c798bb 100644
--- a/src/main/java/com/chargify/model/CreditCard.java
+++ b/src/main/java/com/chargify/model/CreditCard.java
@@ -20,9 +20,13 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
+@NoArgsConstructor
+@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
public class CreditCard implements Serializable
{
@@ -44,10 +48,10 @@ public class CreditCard implements Serializable
private String cardType;
@JsonProperty( "expiration_month" )
- private String expirationMonth;
+ private Integer expirationMonth;
@JsonProperty( "expiration_year" )
- private String expirationYear;
+ private Integer expirationYear;
@JsonProperty( "billing_address" )
private String billingAddress;
@@ -78,209 +82,4 @@ public class CreditCard implements Serializable
@JsonProperty( "customer_id" )
private String customerId;
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getCardType()
- {
- return cardType;
- }
-
- public void setCardType( String cardType )
- {
- this.cardType = cardType;
- }
-
- public String getExpirationMonth()
- {
- return expirationMonth;
- }
-
- public void setExpirationMonth( String expirationMonth )
- {
- this.expirationMonth = expirationMonth;
- }
-
- public String getExpirationYear()
- {
- return expirationYear;
- }
-
- public void setExpirationYear( String expirationYear )
- {
- this.expirationYear = expirationYear;
- }
-
- public String getFirstName()
- {
- return firstName;
- }
-
- public void setFirstName( String firstName )
- {
- this.firstName = firstName;
- }
-
- public String getLastName()
- {
- return lastName;
- }
-
- public void setLastName( String lastName )
- {
- this.lastName = lastName;
- }
-
- public String getMaskedCardNumber()
- {
- return maskedCardNumber;
- }
-
- public void setMaskedCardNumber( String maskedCardNumber )
- {
- this.maskedCardNumber = maskedCardNumber;
- }
-
- public String getCustomerId()
- {
- return customerId;
- }
-
- public void setCustomerId( String customerId )
- {
- this.customerId = customerId;
- }
-
- public String getCustomerVaultToken()
- {
- return customerVaultToken;
- }
-
- public void setCustomerVaultToken( String customerVaultToken )
- {
- this.customerVaultToken = customerVaultToken;
- }
-
- public String getVaultToken()
- {
- return vaultToken;
- }
-
- public void setVaultToken( String vaultToken )
- {
- this.vaultToken = vaultToken;
- }
-
- public String getCurrentVault()
- {
- return currentVault;
- }
-
- public void setCurrentVault( String currentVault )
- {
- this.currentVault = currentVault;
- }
-
- public String getBillingAddress()
- {
- return billingAddress;
- }
-
- public void setBillingAddress( String billingAddress )
- {
- this.billingAddress = billingAddress;
- }
-
- public String getBillingAddress2()
- {
- return billingAddress2;
- }
-
- public void setBillingAddress2( String billingAddress2 )
- {
- this.billingAddress2 = billingAddress2;
- }
-
- public String getBillingCity()
- {
- return billingCity;
- }
-
- public void setBillingCity( String billingCity )
- {
- this.billingCity = billingCity;
- }
-
- public String getBillingState()
- {
- return billingState;
- }
-
- public void setBillingState( String billingState )
- {
- this.billingState = billingState;
- }
-
- public String getBillingZip()
- {
- return billingZip;
- }
-
- public void setBillingZip( String billingZip )
- {
- this.billingZip = billingZip;
- }
-
- public String getBillingCountry()
- {
- return billingCountry;
- }
-
- public void setBillingCountry( String billingCountry )
- {
- this.billingCountry = billingCountry;
- }
-
- public String getPaymentType()
- {
- return paymentType;
- }
-
- public void setPaymentType( String paymentType )
- {
- this.paymentType = paymentType;
- }
-
- @Override
- public String toString()
- {
- return "CreditCard{" +
- "id='" + id + '\'' +
- ", paymentType='" + paymentType + '\'' +
- ", firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", maskedCardNumber='" + maskedCardNumber + '\'' +
- ", cardType='" + cardType + '\'' +
- ", expirationMonth='" + expirationMonth + '\'' +
- ", expirationYear='" + expirationYear + '\'' +
- ", billingAddress='" + billingAddress + '\'' +
- ", billingAddress2='" + billingAddress2 + '\'' +
- ", billingCity='" + billingCity + '\'' +
- ", billingState='" + billingState + '\'' +
- ", billingCountry='" + billingCountry + '\'' +
- ", billingZip='" + billingZip + '\'' +
- ", currentVault='" + currentVault + '\'' +
- ", vaultToken='" + vaultToken + '\'' +
- ", customerVaultToken='" + customerVaultToken + '\'' +
- ", customerId='" + customerId + '\'' +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/Customer.java b/src/main/java/com/chargify/model/Customer.java
index c322822..8946eef 100644
--- a/src/main/java/com/chargify/model/Customer.java
+++ b/src/main/java/com/chargify/model/Customer.java
@@ -1,37 +1,23 @@
-/*
- * ********************************************************************************************************************
- *
- * BACKENDLESS.COM CONFIDENTIAL
- *
- * ********************************************************************************************************************
- *
- * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
- *
- * NOTICE: Â All information contained herein is, and remains the property of Backendless.com and its suppliers,
- * if any. Â The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
- * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
- * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
- * unless prior written permission is obtained from Backendless.com.
- *
- * ********************************************************************************************************************
- */
-
package com.chargify.model;
import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
-@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class Customer implements Serializable
{
+ @JsonProperty( "first_name" )
private String firstName;
+ @JsonProperty( "last_name" )
private String lastName;
+ @JsonProperty( "email" )
private String email;
-
@JsonProperty( "cc_emails" )
private String ccEmails;
@@ -82,224 +68,4 @@ public Customer( @JsonProperty( "first_name" ) String firstName,
this.lastName = lastName;
this.email = email;
}
-
- public Customer()
- {
-
- }
-
- @JsonProperty( "first_name" )
- public String getFirstName()
- {
- return firstName;
- }
-
- @JsonProperty( "last_name" )
- public String getLastName()
- {
- return lastName;
- }
-
- @JsonProperty( "email" )
- public String getEmail()
- {
- return email;
- }
-
- public String getCcEmails()
- {
- return ccEmails;
- }
-
- public void setCcEmails( String ccEmails )
- {
- this.ccEmails = ccEmails;
- }
-
- public String getOrganization()
- {
- return organization;
- }
-
- public void setOrganization( String organization )
- {
- this.organization = organization;
- }
-
- public String getReference()
- {
- return reference;
- }
-
- public void setReference( String reference )
- {
- this.reference = reference;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public Date getCreatedAt()
- {
- return createdAt;
- }
-
- public void setCreatedAt( Date createdAt )
- {
- this.createdAt = createdAt;
- }
-
- public Date getUpdatedAt()
- {
- return updatedAt;
- }
-
- public void setUpdatedAt( Date updatedAt )
- {
- this.updatedAt = updatedAt;
- }
-
- public String getAddress()
- {
- return address;
- }
-
- public void setAddress( String address )
- {
- this.address = address;
- }
-
- public String getAddress2()
- {
- return address2;
- }
-
- public void setAddress2( String address2 )
- {
- this.address2 = address2;
- }
-
- public String getCity()
- {
- return city;
- }
-
- public void setCity( String city )
- {
- this.city = city;
- }
-
- public String getState()
- {
- return state;
- }
-
- public void setState( String state )
- {
- this.state = state;
- }
-
- public String getZip()
- {
- return zip;
- }
-
- public void setZip( String zip )
- {
- this.zip = zip;
- }
-
- public String getCountry()
- {
- return country;
- }
-
- public void setCountry( String country )
- {
- this.country = country;
- }
-
- public String getPhone()
- {
- return phone;
- }
-
- public void setPhone( String phone )
- {
- this.phone = phone;
- }
-
- public Boolean getVerified()
- {
- return verified;
- }
-
- public void setVerified( Boolean verified )
- {
- this.verified = verified;
- }
-
- public Date getPortalCustomerCreatedAt()
- {
- return portalCustomerCreatedAt;
- }
-
- public void setPortalCustomerCreatedAt( Date portalCustomerCreatedAt )
- {
- this.portalCustomerCreatedAt = portalCustomerCreatedAt;
- }
-
- public Date getPortalInviteLastSentAt()
- {
- return portalInviteLastSentAt;
- }
-
- public void setPortalInviteLastSentAt( Date portalInviteLastSentAt )
- {
- this.portalInviteLastSentAt = portalInviteLastSentAt;
- }
-
- public Date getPortalInviteLastAcceptedAt()
- {
- return portalInviteLastAcceptedAt;
- }
-
- public void setPortalInviteLastAcceptedAt( Date portalInviteLastAcceptedAt )
- {
- this.portalInviteLastAcceptedAt = portalInviteLastAcceptedAt;
- }
-
- @Override
- public String toString()
- {
- return "Customer{" +
- "firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", email='" + email + '\'' +
- ", ccEmails='" + ccEmails + '\'' +
- ", organization='" + organization + '\'' +
- ", reference='" + reference + '\'' +
- ", id='" + id + '\'' +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", address='" + address + '\'' +
- ", address2='" + address2 + '\'' +
- ", city='" + city + '\'' +
- ", state='" + state + '\'' +
- ", zip='" + zip + '\'' +
- ", country='" + country + '\'' +
- ", phone='" + phone + '\'' +
- ", verified=" + verified +
- ", portalCustomerCreatedAt=" + portalCustomerCreatedAt +
- ", portalInviteLastSentAt=" + portalInviteLastSentAt +
- ", portalInviteLastAcceptedAt=" + portalInviteLastAcceptedAt +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/Event.java b/src/main/java/com/chargify/model/Event.java
new file mode 100644
index 0000000..fa2c127
--- /dev/null
+++ b/src/main/java/com/chargify/model/Event.java
@@ -0,0 +1,24 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class Event
+{
+ private Integer id;
+ private String key;
+ private String message;
+ @JsonProperty( "subscription_id" )
+ private Integer subscriptionId;
+ @JsonProperty( "created_at" )
+ private LocalDateTime createdAt;
+ @JsonProperty( "event_specific_data" )
+ private EventSpecificData eventSpecificData;
+}
diff --git a/src/main/java/com/chargify/model/EventSpecificData.java b/src/main/java/com/chargify/model/EventSpecificData.java
new file mode 100644
index 0000000..be971c2
--- /dev/null
+++ b/src/main/java/com/chargify/model/EventSpecificData.java
@@ -0,0 +1,17 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+@Data
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class EventSpecificData
+{
+ @JsonProperty( "product_id" )
+ private Integer productId;
+ @JsonProperty( "account_transaction_id" )
+ private Integer accountTransactionId;
+}
diff --git a/src/main/java/com/chargify/model/Events.java b/src/main/java/com/chargify/model/Events.java
new file mode 100644
index 0000000..aa26f20
--- /dev/null
+++ b/src/main/java/com/chargify/model/Events.java
@@ -0,0 +1,33 @@
+package com.chargify.model;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+
+@NoArgsConstructor( access = AccessLevel.PRIVATE )
+public final class Events
+{
+ public static final String BILLING_DATE_CHANGE = "billing_date_change";
+ public static final String COMPONENT_ALLOCATION_CHANGE = "component_allocation_change";
+ public static final String CUSTOMER_CREATE = "customer_create";
+ public static final String CUSTOMER_UPDATE = "customer_update";
+ public static final String DUNNING_STEP_REACHED = "dunning_step_reached";
+ public static final String EXPIRATION_DATE_CHANGE = "expiration_date_change";
+ public static final String EXPIRING_CARD = "expiring_card";
+ public static final String INVOICE_ISSUED = "invoice_issued";
+ public static final String METERED_USAGE = "metered_usage";
+ public static final String PAYMENT_FAILURE = "payment_failure";
+ public static final String PAYMENT_SUCCESS = "payment_success";
+ public static final String PREPAID_USAGE = "prepaid_usage";
+ public static final String RENEWAL_FAILURE = "renewal_failure";
+ public static final String RENEWAL_SUCCESS = "renewal_success";
+ public static final String SIGNUP_SUCCESS = "signup_success";
+ public static final String SIGNUP_FAILURE = "signup_failure";
+ public static final String SUBSCRIPTION_CARD_UPDATE = "subscription_card_update";
+ public static final String SUBSCRIPTION_PRODUCT_CHANGE = "subscription_product_change";
+ public static final String SUBSCRIPTION_STATE_CHANGE = "subscription_state_change";
+ public static final String UPCOMING_RENEWAL_NOTICE = "upcoming_renewal_notice";
+ public static final String UPGRADE_DOWNGRADE_FAILURE = "upgrade_downgrade_failure";
+ public static final String UPGRADE_DOWNGRADE_SUCCESS = "upgrade_downgrade_success";
+ public static final String PENDING_CANCELLATION_CHANGE = "pending_cancellation_change";
+}
diff --git a/src/main/java/com/chargify/model/Metadata.java b/src/main/java/com/chargify/model/Metadata.java
index 65ef49f..7fef6e1 100644
--- a/src/main/java/com/chargify/model/Metadata.java
+++ b/src/main/java/com/chargify/model/Metadata.java
@@ -3,11 +3,15 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class Metadata implements Serializable
{
private String value;
@@ -19,54 +23,4 @@ public class Metadata implements Serializable
@JsonProperty( "current_name" )
private String currentName;
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-
- public String getResourceId()
- {
- return resourceId;
- }
-
- public void setResourceId( String resourceId )
- {
- this.resourceId = resourceId;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- @Override
- public String toString()
- {
- return "Metadata{" +
- "value='" + value + '\'' +
- ", resourceId='" + resourceId + '\'' +
- ", name='" + name + '\'' +
- '}';
- }
-
- public String getCurrentName()
- {
- return currentName;
- }
-
- public void setCurrentName( String currentName )
- {
- this.currentName = currentName;
- }
}
diff --git a/src/main/java/com/chargify/model/Migration.java b/src/main/java/com/chargify/model/Migration.java
index d1e22da..924f63f 100644
--- a/src/main/java/com/chargify/model/Migration.java
+++ b/src/main/java/com/chargify/model/Migration.java
@@ -2,7 +2,16 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+@Builder
+@AllArgsConstructor( access = AccessLevel.PRIVATE )
+@NoArgsConstructor
+@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
public class Migration
{
@@ -10,25 +19,11 @@ public class Migration
private String productHandle;
@JsonProperty( "include_trial")
- private Integer includeTrial;
+ private Boolean includeTrial;
- public String getProductHandle()
- {
- return productHandle;
- }
+ @JsonProperty( "preserve_period")
+ private Boolean preservePeriod;
- public void setProductHandle( String productHandle )
- {
- this.productHandle = productHandle;
- }
-
- public Integer getIncludeTrial()
- {
- return includeTrial;
- }
-
- public void setIncludeTrial( Integer includeTrial )
- {
- this.includeTrial = includeTrial;
- }
+ @JsonProperty( "product_price_point_handle")
+ private String pricePointHandle;
}
diff --git a/src/main/java/com/chargify/model/Payment.java b/src/main/java/com/chargify/model/Payment.java
index 973aced..1516c49 100644
--- a/src/main/java/com/chargify/model/Payment.java
+++ b/src/main/java/com/chargify/model/Payment.java
@@ -3,9 +3,13 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class Payment
{
private String id;
@@ -17,62 +21,8 @@ public class Payment
private String memo;
- public Payment()
- {
- }
-
public Payment( String id )
{
this.id = id;
}
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public Boolean getSuccess()
- {
- return success;
- }
-
- public void setSuccess( Boolean success )
- {
- this.success = success;
- }
-
- public int getAmountInCents()
- {
- return amountInCents;
- }
-
- public void setAmountInCents( int amountInCents )
- {
- this.amountInCents = amountInCents;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- @Override
- public String toString()
- {
- return "Payment{" +
- "id='" + id + '\'' +
- ", success=" + success +
- ", amountInCents=" + amountInCents +
- ", memo='" + memo + '\'' + '}';
- }
}
diff --git a/src/main/java/com/chargify/model/PaymentProfile.java b/src/main/java/com/chargify/model/PaymentProfile.java
new file mode 100644
index 0000000..588381f
--- /dev/null
+++ b/src/main/java/com/chargify/model/PaymentProfile.java
@@ -0,0 +1,63 @@
+/*
+ * ********************************************************************************************************************
+ *
+ * BACKENDLESS.COM CONFIDENTIAL
+ *
+ * ********************************************************************************************************************
+ *
+ * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
+ *
+ * NOTICE: Â All information contained herein is, and remains the property of Backendless.com and its suppliers,
+ * if any. Â The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
+ * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
+ * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
+ * unless prior written permission is obtained from Backendless.com.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+@Getter @Setter
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class PaymentProfile implements Serializable
+{
+ @JsonProperty( "id" )
+ private String id;
+
+ @JsonProperty( "first_name" )
+ private String firstName;
+
+ @JsonProperty( "last_name" )
+ private String lastName;
+
+ @JsonProperty( "payment_type" )
+ private String paymentType;
+
+ @JsonProperty( "masked_card_number" )
+ private String maskedCardNumber;
+
+ @JsonProperty( "card_type" )
+ private String cardType;
+
+ @JsonProperty( "expiration_month" )
+ private Integer expirationMonth;
+
+ @JsonProperty( "expiration_year" )
+ private Integer expirationYear;
+
+ @JsonProperty( "customer_id" )
+ private String customerId;
+
+ @JsonProperty( "billing_zip" )
+ private String billingZip;
+}
diff --git a/src/main/java/com/chargify/model/PaymentProfileAttributes.java b/src/main/java/com/chargify/model/PaymentProfileAttributes.java
deleted file mode 100644
index de06a08..0000000
--- a/src/main/java/com/chargify/model/PaymentProfileAttributes.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * ********************************************************************************************************************
- *
- * BACKENDLESS.COM CONFIDENTIAL
- *
- * ********************************************************************************************************************
- *
- * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
- *
- * NOTICE: Â All information contained herein is, and remains the property of Backendless.com and its suppliers,
- * if any. Â The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
- * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
- * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
- * unless prior written permission is obtained from Backendless.com.
- *
- * ********************************************************************************************************************
- */
-
-package com.chargify.model;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@JsonIgnoreProperties( ignoreUnknown = true )
-@JsonInclude( JsonInclude.Include.NON_NULL )
-public class PaymentProfileAttributes
-{
- @JsonProperty( "first_name" )
- private String firstName;
-
- @JsonProperty( "last_name" )
- private String lastName;
-
- @JsonProperty( "full_number" )
- private String fullNumber;
-
- @JsonProperty( "expiration_month" )
- private String expirationMonth;
-
- @JsonProperty( "expiration_year" )
- private String expirationYear;
-
- private String cvv;
-
- @JsonProperty( "billing_address" )
- private String billingAddress;
-
- @JsonProperty( "billing_address_2" )
- private String billingAddress2;
-
- @JsonProperty( "billing_city" )
- private String billingCity;
-
- @JsonProperty( "billing_state" )
- private String billingState;
-
- @JsonProperty( "billing_zip" )
- private String billingZip;
-
- @JsonProperty( "billing_country" )
- private String billingCountry;
-
- @JsonProperty( "vault_token" )
- private String vaultToken;
-
- @JsonProperty( "customer_vault_token" )
- private String customerVaultToken;
-
- @JsonProperty( "current_vault" )
- private String currentVault;
-
- @JsonProperty( "last_four" )
- private String lastFour;
-
- @JsonProperty( "card_type" )
- private String cardType;
-
- public String getFirstName()
- {
- return firstName;
- }
-
- public void setFirstName( String firstName )
- {
- this.firstName = firstName;
- }
-
- public String getLastName()
- {
- return lastName;
- }
-
- public void setLastName( String lastName )
- {
- this.lastName = lastName;
- }
-
- public String getFullNumber()
- {
- return fullNumber;
- }
-
- public void setFullNumber( String fullNumber )
- {
- this.fullNumber = fullNumber;
- }
-
- public String getExpirationMonth()
- {
- return expirationMonth;
- }
-
- public void setExpirationMonth( String expirationMonth )
- {
- this.expirationMonth = expirationMonth;
- }
-
- public String getExpirationYear()
- {
- return expirationYear;
- }
-
- public void setExpirationYear( String expirationYear )
- {
- this.expirationYear = expirationYear;
- }
-
- public String getCvv()
- {
- return cvv;
- }
-
- public void setCvv( String cvv )
- {
- this.cvv = cvv;
- }
-
- public String getBillingAddress()
- {
- return billingAddress;
- }
-
- public void setBillingAddress( String billingAddress )
- {
- this.billingAddress = billingAddress;
- }
-
- public String getBillingAddress2()
- {
- return billingAddress2;
- }
-
- public void setBillingAddress2( String billingAddress2 )
- {
- this.billingAddress2 = billingAddress2;
- }
-
- public String getBillingCity()
- {
- return billingCity;
- }
-
- public void setBillingCity( String billingCity )
- {
- this.billingCity = billingCity;
- }
-
- public String getBillingState()
- {
- return billingState;
- }
-
- public void setBillingState( String billingState )
- {
- this.billingState = billingState;
- }
-
- public String getBillingZip()
- {
- return billingZip;
- }
-
- public void setBillingZip( String billingZip )
- {
- this.billingZip = billingZip;
- }
-
- public String getBillingCountry()
- {
- return billingCountry;
- }
-
- public void setBillingCountry( String billingCountry )
- {
- this.billingCountry = billingCountry;
- }
-
- public String getVaultToken()
- {
- return vaultToken;
- }
-
- public void setVaultToken( String vaultToken )
- {
- this.vaultToken = vaultToken;
- }
-
- public String getCustomerVaultToken()
- {
- return customerVaultToken;
- }
-
- public void setCustomerVaultToken( String customerVaultToken )
- {
- this.customerVaultToken = customerVaultToken;
- }
-
- public String getCurrentVault()
- {
- return currentVault;
- }
-
- public void setCurrentVault( String currentVault )
- {
- this.currentVault = currentVault;
- }
-
- public String getLastFour()
- {
- return lastFour;
- }
-
- public void setLastFour( String lastFour )
- {
- this.lastFour = lastFour;
- }
-
- public String getCardType()
- {
- return cardType;
- }
-
- public void setCardType( String cardType )
- {
- this.cardType = cardType;
- }
-}
diff --git a/src/main/java/com/chargify/model/PaymentType.java b/src/main/java/com/chargify/model/PaymentType.java
new file mode 100644
index 0000000..fa106ee
--- /dev/null
+++ b/src/main/java/com/chargify/model/PaymentType.java
@@ -0,0 +1,12 @@
+package com.chargify.model;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor( access = AccessLevel.PRIVATE )
+public final class PaymentType
+{
+ public static final String CREDIT_CARD = "credit_card";
+ public static final String BANK_ACCOUNT = "bank_account";
+ public static final String PAYPAL_ACCOUNT = "paypal_account";
+}
diff --git a/src/main/java/com/chargify/model/Price.java b/src/main/java/com/chargify/model/Price.java
index 25ff9d3..9e49f09 100644
--- a/src/main/java/com/chargify/model/Price.java
+++ b/src/main/java/com/chargify/model/Price.java
@@ -3,51 +3,26 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
import java.io.Serializable;
+@AllArgsConstructor
@JsonInclude( JsonInclude.Include.NON_NULL )
+@Data
public final class Price implements Serializable
{
+ private Integer id;
+ @JsonProperty( "starting_quantity" )
private Integer startingQuantity;
+ @JsonProperty( "ending_quantity" )
private Integer endingQuantity;
+ @JsonProperty( "unit_price" )
private Double unitPrice;
@JsonCreator
public Price()
{
}
-
- @JsonProperty( "starting_quantity" )
- public Integer getStartingQuantity()
- {
- return startingQuantity;
- }
-
- public void setStartingQuantity( Integer startingQuantity )
- {
- this.startingQuantity = startingQuantity;
- }
-
- @JsonProperty( "ending_quantity" )
- public Integer getEndingQuantity()
- {
- return endingQuantity;
- }
-
- public void setEndingQuantity( Integer endingQuantity )
- {
- this.endingQuantity = endingQuantity;
- }
-
- @JsonProperty( "unit_price" )
- public Double getUnitPrice()
- {
- return unitPrice;
- }
-
- public void setUnitPrice( Double unitPrice )
- {
- this.unitPrice = unitPrice;
- }
}
diff --git a/src/main/java/com/chargify/model/PricePoint.java b/src/main/java/com/chargify/model/PricePoint.java
index 58dd693..fc697a5 100644
--- a/src/main/java/com/chargify/model/PricePoint.java
+++ b/src/main/java/com/chargify/model/PricePoint.java
@@ -1,63 +1,35 @@
package com.chargify.model;
-import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
public final class PricePoint implements Serializable
{
+ private Integer id;
+ @JsonProperty( "default" )
+ private boolean defaultPricePoint = false;
private String name;
private String handle;
+ @JsonProperty( "pricing_scheme" )
private String pricingScheme;
+ @JsonProperty( "component_id" )
+ private String componentId;
+ @JsonProperty( "archived_at" )
+ private String archivedAt;
+ @JsonProperty( "created_at" )
+ private String createdAt;
+ @JsonProperty( "updated_at" )
+ private String updatedAt;
+ @JsonProperty( "use_site_exchange_rate" )
+ private Boolean useSiteExchangeRate;
private Price[] prices;
-
- @JsonCreator
- public PricePoint()
- {
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getHandle()
- {
- return handle;
- }
-
- public void setHandle( String handle )
- {
- this.handle = handle;
- }
-
- @JsonProperty( "pricing_scheme" )
- public String getPricingScheme()
- {
- return pricingScheme;
- }
-
- public void setPricingScheme( String pricingScheme )
- {
- this.pricingScheme = pricingScheme;
- }
-
- @JsonProperty( "prices" )
- public Price[] getPrices()
- {
- return prices;
- }
-
- public void setPrices( Price[] prices )
- {
- this.prices = prices;
- }
}
diff --git a/src/main/java/com/chargify/model/PricePointIntervalUnit.java b/src/main/java/com/chargify/model/PricePointIntervalUnit.java
new file mode 100644
index 0000000..32a7ffd
--- /dev/null
+++ b/src/main/java/com/chargify/model/PricePointIntervalUnit.java
@@ -0,0 +1,6 @@
+package com.chargify.model;
+
+public enum PricePointIntervalUnit
+{
+ day, month
+}
diff --git a/src/main/java/com/chargify/model/PricePointUpdate.java b/src/main/java/com/chargify/model/PricePointUpdate.java
new file mode 100644
index 0000000..bec53ff
--- /dev/null
+++ b/src/main/java/com/chargify/model/PricePointUpdate.java
@@ -0,0 +1,18 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public final class PricePointUpdate implements Serializable
+{
+ private String name;
+ private Price[] prices;
+}
diff --git a/src/main/java/com/chargify/model/Product.java b/src/main/java/com/chargify/model/Product.java
deleted file mode 100644
index 64e63a7..0000000
--- a/src/main/java/com/chargify/model/Product.java
+++ /dev/null
@@ -1,390 +0,0 @@
-package com.chargify.model;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-@JsonInclude( JsonInclude.Include.NON_NULL )
-public class Product implements Serializable
-{
- private String id;
-
- private String name;
-
- private String handle;
-
- private String description;
-
- @JsonProperty( "accounting_code" )
- private String accountingCode;
-
- @JsonProperty( "request_credit_card" )
- private Boolean requestCreditCard;
-
- @JsonProperty( "expiration_interval" )
- private String expirationInterval;
-
- @JsonProperty( "expiration_interval_unit" )
- private String expirationIntervalUnit;
-
- @JsonProperty( "created_at" )
- private Date createdAt;
-
- @JsonProperty( "updated_at" )
- private Date updatedAt;
-
- @JsonProperty( "price_in_cents" )
- private int priceInCents;
-
- @JsonProperty( "interval" )
- private int recurringInterval;
-
- @JsonProperty( "interval_unit" )
- private IntervalUnit intervalUnit;
-
- @JsonProperty( "initial_charge_in_cents" )
- private String initialChargeInCents;
-
- @JsonProperty( "trial_price_in_cents" )
- private Integer trialPriceInCents;
-
- @JsonProperty( "trial_interval" )
- private Integer trialInterval;
-
- @JsonProperty( "trial_interval_unit" )
- private String trialIntervalUnit;
-
- @JsonProperty( "archived_at" )
- private Date archivedAt;
-
- @JsonProperty( "require_credit_card" )
- private Boolean requireCreditCard;
-
- @JsonProperty( "return_params" )
- private String returnParams;
-
- private Boolean taxable;
-
- @JsonProperty( "update_return_url" )
- private String updateReturnUrl;
-
- @JsonProperty( "initial_charge_after_trial" )
- private Boolean initialChargeAfterTrial;
-
- @JsonProperty( "version_number" )
- private Integer versionNumber;
-
- @JsonProperty( "update_return_params" )
- private String updateReturnParams;
-
- @JsonProperty( "product_family" )
- private ProductFamily productFamily;
-
- @JsonProperty( "public_signup_pages" )
- private List publicSignupPages;
-
- @JsonCreator
- public Product( @JsonProperty( "name" ) final String name,
- @JsonProperty( "price" ) final int priceInCents,
- @JsonProperty( "interval" ) final int recurringInterval,
- @JsonProperty( "interval_unit" ) final IntervalUnit intervalUnit )
- {
- this.name = name;
- this.priceInCents = priceInCents;
- this.recurringInterval = recurringInterval;
- this.intervalUnit = intervalUnit;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getHandle()
- {
- return handle;
- }
-
- public void setHandle( String handle )
- {
- this.handle = handle;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription( String description )
- {
- this.description = description;
- }
-
- public String getAccountingCode()
- {
- return accountingCode;
- }
-
- public void setAccountingCode( String accountingCode )
- {
- this.accountingCode = accountingCode;
- }
-
- public Boolean getRequestCreditCard()
- {
- return requestCreditCard;
- }
-
- public void setRequestCreditCard( Boolean requestCreditCard )
- {
- this.requestCreditCard = requestCreditCard;
- }
-
- public String getExpirationInterval()
- {
- return expirationInterval;
- }
-
- public void setExpirationInterval( String expirationInterval )
- {
- this.expirationInterval = expirationInterval;
- }
-
- public String getExpirationIntervalUnit()
- {
- return expirationIntervalUnit;
- }
-
- public void setExpirationIntervalUnit( String expirationIntervalUnit )
- {
- this.expirationIntervalUnit = expirationIntervalUnit;
- }
-
- public Date getCreatedAt()
- {
- return createdAt;
- }
-
- public void setCreatedAt( Date createdAt )
- {
- this.createdAt = createdAt;
- }
-
- public Date getUpdatedAt()
- {
- return updatedAt;
- }
-
- public void setUpdatedAt( Date updatedAt )
- {
- this.updatedAt = updatedAt;
- }
-
- public Integer getPriceInCents()
- {
- return priceInCents;
- }
-
- public int getRecurringInterval()
- {
- return recurringInterval;
- }
-
- public IntervalUnit getIntervalUnit()
- {
- return intervalUnit;
- }
-
- public String getInitialChargeInCents()
- {
- return initialChargeInCents;
- }
-
- public void setInitialChargeInCents( String initialChargeInCents )
- {
- this.initialChargeInCents = initialChargeInCents;
- }
-
- public Integer getTrialInterval()
- {
- return trialInterval;
- }
-
- public void setTrialInterval( Integer trialInterval )
- {
- this.trialInterval = trialInterval;
- }
-
- public String getTrialIntervalUnit()
- {
- return trialIntervalUnit;
- }
-
- public void setTrialIntervalUnit( String trialIntervalUnit )
- {
- this.trialIntervalUnit = trialIntervalUnit;
- }
-
- public Date getArchivedAt()
- {
- return archivedAt;
- }
-
- public void setArchivedAt( Date archivedAt )
- {
- this.archivedAt = archivedAt;
- }
-
- public Boolean getRequireCreditCard()
- {
- return requireCreditCard;
- }
-
- public void setRequireCreditCard( Boolean requireCreditCard )
- {
- this.requireCreditCard = requireCreditCard;
- }
-
- public String getReturnParams()
- {
- return returnParams;
- }
-
- public void setReturnParams( String returnParams )
- {
- this.returnParams = returnParams;
- }
-
- public Boolean getTaxable()
- {
- return taxable;
- }
-
- public void setTaxable( Boolean taxable )
- {
- this.taxable = taxable;
- }
-
- public String getUpdateReturnUrl()
- {
- return updateReturnUrl;
- }
-
- public void setUpdateReturnUrl( String updateReturnUrl )
- {
- this.updateReturnUrl = updateReturnUrl;
- }
-
- public Boolean getInitialChargeAfterTrial()
- {
- return initialChargeAfterTrial;
- }
-
- public void setInitialChargeAfterTrial( Boolean initialChargeAfterTrial )
- {
- this.initialChargeAfterTrial = initialChargeAfterTrial;
- }
-
- public Integer getVersionNumber()
- {
- return versionNumber;
- }
-
- public void setVersionNumber( Integer versionNumber )
- {
- this.versionNumber = versionNumber;
- }
-
- public String getUpdateReturnParams()
- {
- return updateReturnParams;
- }
-
- public void setUpdateReturnParams( String updateReturnParams )
- {
- this.updateReturnParams = updateReturnParams;
- }
-
- public ProductFamily getProductFamily()
- {
- return productFamily;
- }
-
- public void setProductFamily( ProductFamily productFamily )
- {
- this.productFamily = productFamily;
- }
-
- public List getPublicSignupPages()
- {
- return publicSignupPages;
- }
-
- public void setPublicSignupPages( List publicSignupPages )
- {
- this.publicSignupPages = publicSignupPages;
- }
-
- public Integer getTrialPriceInCents()
- {
- return trialPriceInCents;
- }
-
- public void setTrialPriceInCents( Integer trialPriceInCents )
- {
- this.trialPriceInCents = trialPriceInCents;
- }
-
- @Override
- public String toString()
- {
- return "Product{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", handle='" + handle + '\'' +
- ", description='" + description + '\'' +
- ", accountingCode='" + accountingCode + '\'' +
- ", requestCreditCard=" + requestCreditCard +
- ", expirationInterval='" + expirationInterval + '\'' +
- ", expirationIntervalUnit='" + expirationIntervalUnit + '\'' +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", priceInCents=" + priceInCents +
- ", recurringInterval=" + recurringInterval +
- ", intervalUnit=" + intervalUnit +
- ", initialChargeInCents='" + initialChargeInCents + '\'' +
- ", trialPriceInCents=" + trialPriceInCents +
- ", trialInterval=" + trialInterval +
- ", trialIntervalUnit='" + trialIntervalUnit + '\'' +
- ", archivedAt=" + archivedAt +
- ", requireCreditCard=" + requireCreditCard +
- ", returnParams='" + returnParams + '\'' +
- ", taxable=" + taxable +
- ", updateReturnUrl='" + updateReturnUrl + '\'' +
- ", initialChargeAfterTrial=" + initialChargeAfterTrial +
- ", versionNumber=" + versionNumber +
- ", updateReturnParams='" + updateReturnParams + '\'' +
- ", productFamily=" + productFamily +
- ", publicSignupPages=" + publicSignupPages +
- '}';
- }
-
- public enum IntervalUnit
- {
- month, day
- }
-}
diff --git a/src/main/java/com/chargify/model/ProductFamily.java b/src/main/java/com/chargify/model/ProductFamily.java
deleted file mode 100644
index 3174306..0000000
--- a/src/main/java/com/chargify/model/ProductFamily.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.chargify.model;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.io.Serializable;
-
-@JsonInclude( JsonInclude.Include.NON_NULL )
-public class ProductFamily implements Serializable
-{
- private String id;
-
- private String name;
-
- private String description;
-
- private String handle;
-
- @JsonProperty( "accounting_code" )
- private String accountingCode;
-
- @JsonCreator
- public ProductFamily( @JsonProperty( "name" ) String name )
- {
- this.name = name;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription( String description )
- {
- this.description = description;
- }
-
- public String getHandle()
- {
- return handle;
- }
-
- public void setHandle( String handle )
- {
- this.handle = handle;
- }
-
- public String getAccountingCode()
- {
- return accountingCode;
- }
-
- public void setAccountingCode( String accountingCode )
- {
- this.accountingCode = accountingCode;
- }
-
- @Override
- public String toString()
- {
- return "ProductFamily{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", description='" + description + '\'' +
- ", handle='" + handle + '\'' +
- ", accountingCode='" + accountingCode + '\'' +
- '}';
- }
-}
diff --git a/src/main/java/com/chargify/model/PublicSignupPage.java b/src/main/java/com/chargify/model/PublicSignupPage.java
index 7f8a5e5..3da305d 100644
--- a/src/main/java/com/chargify/model/PublicSignupPage.java
+++ b/src/main/java/com/chargify/model/PublicSignupPage.java
@@ -2,10 +2,14 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class PublicSignupPage implements Serializable
{
private String id;
@@ -17,55 +21,4 @@ public class PublicSignupPage implements Serializable
private String returnParams;
private String url;
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getReturnUrl()
- {
- return returnUrl;
- }
-
- public void setReturnUrl( String returnUrl )
- {
- this.returnUrl = returnUrl;
- }
-
- public String getReturnParams()
- {
- return returnParams;
- }
-
- public void setReturnParams( String returnParams )
- {
- this.returnParams = returnParams;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-
- @Override
- public String toString()
- {
- return "PublicSignupPage{" +
- "id='" + id + '\'' +
- ", returnUrl='" + returnUrl + '\'' +
- ", returnParams='" + returnParams + '\'' +
- ", url='" + url + '\'' +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/ReferralCode.java b/src/main/java/com/chargify/model/ReferralCode.java
index 813564e..776e90a 100644
--- a/src/main/java/com/chargify/model/ReferralCode.java
+++ b/src/main/java/com/chargify/model/ReferralCode.java
@@ -2,8 +2,14 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
+@Accessors( chain = true )
public class ReferralCode
{
private String id;
@@ -15,48 +21,4 @@ public class ReferralCode
private String subscriptionId;
private String code;
-
- public String getId()
- {
- return id;
- }
-
- public ReferralCode setId( String id )
- {
- this.id = id;
- return this;
- }
-
- public String getSiteId()
- {
- return siteId;
- }
-
- public ReferralCode setSiteId( String siteId )
- {
- this.siteId = siteId;
- return this;
- }
-
- public String getSubscriptionId()
- {
- return subscriptionId;
- }
-
- public ReferralCode setSubscriptionId( String subscriptionId )
- {
- this.subscriptionId = subscriptionId;
- return this;
- }
-
- public String getCode()
- {
- return code;
- }
-
- public ReferralCode setCode( String code )
- {
- this.code = code;
- return this;
- }
}
diff --git a/src/main/java/com/chargify/model/RefundInput.java b/src/main/java/com/chargify/model/RefundInput.java
index 8231841..85f37ec 100644
--- a/src/main/java/com/chargify/model/RefundInput.java
+++ b/src/main/java/com/chargify/model/RefundInput.java
@@ -3,9 +3,15 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
public class RefundInput
{
@JsonProperty( "payment_id" )
@@ -16,54 +22,4 @@ public class RefundInput
@JsonProperty( "memo" )
private String memo;
-
- public RefundInput()
- {
- }
-
- public RefundInput( String paymentId, int amountInCents, String memo )
- {
- this.paymentId = paymentId;
- this.amountInCents = amountInCents;
- this.memo = memo;
- }
-
- public String getPaymentId()
- {
- return paymentId;
- }
-
- public void setPaymentId( String paymentId )
- {
- this.paymentId = paymentId;
- }
-
- public int getAmountInCents()
- {
- return amountInCents;
- }
-
- public void setAmountInCents( int amountInCents )
- {
- this.amountInCents = amountInCents;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- @Override
- public String toString()
- {
- return "RefundInput{" +
- "paymentId='" + paymentId + '\'' +
- ", amountInCents=" + amountInCents +
- ", memo='" + memo + '\'' + '}';
- }
}
diff --git a/src/main/java/com/chargify/model/RefundOutput.java b/src/main/java/com/chargify/model/RefundOutput.java
index fd29586..ac2aaf6 100644
--- a/src/main/java/com/chargify/model/RefundOutput.java
+++ b/src/main/java/com/chargify/model/RefundOutput.java
@@ -3,9 +3,13 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class RefundOutput
{
private String id;
@@ -16,58 +20,4 @@ public class RefundOutput
private int amountInCents;
private String memo;
-
- public RefundOutput()
- {
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public Boolean getSuccess()
- {
- return success;
- }
-
- public void setSuccess( Boolean success )
- {
- this.success = success;
- }
-
- public int getAmountInCents()
- {
- return amountInCents;
- }
-
- public void setAmountInCents( int amountInCents )
- {
- this.amountInCents = amountInCents;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- @Override
- public String toString()
- {
- return "RefundOutput{" +
- "id='" + id + '\'' +
- ", success=" + success +
- ", amountInCents=" + amountInCents +
- ", memo='" + memo + '\'' + '}';
- }
}
diff --git a/src/main/java/com/chargify/model/RenewalPreview.java b/src/main/java/com/chargify/model/RenewalPreview.java
index 057e389..ca5261a 100644
--- a/src/main/java/com/chargify/model/RenewalPreview.java
+++ b/src/main/java/com/chargify/model/RenewalPreview.java
@@ -2,46 +2,24 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
+@EqualsAndHashCode
+@ToString
public class RenewalPreview
{
@JsonProperty( "subtotal_in_cents" )
- private Integer subtotalInCents;
+ private Long subtotalInCents;
@JsonProperty( "total_amount_due_in_cents" )
- private Integer totalAmountDureInCents;
+ private Long totalAmountDueInCents;
@JsonProperty( "existing_balance_in_cents" )
- private Integer existingBalanceInCents;
-
- public Integer getSubtotalInCents()
- {
- return subtotalInCents;
- }
-
- public void setSubtotalInCents( Integer subtotalInCents )
- {
- this.subtotalInCents = subtotalInCents;
- }
-
- public Integer getTotalAmountDueInCents()
- {
- return totalAmountDureInCents;
- }
-
- public void setTotalAmountDureInCents( Integer totalAmountDureInCents )
- {
- this.totalAmountDureInCents = totalAmountDureInCents;
- }
-
- public Integer getExistingBalanceInCents()
- {
- return existingBalanceInCents;
- }
-
- public void setExistingBalanceInCents( Integer existingBalanceInCents )
- {
- this.existingBalanceInCents = existingBalanceInCents;
- }
+ private Long existingBalanceInCents;
}
diff --git a/src/main/java/com/chargify/model/Subscription.java b/src/main/java/com/chargify/model/Subscription.java
index 3d63a39..3a201af 100644
--- a/src/main/java/com/chargify/model/Subscription.java
+++ b/src/main/java/com/chargify/model/Subscription.java
@@ -20,14 +20,15 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import java.io.Serializable;
import java.time.ZonedDateTime;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
public class Subscription implements Serializable
{
@@ -36,10 +37,10 @@ public class Subscription implements Serializable
private String state;
@JsonProperty( "balance_in_cents" )
- private Integer balanceInCents;
+ private Long balanceInCents;
@JsonProperty( "total_revenue_in_cents" )
- private Integer totalRevenueInCents;
+ private Long totalRevenueInCents;
@JsonProperty( "product_price_in_cents" )
private Integer productPriceInCents;
@@ -48,7 +49,7 @@ public class Subscription implements Serializable
private Integer productVersionNumber;
@JsonProperty( "current_period_ends_at" )
- private Date currentPeriodEndsAt;
+ private ZonedDateTime currentPeriodEndsAt;
@JsonProperty( "next_assessment_at" )
private ZonedDateTime nextAssessmentAt;
@@ -57,22 +58,22 @@ public class Subscription implements Serializable
private ZonedDateTime nextBillingAt;
@JsonProperty( "trial_started_at" )
- private Date trialStartedAt;
+ private ZonedDateTime trialStartedAt;
@JsonProperty( "trial_ended_at" )
- private Date trialEndedAt;
+ private ZonedDateTime trialEndedAt;
@JsonProperty( "activated_at" )
- private Date activatedAt;
+ private ZonedDateTime activatedAt;
@JsonProperty( "expires_at" )
- private Date expiresAt;
+ private ZonedDateTime expiresAt;
@JsonProperty( "created_at" )
- private Date createdAt;
+ private ZonedDateTime createdAt;
@JsonProperty( "updated_at" )
- private Date updatedAt;
+ private ZonedDateTime updatedAt;
@JsonProperty( "cancellation_message" )
private String cancellationMessage;
@@ -84,10 +85,10 @@ public class Subscription implements Serializable
private Boolean cancelAtEndOfPeriod;
@JsonProperty( "canceled_at" )
- private Date canceledAt;
+ private ZonedDateTime canceledAt;
@JsonProperty( "current_period_started_at" )
- private Date currentPeriodStartedAt;
+ private ZonedDateTime currentPeriodStartedAt;
@JsonProperty( "customer_attributes" )
private Customer customerAttributes;
@@ -107,9 +108,6 @@ public class Subscription implements Serializable
@JsonProperty( "product_handle" )
private String productHandle;
- @JsonProperty( "product_id" )
- private String productId;
-
@JsonProperty( "signup_payment_id" )
private Integer signupPaymentId;
@@ -117,7 +115,7 @@ public class Subscription implements Serializable
private String signupRevenue;
@JsonProperty( "delayed_cancel_at" )
- private Date delayedCancelAt;
+ private ZonedDateTime delayedCancelAt;
@JsonProperty( "coupon_code" )
private String couponCode;
@@ -136,7 +134,7 @@ public class Subscription implements Serializable
private Customer customer;
- private Product product;
+ private SubscriptionProduct product;
@JsonProperty( "credit_card" )
private CreditCard creditCard;
@@ -147,12 +145,18 @@ public class Subscription implements Serializable
@JsonProperty( "referral_code" )
private String referralCode;
- @JsonProperty( "ref" )
+ @JsonProperty( "reference" )
private String reference;
@JsonProperty( "next_product_id" )
private String nextProductId;
+ @JsonProperty( "next_product_handle" )
+ private String nextProductHandle;
+
+ @JsonProperty( "next_product_price_point_id" )
+ private Integer nextProductPricePointId;
+
@JsonProperty( "coupon_use_count" )
private Integer couponUseCount;
@@ -162,517 +166,4 @@ public class Subscription implements Serializable
private List components;
private Map metafields = new HashMap<>();
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getState()
- {
- return state;
- }
-
- public void setState( String state )
- {
- this.state = state;
- }
-
- public Integer getBalanceInCents()
- {
- return balanceInCents;
- }
-
- public void setBalanceInCents( Integer balanceInCents )
- {
- this.balanceInCents = balanceInCents;
- }
-
- public Integer getTotalRevenueInCents()
- {
- return totalRevenueInCents;
- }
-
- public void setTotalRevenueInCents( Integer totalRevenueInCents )
- {
- this.totalRevenueInCents = totalRevenueInCents;
- }
-
- public Integer getProductPriceInCents()
- {
- return productPriceInCents;
- }
-
- public void setProductPriceInCents( Integer productPriceInCents )
- {
- this.productPriceInCents = productPriceInCents;
- }
-
- public Integer getProductVersionNumber()
- {
- return productVersionNumber;
- }
-
- public void setProductVersionNumber( Integer productVersionNumber )
- {
- this.productVersionNumber = productVersionNumber;
- }
-
- public Date getCurrentPeriodEndsAt()
- {
- return currentPeriodEndsAt;
- }
-
- public void setCurrentPeriodEndsAt( Date currentPeriodEndsAt )
- {
- this.currentPeriodEndsAt = currentPeriodEndsAt;
- }
-
- public Date getTrialStartedAt()
- {
- return trialStartedAt;
- }
-
- public void setTrialStartedAt( Date trialStartedAt )
- {
- this.trialStartedAt = trialStartedAt;
- }
-
- public Date getTrialEndedAt()
- {
- return trialEndedAt;
- }
-
- public void setTrialEndedAt( Date trialEndedAt )
- {
- this.trialEndedAt = trialEndedAt;
- }
-
- public Date getActivatedAt()
- {
- return activatedAt;
- }
-
- public void setActivatedAt( Date activatedAt )
- {
- this.activatedAt = activatedAt;
- }
-
- public Date getExpiresAt()
- {
- return expiresAt;
- }
-
- public void setExpiresAt( Date expiresAt )
- {
- this.expiresAt = expiresAt;
- }
-
- public Date getCreatedAt()
- {
- return createdAt;
- }
-
- public void setCreatedAt( Date createdAt )
- {
- this.createdAt = createdAt;
- }
-
- public Date getUpdatedAt()
- {
- return updatedAt;
- }
-
- public void setUpdatedAt( Date updatedAt )
- {
- this.updatedAt = updatedAt;
- }
-
- public String getCancellationMessage()
- {
- return cancellationMessage;
- }
-
- public void setCancellationMessage( String cancellationMessage )
- {
- this.cancellationMessage = cancellationMessage;
- }
-
- public String getCancellationMethod()
- {
- return cancellationMethod;
- }
-
- public void setCancellationMethod( String cancellationMethod )
- {
- this.cancellationMethod = cancellationMethod;
- }
-
- public Boolean getCancelAtEndOfPeriod()
- {
- return cancelAtEndOfPeriod;
- }
-
- public void setCancelAtEndOfPeriod( Boolean cancelAtEndOfPeriod )
- {
- this.cancelAtEndOfPeriod = cancelAtEndOfPeriod;
- }
-
- public Date getCanceledAt()
- {
- return canceledAt;
- }
-
- public void setCanceledAt( Date canceledAt )
- {
- this.canceledAt = canceledAt;
- }
-
- public Date getCurrentPeriodStartedAt()
- {
- return currentPeriodStartedAt;
- }
-
- public void setCurrentPeriodStartedAt( Date currentPeriodStartedAt )
- {
- this.currentPeriodStartedAt = currentPeriodStartedAt;
- }
-
- public String getPreviousState()
- {
- return previousState;
- }
-
- public void setPreviousState( String previousState )
- {
- this.previousState = previousState;
- }
-
- public Integer getSignupPaymentId()
- {
- return signupPaymentId;
- }
-
- public void setSignupPaymentId( Integer signupPaymentId )
- {
- this.signupPaymentId = signupPaymentId;
- }
-
- public String getSignupRevenue()
- {
- return signupRevenue;
- }
-
- public void setSignupRevenue( String signupRevenue )
- {
- this.signupRevenue = signupRevenue;
- }
-
- public Date getDelayedCancelAt()
- {
- return delayedCancelAt;
- }
-
- public void setDelayedCancelAt( Date delayedCancelAt )
- {
- this.delayedCancelAt = delayedCancelAt;
- }
-
- public String getCouponCode()
- {
- return couponCode;
- }
-
- public void setCouponCode( String couponCode )
- {
- this.couponCode = couponCode;
- }
-
- public String getPaymentCollectionMethod()
- {
- return paymentCollectionMethod;
- }
-
- public void setPaymentCollectionMethod( String paymentCollectionMethod )
- {
- this.paymentCollectionMethod = paymentCollectionMethod;
- }
-
- public String getSnapDay()
- {
- return snapDay;
- }
-
- public void setSnapDay( String snapDay )
- {
- this.snapDay = snapDay;
- }
-
- public String getReasonCode()
- {
- return reasonCode;
- }
-
- public void setReasonCode( String reasonCode )
- {
- this.reasonCode = reasonCode;
- }
-
- public Customer getCustomer()
- {
- return customer;
- }
-
- public void setCustomer( Customer customer )
- {
- this.customer = customer;
- }
-
- public Product getProduct()
- {
- return product;
- }
-
- public void setProduct( Product product )
- {
- this.product = product;
- }
-
- public CreditCard getCreditCard()
- {
- return creditCard;
- }
-
- public void setCreditCard( CreditCard creditCard )
- {
- this.creditCard = creditCard;
- }
-
- public String getPaymentType()
- {
- return paymentType;
- }
-
- public void setPaymentType( String paymentType )
- {
- this.paymentType = paymentType;
- }
-
- public String getReferralCode()
- {
- return referralCode;
- }
-
- public void setReferralCode( String referralCode )
- {
- this.referralCode = referralCode;
- }
-
- public String getNextProductId()
- {
- return nextProductId;
- }
-
- public void setNextProductId( String nextProductId )
- {
- this.nextProductId = nextProductId;
- }
-
- public Integer getCouponUseCount()
- {
- return couponUseCount;
- }
-
- public void setCouponUseCount( Integer couponUseCount )
- {
- this.couponUseCount = couponUseCount;
- }
-
- public Integer getCouponUsesAllowed()
- {
- return couponUsesAllowed;
- }
-
- public void setCouponUsesAllowed( Integer couponUsesAllowed )
- {
- this.couponUsesAllowed = couponUsesAllowed;
- }
-
- public String getProductId()
- {
- return productId;
- }
-
- public void setProductId( String productId )
- {
- this.productId = productId;
- }
-
- public String getCustomerId()
- {
- return customerId;
- }
-
- public void setCustomerId( String customerId )
- {
- this.customerId = customerId;
- }
-
- public String getCustomerReference()
- {
- return customerReference;
- }
-
- public void setCustomerReference( String customerReference )
- {
- this.customerReference = customerReference;
- }
-
- public String getProductHandle()
- {
- return productHandle;
- }
-
- public void setProductHandle( String productHandle )
- {
- this.productHandle = productHandle;
- }
-
- public Customer getCustomerAttributes()
- {
- return customerAttributes;
- }
-
- public void setCustomerAttributes( Customer customerAttributes )
- {
- this.customerAttributes = customerAttributes;
- }
-
- public boolean isProductChangeDelayed()
- {
- return productChangeDelayed;
- }
-
- public void setProductChangeDelayed( boolean productChangeDelayed )
- {
- this.productChangeDelayed = productChangeDelayed;
- }
-
- public Map getMetafields()
- {
- return metafields;
- }
-
- public void setMetafields( Map metafields )
- {
- this.metafields = metafields;
- }
-
- public List getComponents()
- {
- return components;
- }
-
- public void setComponents( List components )
- {
- this.components = components;
- }
-
- public String getPaymentProfileId()
- {
- return paymentProfileId;
- }
-
- public void setPaymentProfileId( String paymentProfileId )
- {
- this.paymentProfileId = paymentProfileId;
- }
-
- public ZonedDateTime getNextBillingAt()
- {
- return nextBillingAt;
- }
-
- public void setNextBillingAt( ZonedDateTime nextBillingAt )
- {
- this.nextBillingAt = nextBillingAt;
- }
-
- public ZonedDateTime getNextAssessmentAt()
- {
- return nextAssessmentAt;
- }
-
- public void setNextAssessmentAt( ZonedDateTime nextAssessmentAt )
- {
- this.nextAssessmentAt = nextAssessmentAt;
- }
-
- public String getReference()
- {
- return reference;
- }
-
- public void setReference( String reference )
- {
- this.reference = reference;
- }
-
- @Override
- public String toString()
- {
- return "Subscription{" +
- "id='" + id + '\'' +
- ", state='" + state + '\'' +
- ", balanceInCents=" + balanceInCents +
- ", totalRevenueInCents=" + totalRevenueInCents +
- ", productPriceInCents=" + productPriceInCents +
- ", productVersionNumber=" + productVersionNumber +
- ", currentPeriodEndsAt=" + currentPeriodEndsAt +
- ", nextAssessmentAt=" + nextAssessmentAt +
- ", nextBillingAt=" + nextBillingAt +
- ", trialStartedAt=" + trialStartedAt +
- ", trialEndedAt=" + trialEndedAt +
- ", activatedAt=" + activatedAt +
- ", expiresAt=" + expiresAt +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", cancellationMessage='" + cancellationMessage + '\'' +
- ", cancellationMethod='" + cancellationMethod + '\'' +
- ", cancelAtEndOfPeriod=" + cancelAtEndOfPeriod +
- ", canceledAt=" + canceledAt +
- ", currentPeriodStartedAt=" + currentPeriodStartedAt +
- ", customerAttributes=" + customerAttributes +
- ", customerId='" + customerId + '\'' +
- ", customerReference='" + customerReference + '\'' +
- ", productChangeDelayed=" + productChangeDelayed +
- ", previousState='" + previousState + '\'' +
- ", productHandle='" + productHandle + '\'' +
- ", productId='" + productId + '\'' +
- ", signupPaymentId=" + signupPaymentId +
- ", signupRevenue='" + signupRevenue + '\'' +
- ", delayedCancelAt=" + delayedCancelAt +
- ", couponCode='" + couponCode + '\'' +
- ", paymentCollectionMethod='" + paymentCollectionMethod + '\'' +
- ", paymentProfileId='" + paymentProfileId + '\'' +
- ", snapDay='" + snapDay + '\'' +
- ", reasonCode='" + reasonCode + '\'' +
- ", customer=" + customer +
- ", product=" + product +
- ", creditCard=" + creditCard +
- ", paymentType='" + paymentType + '\'' +
- ", referralCode='" + referralCode + '\'' +
- ", reference='" + reference + '\'' +
- ", nextProductId='" + nextProductId + '\'' +
- ", couponUseCount=" + couponUseCount +
- ", couponUsesAllowed=" + couponUsesAllowed +
- ", components=" + components +
- ", metafields=" + metafields +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/SubscriptionCharge.java b/src/main/java/com/chargify/model/SubscriptionCharge.java
new file mode 100644
index 0000000..c105327
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionCharge.java
@@ -0,0 +1,26 @@
+package com.chargify.model;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+
+@NoArgsConstructor
+@Data
+public class SubscriptionCharge implements Serializable
+{
+ private Double amount;
+ private Long amountInCents;
+ private String memo;
+ private String periodRangeStart;
+ private String periodRangeEnd;
+ private Boolean delayCapture;
+ private Boolean accrueOnFailure = false;
+
+ public SubscriptionCharge( Long amountInCents, String memo )
+ {
+ this.amountInCents = amountInCents;
+ this.memo = memo;
+ }
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionChargePayload.java b/src/main/java/com/chargify/model/SubscriptionChargePayload.java
new file mode 100644
index 0000000..6f180e9
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionChargePayload.java
@@ -0,0 +1,47 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@NoArgsConstructor
+@Data
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class SubscriptionChargePayload implements Serializable
+{
+ private String amount;
+ @JsonProperty( "amount_in_cents" )
+ private String amountInCents;
+ private String memo;
+ @JsonProperty( "period_range_start" )
+ private String periodRangeStart;
+ @JsonProperty( "period_range_end" )
+ private String periodRangeEnd;
+ @JsonProperty( "delay_capture" )
+ private String delayCapture;
+ @JsonProperty( "accrue_on_failure" )
+ private String accrueOnFailure = "true";
+
+ public static SubscriptionChargePayload from( SubscriptionCharge subscriptionCharge )
+ {
+ SubscriptionChargePayload payload = new SubscriptionChargePayload();
+ if( subscriptionCharge.getAmount() != null )
+ payload.setAmount( String.valueOf( subscriptionCharge.getAmount() ) );
+ if( subscriptionCharge.getAmountInCents() != null )
+ payload.setAmountInCents( String.valueOf( subscriptionCharge.getAmountInCents() ) );
+ payload.setMemo( String.valueOf( subscriptionCharge.getMemo() ) );
+ payload.setPeriodRangeStart( subscriptionCharge.getPeriodRangeStart() );
+ payload.setPeriodRangeEnd( subscriptionCharge.getPeriodRangeEnd() );
+ if( subscriptionCharge.getDelayCapture() != null )
+ payload.setDelayCapture( String.valueOf( subscriptionCharge.getDelayCapture() ) );
+ if( subscriptionCharge.getAccrueOnFailure() != null )
+ payload.setAccrueOnFailure( String.valueOf( subscriptionCharge.getAccrueOnFailure() ) );
+
+ return payload;
+ }
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionChargeResult.java b/src/main/java/com/chargify/model/SubscriptionChargeResult.java
new file mode 100644
index 0000000..2d05a13
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionChargeResult.java
@@ -0,0 +1,48 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class SubscriptionChargeResult implements Serializable
+{
+ private Integer id;
+ @JsonProperty( "subscription_id" )
+ private Integer subscriptionId;
+ private String type;
+ private String kind;
+ @JsonProperty( "transaction_type" )
+ private String transactionType;
+ private Boolean success;
+ @JsonProperty( "amount_in_cents" )
+ private Integer amountInCents;
+ private String memo;
+ @JsonProperty( "created_at" )
+ private String createdAt;
+ @JsonProperty( "starting_balance_in_cents" )
+ private Long startingBalanceInCents;
+ @JsonProperty( "ending_balance_in_cents" )
+ private Long endingBalanceInCents;
+ @JsonProperty( "product_id" )
+ private Integer productId;
+ @JsonProperty( "statement_id" )
+ private Integer statementId;
+ @JsonProperty( "customer_id" )
+ private Integer customerId;
+ @JsonProperty( "period_range_start" )
+ private String periodRangeStart;
+ @JsonProperty( "period_range_end" )
+ private String periodRangeEnd;
+
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionComponent.java b/src/main/java/com/chargify/model/SubscriptionComponent.java
index 7839b88..f9c4e97 100644
--- a/src/main/java/com/chargify/model/SubscriptionComponent.java
+++ b/src/main/java/com/chargify/model/SubscriptionComponent.java
@@ -20,14 +20,16 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import java.io.Serializable;
+@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
public class SubscriptionComponent implements Serializable
{
@JsonProperty( "component_id" )
- private String componentId;
+ private Integer componentId;
@JsonProperty( "subscription_id" )
private String subscriptionId;
@@ -51,93 +53,9 @@ public class SubscriptionComponent implements Serializable
@JsonProperty( "allocated_quantity" )
private Integer allocatedQuantity;
- public String getComponentId()
- {
- return componentId;
- }
+ @JsonProperty( "price_point_id" )
+ private Integer pricePointId;
- public void setComponentId( String componentId )
- {
- this.componentId = componentId;
- }
-
- public String getSubscriptionId()
- {
- return subscriptionId;
- }
-
- public void setSubscriptionId( String subscriptionId )
- {
- this.subscriptionId = subscriptionId;
- }
-
- public Integer getUnitBalance()
- {
- return unitBalance;
- }
-
- public void setUnitBalance( Integer unitBalance )
- {
- this.unitBalance = unitBalance;
- }
-
- public String getPricingScheme()
- {
- return pricingScheme;
- }
-
- public void setPricingScheme( String pricingScheme )
- {
- this.pricingScheme = pricingScheme;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public ComponentKind getKind()
- {
- return kind;
- }
-
- public void setKind( ComponentKind kind )
- {
- this.kind = kind;
- }
-
- public String getUnitName()
- {
- return unitName;
- }
-
- public void setUnitName( String unitName )
- {
- this.unitName = unitName;
- }
-
- public Boolean getEnabled()
- {
- return enabled;
- }
-
- public void setEnabled( Boolean enabled )
- {
- this.enabled = enabled;
- }
-
- public Integer getAllocatedQuantity()
- {
- return allocatedQuantity;
- }
-
- public void setAllocatedQuantity( Integer allocatedQuantity )
- {
- this.allocatedQuantity = allocatedQuantity;
- }
+ @JsonProperty( "price_point_handle" )
+ private String pricePointHandle;
}
diff --git a/src/main/java/com/chargify/model/SubscriptionMetadata.java b/src/main/java/com/chargify/model/SubscriptionMetadata.java
index 603ae22..38a4d18 100644
--- a/src/main/java/com/chargify/model/SubscriptionMetadata.java
+++ b/src/main/java/com/chargify/model/SubscriptionMetadata.java
@@ -3,12 +3,17 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import java.io.Serializable;
import java.util.Arrays;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Getter @Setter
public class SubscriptionMetadata implements Serializable
{
@JsonProperty( "total_count" )
@@ -25,56 +30,6 @@ public class SubscriptionMetadata implements Serializable
private Metadata[] metadata;
- public int getTotalCount()
- {
- return totalCount;
- }
-
- public void setTotalCount( int totalCount )
- {
- this.totalCount = totalCount;
- }
-
- public int getCurrentPage()
- {
- return currentPage;
- }
-
- public void setCurrentPage( int currentPage )
- {
- this.currentPage = currentPage;
- }
-
- public int getTotalPages()
- {
- return totalPages;
- }
-
- public void setTotalPages( int totalPages )
- {
- this.totalPages = totalPages;
- }
-
- public int getPerPage()
- {
- return perPage;
- }
-
- public void setPerPage( int perPage )
- {
- this.perPage = perPage;
- }
-
- public Metadata[] getMetadata()
- {
- return metadata;
- }
-
- public void setMetadata( Metadata[] metadata )
- {
- this.metadata = metadata;
- }
-
@Override
public String toString()
{
diff --git a/src/main/java/com/chargify/model/SubscriptionProduct.java b/src/main/java/com/chargify/model/SubscriptionProduct.java
new file mode 100644
index 0000000..cb02a5a
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionProduct.java
@@ -0,0 +1,36 @@
+package com.chargify.model;
+
+import com.chargify.model.product.BaseProduct;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@ToString
+@EqualsAndHashCode( callSuper = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class SubscriptionProduct extends BaseProduct implements Serializable
+{
+ @JsonProperty( "archived_at" )
+ private Date archivedAt;
+ @JsonProperty( "product_price_point_handle" )
+ private String productPricePointHandle;
+
+ @JsonCreator
+ public SubscriptionProduct( @JsonProperty( "name" ) final String name,
+ @JsonProperty( "price" ) final int priceInCents,
+ @JsonProperty( "interval" ) final int recurringInterval,
+ @JsonProperty( "interval_unit" ) final PricePointIntervalUnit intervalUnit )
+ {
+ this.name = name;
+ this.priceInCents = priceInCents;
+ this.recurringInterval = recurringInterval;
+ this.intervalUnit = intervalUnit;
+ }
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionProductUpdate.java b/src/main/java/com/chargify/model/SubscriptionProductUpdate.java
new file mode 100644
index 0000000..2a7181f
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionProductUpdate.java
@@ -0,0 +1,29 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor( access = AccessLevel.PRIVATE )
+@Data
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class SubscriptionProductUpdate implements Serializable
+{
+
+ @JsonProperty( "product_handle" )
+ private String productHandle;
+
+ @JsonProperty( "product_change_delayed" )
+ private boolean changeDelayed;
+
+ @JsonProperty( "product_price_point_handle" )
+ private String pricePointHandle;
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionReactivationData.java b/src/main/java/com/chargify/model/SubscriptionReactivationData.java
new file mode 100644
index 0000000..7c119fa
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionReactivationData.java
@@ -0,0 +1,17 @@
+package com.chargify.model;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@NoArgsConstructor
+@Data
+public class SubscriptionReactivationData
+{
+ private String subscriptionId;
+ private boolean includeTrial = false;
+ private boolean preserveBalance = false;
+ private String couponCode;
+ private Boolean resume;
+ private boolean forgiveBalance = false;
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionStatement.java b/src/main/java/com/chargify/model/SubscriptionStatement.java
new file mode 100644
index 0000000..1d39c42
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionStatement.java
@@ -0,0 +1,73 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@JsonIgnoreProperties( ignoreUnknown = true )
+@Data
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class SubscriptionStatement implements Serializable
+{
+ @JsonProperty( "id" )
+ private Integer id;
+ @JsonProperty( "created_at" )
+ private LocalDateTime closedAt;
+ @JsonProperty( "opened_at" )
+ private LocalDateTime openedAt;
+ @JsonProperty( "settled_at" )
+ private LocalDateTime settledAt;
+ @JsonProperty( "created_at" )
+ private LocalDateTime createdAt;
+ @JsonProperty( "updated_at" )
+ private LocalDateTime updatedAt;
+ @JsonProperty( "customer_first_name" )
+ private String customerFirstName;
+ @JsonProperty( "customer_last_name" )
+ private String customerLastName;
+ @JsonProperty( "customer_billing_address" )
+ private String customerBillingAddress;
+ @JsonProperty( "customer_billing_address_2" )
+ private String customerBillingAddress2;
+ @JsonProperty( "customer_billing_city" )
+ private String customerBillingCity;
+ @JsonProperty( "customer_billing_country" )
+ private String customerBillingCountry;
+ @JsonProperty( "customer_billing_state" )
+ private String customerBillingState;
+ @JsonProperty( "customer_billing_zip" )
+ private String customerBillingZip;
+ @JsonProperty( "customer_organization" )
+ private String customerOrganization;
+ @JsonProperty( "customer_shipping_address" )
+ private String customerShippingAddress;
+ @JsonProperty( "customer_shipping_address_2" )
+ private String customerShippingAddress2;
+ @JsonProperty( "customer_shipping_city" )
+ private String customerShippingCity;
+ @JsonProperty( "customer_shipping_country" )
+ private String customerShippingCountry;
+ @JsonProperty( "customer_shipping_state" )
+ private String customerShippingState;
+ @JsonProperty( "customer_shipping_zip" )
+ private String customerShippingZip;
+ @JsonProperty( "starting_balance_in_cents" )
+ private Long startingBalanceInCents;
+ @JsonProperty( "ending_balance_in_cents" )
+ private Long endingBalanceInCents;
+ @JsonProperty( "memo" )
+ private String memo;
+ @JsonProperty( "subscription_id" )
+ private Integer subscriptionId;
+ @JsonProperty( "total_in_cents" )
+ private Integer totalInCents;
+ @JsonDeserialize(contentAs = Transaction.class)
+ private List transactions;
+
+}
diff --git a/src/main/java/com/chargify/model/SubscriptionStates.java b/src/main/java/com/chargify/model/SubscriptionStates.java
new file mode 100644
index 0000000..a3aceda
--- /dev/null
+++ b/src/main/java/com/chargify/model/SubscriptionStates.java
@@ -0,0 +1,20 @@
+package com.chargify.model;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+
+@NoArgsConstructor( access = AccessLevel.PRIVATE )
+public final class SubscriptionStates
+{
+ public static final String ACTIVE = "active";
+ public static final String CANCELED = "canceled";
+ public static final String EXPIRED = "expired";
+ public static final String ON_HOLD = "on_hold";
+ public static final String PAST_DUE = "past_due";
+ public static final String SOFT_FAILURE = "soft_failure";
+ public static final String TRAILING = "trialing";
+ public static final String TRIAL_ENDED = "trial_ended";
+ public static final String UNPAID = "unpaid";
+ public static final String SUSPENDED = "suspended";
+}
diff --git a/src/main/java/com/chargify/model/Transaction.java b/src/main/java/com/chargify/model/Transaction.java
index d249469..7599784 100644
--- a/src/main/java/com/chargify/model/Transaction.java
+++ b/src/main/java/com/chargify/model/Transaction.java
@@ -3,207 +3,42 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
-import java.util.Date;
+import java.time.ZonedDateTime;
+@Data
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
public class Transaction
{
+ private Integer id;
+ @JsonProperty( "subscription_id" )
+ private String subscriptionId;
+ private String type;
+ private String kind;
+ @JsonProperty( "transaction_type" )
+ private String transactionType;
+ private boolean success;
@JsonProperty( "amount_in_cents" )
private int amountInCents;
-
+ private String memo;
@JsonProperty( "created_at" )
- private Date createdAt;
-
+ private ZonedDateTime createdAt;
@JsonProperty( "starting_balance_in_cents" )
- private int startingBalanceInCents;
-
+ private long startingBalanceInCents;
@JsonProperty( "ending_balance_in_cents" )
- private int endingBalanceInCents;
-
- private String id;
-
- private String kind;
-
- private String memo;
-
+ private long endingBalanceInCents;
+ @JsonProperty( "gateway_used" )
+ private String gatewayUsed;
+ @JsonProperty( "gateway_transaction_id" )
+ private String gatewayTransactionId;
+ @JsonProperty( "gateway_order_id" )
+ private String gatewayOrderId;
@JsonProperty( "payment_id" )
private String paymentId;
-
@JsonProperty( "product_id" )
private String productId;
-
- @JsonProperty( "subscription_id" )
- private String subscriptionId;
-
- private boolean success;
-
- private String type;
-
- @JsonProperty( "transaction_type" )
- private String transactionType;
-
- @JsonProperty( "gateway_transaction_id" )
- private String gatewayTransactionId;
-
- public int getAmountInCents()
- {
- return amountInCents;
- }
-
- public void setAmountInCents( int amountInCents )
- {
- this.amountInCents = amountInCents;
- }
-
- public Date getCreatedAt()
- {
- return createdAt;
- }
-
- public void setCreatedAt( Date createdAt )
- {
- this.createdAt = createdAt;
- }
-
- public int getEndingBalanceInCents()
- {
- return endingBalanceInCents;
- }
-
- public void setEndingBalanceInCents( int endingBalanceInCents )
- {
- this.endingBalanceInCents = endingBalanceInCents;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getKind()
- {
- return kind;
- }
-
- public void setKind( String kind )
- {
- this.kind = kind;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- public String getPaymentId()
- {
- return paymentId;
- }
-
- public void setPaymentId( String paymentId )
- {
- this.paymentId = paymentId;
- }
-
- public String getProductId()
- {
- return productId;
- }
-
- public void setProductId( String productId )
- {
- this.productId = productId;
- }
-
- public int getStartingBalanceInCents()
- {
- return startingBalanceInCents;
- }
-
- public void setStartingBalanceInCents( int startingBalanceInCents )
- {
- this.startingBalanceInCents = startingBalanceInCents;
- }
-
- public String getSubscriptionId()
- {
- return subscriptionId;
- }
-
- public void setSubscriptionId( String subscriptionId )
- {
- this.subscriptionId = subscriptionId;
- }
-
- public boolean getSuccess()
- {
- return success;
- }
-
- public void setSuccess( boolean success )
- {
- this.success = success;
- }
-
- public String getType()
- {
- return type;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- public String getTransactionType()
- {
- return transactionType;
- }
-
- public void setTransactionType( String transactionType )
- {
- this.transactionType = transactionType;
- }
-
- public String getGatewayTransactionId()
- {
- return gatewayTransactionId;
- }
-
- public void setGatewayTransactionId( String gatewayTransactionId )
- {
- this.gatewayTransactionId = gatewayTransactionId;
- }
-
- @Override
- public String toString()
- {
- return "Transaction{" +
- "amountInCents=" + amountInCents +
- ", createdAt=" + createdAt +
- ", startingBalanceInCents=" + startingBalanceInCents +
- ", endingBalanceInCents=" + endingBalanceInCents +
- ", id='" + id + '\'' +
- ", kind='" + kind + '\'' +
- ", memo='" + memo + '\'' +
- ", paymentId='" + paymentId + '\'' +
- ", productId='" + productId + '\'' +
- ", subscriptionId='" + subscriptionId + '\'' +
- ", success=" + success +
- ", type='" + type + '\'' +
- ", transactionType='" + transactionType + '\'' +
- ", gatewayTransactionId='" + gatewayTransactionId + '\'' + '}';
- }
+ @JsonProperty( "component_id" )
+ private String componentId;
}
diff --git a/src/main/java/com/chargify/model/TransactionsKinds.java b/src/main/java/com/chargify/model/TransactionsKinds.java
new file mode 100644
index 0000000..4e3332e
--- /dev/null
+++ b/src/main/java/com/chargify/model/TransactionsKinds.java
@@ -0,0 +1,14 @@
+package com.chargify.model;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor( access = AccessLevel.PRIVATE )
+public final class TransactionsKinds
+{
+ public static final String CHARGE = "charge";
+ public static final String CREDIT = "credit";
+ public static final String ADJUSTMENT = "adjustment";
+ public static final String PAYMENT = "payment";
+ public static final String REFUND = "refund";
+}
diff --git a/src/main/java/com/chargify/model/UpdatePaymentProfile.java b/src/main/java/com/chargify/model/UpdatePaymentProfile.java
new file mode 100644
index 0000000..db42326
--- /dev/null
+++ b/src/main/java/com/chargify/model/UpdatePaymentProfile.java
@@ -0,0 +1,31 @@
+/*
+ * ********************************************************************************************************************
+ *
+ * BACKENDLESS.COM CONFIDENTIAL
+ *
+ * ********************************************************************************************************************
+ *
+ * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
+ *
+ * NOTICE: Â All information contained herein is, and remains the property of Backendless.com and its suppliers,
+ * if any. Â The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
+ * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
+ * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
+ * unless prior written permission is obtained from Backendless.com.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter @Setter
+@JsonIgnoreProperties( ignoreUnknown = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class UpdatePaymentProfile extends BaseUpsertPaymentProfile
+{
+}
diff --git a/src/main/java/com/chargify/model/UpdateSubscription.java b/src/main/java/com/chargify/model/UpdateSubscription.java
new file mode 100644
index 0000000..d03d1ff
--- /dev/null
+++ b/src/main/java/com/chargify/model/UpdateSubscription.java
@@ -0,0 +1,27 @@
+package com.chargify.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Builder;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Builder
+@Data
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class UpdateSubscription implements Serializable
+{
+
+ @JsonProperty( "product_handle" )
+ private String productHandle;
+
+ @JsonProperty( "product_id" )
+ private String productId;
+
+ @JsonProperty( "reference" )
+ private String reference;
+
+ @JsonProperty( "next_billing_at" )
+ private String nextBillingAt;
+}
diff --git a/src/main/java/com/chargify/model/Usage.java b/src/main/java/com/chargify/model/Usage.java
index 3b6f0c4..5926d2a 100644
--- a/src/main/java/com/chargify/model/Usage.java
+++ b/src/main/java/com/chargify/model/Usage.java
@@ -3,11 +3,15 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.util.Date;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class Usage
{
@JsonProperty( "created_at" )
@@ -21,66 +25,4 @@ public class Usage
@JsonProperty( "price_point_id" )
private Integer pricePointId;
-
- public Date getCreatedAt()
- {
- return createdAt;
- }
-
- public void setCreatedAt( Date createdAt )
- {
- this.createdAt = createdAt;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getMemo()
- {
- return memo;
- }
-
- public void setMemo( String memo )
- {
- this.memo = memo;
- }
-
- public Integer getQuantity()
- {
- return quantity;
- }
-
- public void setQuantity( Integer quantity )
- {
- this.quantity = quantity;
- }
-
- public Integer getPricePointId()
- {
- return pricePointId;
- }
-
- public void setPricePointId( Integer pricePointId )
- {
- this.pricePointId = pricePointId;
- }
-
- @Override
- public String toString()
- {
- return "Usage{" +
- "createdAt=" + createdAt +
- ", id='" + id + '\'' +
- ", memo='" + memo + '\'' +
- ", quantity=" + quantity +
- ", pricePointId=" + pricePointId +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/event/Site.java b/src/main/java/com/chargify/model/event/Site.java
new file mode 100644
index 0000000..094ae03
--- /dev/null
+++ b/src/main/java/com/chargify/model/event/Site.java
@@ -0,0 +1,16 @@
+package com.chargify.model.event;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties( ignoreUnknown = true )
+public class Site
+{
+ private Long id;
+ private String subdomain;
+}
diff --git a/src/main/java/com/chargify/model/event/SubscriptionCardUpdate.java b/src/main/java/com/chargify/model/event/SubscriptionCardUpdate.java
new file mode 100644
index 0000000..cbb67b0
--- /dev/null
+++ b/src/main/java/com/chargify/model/event/SubscriptionCardUpdate.java
@@ -0,0 +1,91 @@
+package com.chargify.model.event;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties( ignoreUnknown = true )
+public class SubscriptionCardUpdate
+{
+ @JsonProperty( "event_id" )
+ private String eventId;
+ private Site site;
+ private Subscription subscription;
+ private Customer customer;
+ @JsonProperty( "previous_payment_profile" )
+ private PaymentProfile previousPaymentProfile;
+ @JsonProperty( "updated_payment_profile" )
+ private PaymentProfile updatedPaymentProfile;
+
+ @Data
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @JsonIgnoreProperties( ignoreUnknown = true )
+ public static class Subscription
+ {
+ private Long id;
+ private String state;
+ @JsonProperty( "balance_in_cents" )
+ private Long balanceInCents;
+ }
+
+ @Data
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @JsonIgnoreProperties( ignoreUnknown = true )
+ public static class Customer
+ {
+ private Long id;
+ @JsonProperty( "first_name" )
+ private String firstName;
+ @JsonProperty( "last_name" )
+ private String lastName;
+ private String reference;
+ private String organization;
+ private String email;
+ }
+
+ @Data
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @JsonIgnoreProperties( ignoreUnknown = true )
+ public static class PaymentProfile
+ {
+ private Long id;
+ @JsonProperty( "first_name" )
+ private String firstName;
+ @JsonProperty( "last_name" )
+ private String lastName;
+ @JsonProperty( "masked_card_number" )
+ private String maskedCardNumber;
+ @JsonProperty( "card_type" )
+ private String cardType;
+ @JsonProperty( "expiration_month" )
+ private Integer expirationMonth;
+ @JsonProperty( "expiration_year" )
+ private Integer expirationYear;
+ @JsonProperty( "current_vault" )
+ private String currentVault;
+ @JsonProperty( "vault_token" )
+ private String vaultToken;
+ @JsonProperty( "customer_vault_token" )
+ private String customerVaultToken;
+ @JsonProperty( "billing_address" )
+ private String billingAddress;
+ @JsonProperty( "billing_address_2" )
+ private String billingAddress2;
+ @JsonProperty( "billing_city" )
+ private String billingCity;
+ @JsonProperty( "billing_state" )
+ private String billingState;
+ @JsonProperty( "billing_zip" )
+ private String billingZip;
+ @JsonProperty( "billing_country" )
+ private String billingCountry;
+ }
+}
diff --git a/src/main/java/com/chargify/model/product/BaseProduct.java b/src/main/java/com/chargify/model/product/BaseProduct.java
new file mode 100644
index 0000000..492c73f
--- /dev/null
+++ b/src/main/java/com/chargify/model/product/BaseProduct.java
@@ -0,0 +1,99 @@
+package com.chargify.model.product;
+
+import com.chargify.model.PricePointIntervalUnit;
+import com.chargify.model.PublicSignupPage;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@NoArgsConstructor
+@Data
+@ToString
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public abstract class BaseProduct implements Serializable
+{
+ protected String id;
+
+ protected String name;
+
+ protected String handle;
+
+ protected String description;
+
+ @JsonProperty( "accounting_code" )
+ protected String accountingCode;
+
+ @JsonProperty( "request_credit_card" )
+ protected Boolean requestCreditCard;
+
+ @JsonProperty( "expiration_interval" )
+ protected String expirationInterval;
+
+ @JsonProperty( "expiration_interval_unit" )
+ protected String expirationIntervalUnit;
+
+ @JsonProperty( "created_at" )
+ protected Date createdAt;
+
+ @JsonProperty( "updated_at" )
+ protected Date updatedAt;
+
+ @JsonProperty( "price_in_cents" )
+ protected int priceInCents;
+
+ @JsonProperty( "interval" )
+ protected int recurringInterval;
+
+ @JsonProperty( "interval_unit" )
+ protected PricePointIntervalUnit intervalUnit;
+
+ @JsonProperty( "initial_charge_in_cents" )
+ protected String initialChargeInCents;
+
+ @JsonProperty( "trial_price_in_cents" )
+ protected Integer trialPriceInCents;
+
+ @JsonProperty( "trial_interval" )
+ protected Integer trialInterval;
+
+ @JsonProperty( "trial_interval_unit" )
+ protected String trialIntervalUnit;
+
+ @JsonProperty( "require_credit_card" )
+ protected Boolean requireCreditCard;
+
+ @JsonProperty( "return_params" )
+ protected String returnParams;
+
+ protected Boolean taxable;
+
+ @JsonProperty( "update_return_url" )
+ protected String updateReturnUrl;
+
+ @JsonProperty( "tax_code" )
+ protected String taxCode;
+
+ @JsonProperty( "initial_charge_after_trial" )
+ protected Boolean initialChargeAfterTrial;
+
+ @JsonProperty( "version_number" )
+ protected Integer versionNumber;
+
+ @JsonProperty( "update_return_params" )
+ protected String updateReturnParams;
+
+ @JsonProperty( "product_family" )
+ protected ProductFamily productFamily;
+
+ @JsonProperty( "public_signup_pages" )
+ protected List publicSignupPages;
+
+ @JsonProperty( "product_price_point_name" )
+ protected String productPricePointName;
+}
diff --git a/src/main/java/com/chargify/model/product/Product.java b/src/main/java/com/chargify/model/product/Product.java
new file mode 100644
index 0000000..271b26a
--- /dev/null
+++ b/src/main/java/com/chargify/model/product/Product.java
@@ -0,0 +1,39 @@
+package com.chargify.model.product;
+
+import com.chargify.model.PricePointIntervalUnit;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+@Data
+@ToString
+@EqualsAndHashCode( callSuper = true )
+@JsonInclude( JsonInclude.Include.NON_NULL )
+public class Product extends BaseProduct implements Serializable
+{
+ @JsonProperty( "request_billing_address" )
+ private Boolean requestBillingAddress;
+ @JsonProperty( "require_billing_address" )
+ private Boolean requireBillingAddress;
+ @JsonProperty( "require_shipping_address" )
+ private Boolean requireShippingAddress;
+ @JsonProperty( "default_product_price_point_id" )
+ private Integer defaultProductPricePointId;
+
+ @JsonCreator
+ public Product( @JsonProperty( "name" ) final String name,
+ @JsonProperty( "price" ) final int priceInCents,
+ @JsonProperty( "interval" ) final int recurringInterval,
+ @JsonProperty( "interval_unit" ) final PricePointIntervalUnit intervalUnit )
+ {
+ this.name = name;
+ this.priceInCents = priceInCents;
+ this.recurringInterval = recurringInterval;
+ this.intervalUnit = intervalUnit;
+ }
+}
diff --git a/src/main/java/com/chargify/model/ProductComponentItem.java b/src/main/java/com/chargify/model/product/ProductComponentItem.java
similarity index 74%
rename from src/main/java/com/chargify/model/ProductComponentItem.java
rename to src/main/java/com/chargify/model/product/ProductComponentItem.java
index 859a126..8bfcea8 100644
--- a/src/main/java/com/chargify/model/ProductComponentItem.java
+++ b/src/main/java/com/chargify/model/product/ProductComponentItem.java
@@ -16,14 +16,18 @@
* ********************************************************************************************************************
*/
-package com.chargify.model;
+package com.chargify.model.product;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
@JsonIgnoreProperties( ignoreUnknown = true )
@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
public class ProductComponentItem
{
@JsonProperty( "component_id" )
@@ -33,34 +37,4 @@ public class ProductComponentItem
private int allocatedQuantity;
private boolean enabled;
-
- public String getComponentId()
- {
- return componentId;
- }
-
- public void setComponentId( String componentId )
- {
- this.componentId = componentId;
- }
-
- public int getAllocatedQuantity()
- {
- return allocatedQuantity;
- }
-
- public void setAllocatedQuantity( int allocatedQuantity )
- {
- this.allocatedQuantity = allocatedQuantity;
- }
-
- public boolean isEnabled()
- {
- return enabled;
- }
-
- public void setEnabled( boolean enabled )
- {
- this.enabled = enabled;
- }
}
diff --git a/src/main/java/com/chargify/model/product/ProductFamily.java b/src/main/java/com/chargify/model/product/ProductFamily.java
new file mode 100644
index 0000000..ce72bac
--- /dev/null
+++ b/src/main/java/com/chargify/model/product/ProductFamily.java
@@ -0,0 +1,32 @@
+package com.chargify.model.product;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@Data
+public class ProductFamily implements Serializable
+{
+ private String id;
+
+ private String name;
+
+ private String description;
+
+ private String handle;
+
+ @JsonProperty( "accounting_code" )
+ private String accountingCode;
+
+ @JsonCreator
+ public ProductFamily( @JsonProperty( "name" ) String name )
+ {
+ this.name = name;
+ }
+}
diff --git a/src/main/java/com/chargify/model/product/ProductPricePoint.java b/src/main/java/com/chargify/model/product/ProductPricePoint.java
new file mode 100644
index 0000000..48464bc
--- /dev/null
+++ b/src/main/java/com/chargify/model/product/ProductPricePoint.java
@@ -0,0 +1,53 @@
+package com.chargify.model.product;
+
+import com.chargify.model.PricePointIntervalUnit;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@JsonInclude( JsonInclude.Include.NON_NULL )
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public class ProductPricePoint implements Serializable
+{
+ private Integer id;
+ private String name;
+ private String handle;
+ @JsonProperty( "price_in_cents" )
+ private Integer priceInCents;
+ private Integer interval;
+ @JsonProperty( "interval_unit" )
+ private PricePointIntervalUnit intervalUnit;
+ @JsonProperty( "trial_price_in_cents" )
+ private Integer trialPriceInCents;
+ @JsonProperty( "trial_interval" )
+ private Integer trialInterval;
+ @JsonProperty( "trial_interval_unit" )
+ private PricePointIntervalUnit trialIntervalUnit;
+ @JsonProperty( "trial_type" )
+ private String trialType;
+ @JsonProperty( "initial_charge_in_cents" )
+ private Integer initialChargeInCents;
+ @JsonProperty( "initial_charge_after_trial" )
+ private boolean initialChargeAfterTrial = false;
+ @JsonProperty( "expiration_interval" )
+ private Integer expirationInterval;
+ @JsonProperty( "expiration_interval_unit" )
+ private String expirationIntervalUnit;
+ @JsonProperty( "product_id" )
+ private String productId;
+ @JsonProperty( "archived_at" )
+ private String archivedAt;
+ @JsonProperty( "created_at" )
+ private String createdAt;
+ @JsonProperty( "updated_at" )
+ private String updatedAt;
+ @JsonProperty( "use_site_exchange_rate" )
+ private Boolean useSiteExchangeRate;
+
+}
diff --git a/src/main/java/com/chargify/model/wrappers/AdjustmentWrapper.java b/src/main/java/com/chargify/model/wrappers/AdjustmentWrapper.java
new file mode 100644
index 0000000..db769df
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/AdjustmentWrapper.java
@@ -0,0 +1,22 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.Adjustment;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@EqualsAndHashCode
+@ToString
+public final class AdjustmentWrapper
+{
+ private final Adjustment adjustment;
+
+ @JsonCreator
+ public AdjustmentWrapper( @JsonProperty( "adjustment" ) Adjustment wrappedAdjustment )
+ {
+ this.adjustment = wrappedAdjustment;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/AllocationPreviewWrapper.java b/src/main/java/com/chargify/model/wrappers/AllocationPreviewWrapper.java
new file mode 100644
index 0000000..f5c81fd
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/AllocationPreviewWrapper.java
@@ -0,0 +1,22 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.AllocationPreview;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@EqualsAndHashCode
+@ToString
+public final class AllocationPreviewWrapper
+{
+ private final AllocationPreview allocationPreview;
+
+ @JsonCreator
+ public AllocationPreviewWrapper( @JsonProperty( "allocation_preview" ) AllocationPreview allocationPreview )
+ {
+ this.allocationPreview = allocationPreview;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/AllocationWrapper.java b/src/main/java/com/chargify/model/wrappers/AllocationWrapper.java
index f6561a8..63401e9 100644
--- a/src/main/java/com/chargify/model/wrappers/AllocationWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/AllocationWrapper.java
@@ -3,7 +3,13 @@
import com.chargify.model.Allocation;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@EqualsAndHashCode
+@ToString
public final class AllocationWrapper
{
private final Allocation allocation;
@@ -13,9 +19,4 @@ public AllocationWrapper( @JsonProperty( "allocation" ) Allocation wrappedAlloca
{
this.allocation = wrappedAllocation;
}
-
- public Allocation getAllocation()
- {
- return allocation;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/AnyComponentWrapper.java b/src/main/java/com/chargify/model/wrappers/AnyComponentWrapper.java
index 7ed7afb..0b67034 100644
--- a/src/main/java/com/chargify/model/wrappers/AnyComponentWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/AnyComponentWrapper.java
@@ -3,7 +3,13 @@
import com.chargify.model.Component;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@EqualsAndHashCode
+@ToString
public final class AnyComponentWrapper
{
private final Component component;
@@ -13,17 +19,4 @@ public AnyComponentWrapper( @JsonProperty( "component" ) Component wrappedCompon
{
this.component = wrappedComponent;
}
-
- public Component getComponent()
- {
- return component;
- }
-
- @Override
- public String toString()
- {
- return "AnyComponentWrapper{" +
- "component=" + component +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/ComponentPricePointUpdatesWrapper.java b/src/main/java/com/chargify/model/wrappers/ComponentPricePointUpdatesWrapper.java
index 1a7ade9..21c0e90 100644
--- a/src/main/java/com/chargify/model/wrappers/ComponentPricePointUpdatesWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/ComponentPricePointUpdatesWrapper.java
@@ -3,31 +3,29 @@
import com.chargify.model.ComponentPricePointUpdate;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Setter;
import java.util.Arrays;
+import java.util.List;
+@Data
+@Setter( AccessLevel.NONE )
public final class ComponentPricePointUpdatesWrapper
{
- private final ComponentPricePointUpdate[] pricePointUpdates;
+ @JsonProperty( "components" )
+ private final List pricePointUpdates;
@JsonCreator
public ComponentPricePointUpdatesWrapper(
@JsonProperty( "components" ) ComponentPricePointUpdate... pricePointUpdates )
{
- this.pricePointUpdates = pricePointUpdates;
+ this.pricePointUpdates = Arrays.asList( pricePointUpdates );
}
- @JsonProperty( "components" )
- public ComponentPricePointUpdate[] getPricePointUpdates()
+ public ComponentPricePointUpdatesWrapper( List pricePointUpdates )
{
- return pricePointUpdates;
- }
-
- @Override
- public String toString()
- {
- return "ComponentPricePointUpdatesWrapper{" +
- "pricePointUpdates=" + Arrays.toString( pricePointUpdates ) +
- '}';
+ this.pricePointUpdates = pricePointUpdates;
}
}
diff --git a/src/main/java/com/chargify/model/wrappers/ComponentPricePointsWrapper.java b/src/main/java/com/chargify/model/wrappers/ComponentPricePointsWrapper.java
new file mode 100644
index 0000000..1fac0e1
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/ComponentPricePointsWrapper.java
@@ -0,0 +1,24 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.PricePoint;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.util.Set;
+
+@Getter
+@EqualsAndHashCode
+@ToString
+public final class ComponentPricePointsWrapper
+{
+ private final Set pricePoints;
+
+ @JsonCreator
+ public ComponentPricePointsWrapper( @JsonProperty( "price_points" ) Set pricePoints )
+ {
+ this.pricePoints = pricePoints;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/CreateSubscriptionWrapper.java b/src/main/java/com/chargify/model/wrappers/CreateSubscriptionWrapper.java
new file mode 100644
index 0000000..4b7f280
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/CreateSubscriptionWrapper.java
@@ -0,0 +1,22 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.CreateSubscription;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@EqualsAndHashCode
+@ToString
+public final class CreateSubscriptionWrapper
+{
+ private final CreateSubscription subscription;
+
+ @JsonCreator
+ public CreateSubscriptionWrapper( @JsonProperty( "subscription" ) CreateSubscription wrappedSubscription )
+ {
+ this.subscription = wrappedSubscription;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/CustomerWrapper.java b/src/main/java/com/chargify/model/wrappers/CustomerWrapper.java
index a5ebf8a..0d8be38 100644
--- a/src/main/java/com/chargify/model/wrappers/CustomerWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/CustomerWrapper.java
@@ -3,21 +3,20 @@
import com.chargify.model.Customer;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@EqualsAndHashCode
+@ToString
public final class CustomerWrapper
{
private final Customer customer;
@JsonCreator
- public CustomerWrapper(
- @JsonProperty( "customer" )
- Customer wrappedCustomer )
+ public CustomerWrapper( @JsonProperty( "customer" ) Customer wrappedCustomer )
{
this.customer = wrappedCustomer;
}
-
- public Customer getCustomer()
- {
- return customer;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/MetadataWrapper.java b/src/main/java/com/chargify/model/wrappers/MetadataWrapper.java
index 50851e7..52477d7 100644
--- a/src/main/java/com/chargify/model/wrappers/MetadataWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/MetadataWrapper.java
@@ -3,7 +3,13 @@
import com.chargify.model.Metadata;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@ToString
+@EqualsAndHashCode
public final class MetadataWrapper
{
private final Metadata[] metadata;
@@ -13,9 +19,4 @@ public MetadataWrapper( @JsonProperty( "metadata" ) Metadata[] wrappedMetadata )
{
this.metadata = wrappedMetadata;
}
-
- public Metadata[] getMetadata()
- {
- return metadata;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/MigrationWrapper.java b/src/main/java/com/chargify/model/wrappers/MigrationWrapper.java
index 70b6454..3512f1f 100644
--- a/src/main/java/com/chargify/model/wrappers/MigrationWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/MigrationWrapper.java
@@ -3,7 +3,13 @@
import com.chargify.model.Migration;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@ToString
+@EqualsAndHashCode
public final class MigrationWrapper
{
private final Migration migration;
@@ -13,9 +19,4 @@ public MigrationWrapper( @JsonProperty( "migration" ) Migration wrappedMigration
{
this.migration = wrappedMigration;
}
-
- public Migration getMigration()
- {
- return migration;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/PaymentProfileWrapper.java b/src/main/java/com/chargify/model/wrappers/PaymentProfileWrapper.java
new file mode 100644
index 0000000..5004036
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/PaymentProfileWrapper.java
@@ -0,0 +1,22 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.PaymentProfile;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@ToString
+@EqualsAndHashCode
+public final class PaymentProfileWrapper
+{
+ private final PaymentProfile paymentProfile;
+
+ @JsonCreator
+ public PaymentProfileWrapper( @JsonProperty( "payment_profile" ) PaymentProfile paymentProfile )
+ {
+ this.paymentProfile = paymentProfile;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/PricePointUpdateResultWrapper.java b/src/main/java/com/chargify/model/wrappers/PricePointUpdateResultWrapper.java
new file mode 100644
index 0000000..1988793
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/PricePointUpdateResultWrapper.java
@@ -0,0 +1,23 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.PricePoint;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@EqualsAndHashCode
+@ToString
+public final class PricePointUpdateResultWrapper
+{
+ @JsonProperty( "price_point" )
+ private final PricePoint pricePoint;
+
+ @JsonCreator
+ public PricePointUpdateResultWrapper( @JsonProperty( "price_point" ) PricePoint pricePoint )
+ {
+ this.pricePoint = pricePoint;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/PricePointUpdateWrapper.java b/src/main/java/com/chargify/model/wrappers/PricePointUpdateWrapper.java
new file mode 100644
index 0000000..b374d24
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/PricePointUpdateWrapper.java
@@ -0,0 +1,23 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.PricePointUpdate;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@EqualsAndHashCode
+@ToString
+public final class PricePointUpdateWrapper
+{
+ @JsonProperty( "price_point" )
+ private final PricePointUpdate pricePoint;
+
+ @JsonCreator
+ public PricePointUpdateWrapper( @JsonProperty( "price_point" ) PricePointUpdate pricePoint )
+ {
+ this.pricePoint = pricePoint;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/ProductFamilyWrapper.java b/src/main/java/com/chargify/model/wrappers/ProductFamilyWrapper.java
index 76a281f..d3af269 100644
--- a/src/main/java/com/chargify/model/wrappers/ProductFamilyWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/ProductFamilyWrapper.java
@@ -1,6 +1,6 @@
package com.chargify.model.wrappers;
-import com.chargify.model.ProductFamily;
+import com.chargify.model.product.ProductFamily;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/src/main/java/com/chargify/model/wrappers/ProductPricePointsWrapper.java b/src/main/java/com/chargify/model/wrappers/ProductPricePointsWrapper.java
new file mode 100644
index 0000000..971cf0c
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/ProductPricePointsWrapper.java
@@ -0,0 +1,22 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.product.ProductPricePoint;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.util.Set;
+
+@Getter
+@ToString
+public final class ProductPricePointsWrapper
+{
+ private final Set pricePoints;
+
+ @JsonCreator
+ public ProductPricePointsWrapper( @JsonProperty( "price_points" ) Set pricePoints )
+ {
+ this.pricePoints = pricePoints;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/ProductWrapper.java b/src/main/java/com/chargify/model/wrappers/ProductWrapper.java
index 31651c5..4cb9232 100644
--- a/src/main/java/com/chargify/model/wrappers/ProductWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/ProductWrapper.java
@@ -1,9 +1,13 @@
package com.chargify.model.wrappers;
-import com.chargify.model.Product;
+import com.chargify.model.product.Product;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@ToString
public final class ProductWrapper
{
private final Product product;
@@ -13,17 +17,4 @@ public ProductWrapper( @JsonProperty( "product" ) Product wrappedProduct )
{
this.product = wrappedProduct;
}
-
- public Product getProduct()
- {
- return product;
- }
-
- @Override
- public String toString()
- {
- return "ProductWrapper{" +
- "product=" + product +
- '}';
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/ReferralCodeWrapper.java b/src/main/java/com/chargify/model/wrappers/ReferralCodeWrapper.java
index 3143b93..696e0b8 100644
--- a/src/main/java/com/chargify/model/wrappers/ReferralCodeWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/ReferralCodeWrapper.java
@@ -3,27 +3,18 @@
import com.chargify.model.ReferralCode;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.ToString;
+@Getter
+@ToString
public final class ReferralCodeWrapper
{
private final ReferralCode referralCode;
@JsonCreator
- public ReferralCodeWrapper( @JsonProperty( "referral_code" ) ReferralCode wrappedReferalCode )
+ public ReferralCodeWrapper( @JsonProperty( "referral_code" ) ReferralCode wrappedReferralCode )
{
- this.referralCode = wrappedReferalCode;
- }
-
- public ReferralCode getReferralCode()
- {
- return referralCode;
- }
-
- @Override
- public String toString()
- {
- return "ReferralCodeWrapper{" +
- "referralCode=" + referralCode +
- '}';
+ this.referralCode = wrappedReferralCode;
}
}
diff --git a/src/main/java/com/chargify/model/wrappers/RenewalPreviewWrapper.java b/src/main/java/com/chargify/model/wrappers/RenewalPreviewWrapper.java
index 31b7089..47d98e2 100644
--- a/src/main/java/com/chargify/model/wrappers/RenewalPreviewWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/RenewalPreviewWrapper.java
@@ -3,7 +3,9 @@
import com.chargify.model.RenewalPreview;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+@Getter
public final class RenewalPreviewWrapper
{
private final RenewalPreview renewalPreview;
@@ -13,9 +15,4 @@ public RenewalPreviewWrapper( @JsonProperty( "renewal_preview" ) RenewalPreview
{
this.renewalPreview = renewalPreview;
}
-
- public RenewalPreview getRenewalPreview()
- {
- return renewalPreview;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/SubscriptionChargeWrapper.java b/src/main/java/com/chargify/model/wrappers/SubscriptionChargeWrapper.java
new file mode 100644
index 0000000..1996834
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/SubscriptionChargeWrapper.java
@@ -0,0 +1,21 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.SubscriptionChargeResult;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.ToString;
+
+
+@Getter
+@ToString
+public final class SubscriptionChargeWrapper
+{
+ private final SubscriptionChargeResult subscriptionChargeResult;
+
+ @JsonCreator
+ public SubscriptionChargeWrapper( @JsonProperty( "charge" ) SubscriptionChargeResult subscriptionChargeResult )
+ {
+ this.subscriptionChargeResult = subscriptionChargeResult;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/SubscriptionComponentWrapper.java b/src/main/java/com/chargify/model/wrappers/SubscriptionComponentWrapper.java
index 55ccf4a..550a699 100644
--- a/src/main/java/com/chargify/model/wrappers/SubscriptionComponentWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/SubscriptionComponentWrapper.java
@@ -3,7 +3,9 @@
import com.chargify.model.SubscriptionComponent;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+@Getter
public final class SubscriptionComponentWrapper
{
private final SubscriptionComponent component;
@@ -13,9 +15,4 @@ public SubscriptionComponentWrapper( @JsonProperty( "component" ) SubscriptionCo
{
this.component = wrappedComponent;
}
-
- public SubscriptionComponent getComponent()
- {
- return component;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/SubscriptionProductUpdateWrapper.java b/src/main/java/com/chargify/model/wrappers/SubscriptionProductUpdateWrapper.java
new file mode 100644
index 0000000..cef3230
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/SubscriptionProductUpdateWrapper.java
@@ -0,0 +1,18 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.SubscriptionProductUpdate;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+
+@Getter
+public final class SubscriptionProductUpdateWrapper
+{
+ private final SubscriptionProductUpdate subscription;
+
+ @JsonCreator
+ public SubscriptionProductUpdateWrapper( @JsonProperty( "subscription" ) SubscriptionProductUpdate wrappedSubscription )
+ {
+ this.subscription = wrappedSubscription;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/SubscriptionStatementWrapper.java b/src/main/java/com/chargify/model/wrappers/SubscriptionStatementWrapper.java
new file mode 100644
index 0000000..98d3ef1
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/SubscriptionStatementWrapper.java
@@ -0,0 +1,18 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.SubscriptionStatement;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+
+@Getter
+public final class SubscriptionStatementWrapper
+{
+ private final SubscriptionStatement statement;
+
+ @JsonCreator
+ public SubscriptionStatementWrapper( @JsonProperty( "statement" ) SubscriptionStatement statement )
+ {
+ this.statement = statement;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/SubscriptionWrapper.java b/src/main/java/com/chargify/model/wrappers/SubscriptionWrapper.java
index 70fd480..c2d9230 100644
--- a/src/main/java/com/chargify/model/wrappers/SubscriptionWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/SubscriptionWrapper.java
@@ -3,21 +3,16 @@
import com.chargify.model.Subscription;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+@Getter
public final class SubscriptionWrapper
{
private final Subscription subscription;
@JsonCreator
- public SubscriptionWrapper(
- @JsonProperty( "subscription" )
- Subscription wrappedSubscription )
+ public SubscriptionWrapper( @JsonProperty( "subscription" ) Subscription wrappedSubscription )
{
this.subscription = wrappedSubscription;
}
-
- public Subscription getSubscription()
- {
- return subscription;
- }
}
diff --git a/src/main/java/com/chargify/model/wrappers/TransactionWrapper.java b/src/main/java/com/chargify/model/wrappers/TransactionWrapper.java
new file mode 100644
index 0000000..7a5100f
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/TransactionWrapper.java
@@ -0,0 +1,18 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.Transaction;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+
+@Getter
+public final class TransactionWrapper
+{
+ private final Transaction transaction;
+
+ @JsonCreator
+ public TransactionWrapper( @JsonProperty( "transaction" ) Transaction transaction )
+ {
+ this.transaction = transaction;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/UpdateSubscriptionWrapper.java b/src/main/java/com/chargify/model/wrappers/UpdateSubscriptionWrapper.java
new file mode 100644
index 0000000..0e2bc8c
--- /dev/null
+++ b/src/main/java/com/chargify/model/wrappers/UpdateSubscriptionWrapper.java
@@ -0,0 +1,18 @@
+package com.chargify.model.wrappers;
+
+import com.chargify.model.UpdateSubscription;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+
+@Getter
+public final class UpdateSubscriptionWrapper
+{
+ private final UpdateSubscription subscription;
+
+ @JsonCreator
+ public UpdateSubscriptionWrapper( @JsonProperty( "subscription" ) UpdateSubscription wrappedSubscription )
+ {
+ this.subscription = wrappedSubscription;
+ }
+}
diff --git a/src/main/java/com/chargify/model/wrappers/UsageWrapper.java b/src/main/java/com/chargify/model/wrappers/UsageWrapper.java
index cd03f16..e92f4a9 100644
--- a/src/main/java/com/chargify/model/wrappers/UsageWrapper.java
+++ b/src/main/java/com/chargify/model/wrappers/UsageWrapper.java
@@ -3,7 +3,9 @@
import com.chargify.model.Usage;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+@Getter
public final class UsageWrapper
{
private final Usage usage;
@@ -13,9 +15,4 @@ public UsageWrapper( @JsonProperty( "usage" ) Usage wrappedUsage )
{
this.usage = wrappedUsage;
}
-
- public Usage getUsage()
- {
- return usage;
- }
}
diff --git a/src/test/java/com/chargify/ChargifyTest.java b/src/test/java/com/chargify/ChargifyTest.java
index 6161bea..e49661a 100644
--- a/src/test/java/com/chargify/ChargifyTest.java
+++ b/src/test/java/com/chargify/ChargifyTest.java
@@ -16,7 +16,7 @@ public abstract class ChargifyTest
"-Dchargify.domain=XXX -Dchargify.apikey=YYY" );
}
- chargify = new ChargifyService( domain, apiKey );
+ chargify = new ChargifyService( domain, apiKey, 5000, 5000 );
}
protected static String randomName()
diff --git a/src/test/java/com/chargify/ComponentsTest.java b/src/test/java/com/chargify/ComponentsTest.java
index 9529b25..09e7975 100644
--- a/src/test/java/com/chargify/ComponentsTest.java
+++ b/src/test/java/com/chargify/ComponentsTest.java
@@ -2,7 +2,7 @@
import com.chargify.model.Component;
import com.chargify.model.ComponentKind;
-import com.chargify.model.ProductFamily;
+import com.chargify.model.product.ProductFamily;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -16,7 +16,7 @@ public class ComponentsTest extends ChargifyTest
@BeforeClass
public static void setup()
{
- productFamily = chargify.createProductFamily( new ProductFamily( randomName() ) );
+ productFamily = chargify.createProductFamily( new ProductFamily( randomName() ) ).block();
}
@Test
@@ -28,7 +28,7 @@ public void createQuantityBasedComponent()
component.setUnitName( randomName() );
component.setPricingScheme( "per_unit" );
component.setUnitPrice( 10. );
- final Component createdComponent = chargify.createComponent( productFamily.getId(), component );
+ final Component createdComponent = chargify.createComponent( productFamily.getId(), component ).block();
assertEquals( "Wrong component kind", ComponentKind.quantity_based_component, createdComponent.getKind() );
}
@@ -41,7 +41,7 @@ public void createMeteredComponent()
component.setUnitName( randomName() );
component.setPricingScheme( "per_unit" );
component.setUnitPrice( 10. );
- final Component createdComponent = chargify.createComponent( productFamily.getId(), component );
+ final Component createdComponent = chargify.createComponent( productFamily.getId(), component ).block();
assertEquals( "Wrong component kind", ComponentKind.metered_component, createdComponent.getKind() );
}
@@ -52,13 +52,13 @@ public void createOnOffComponent()
component.setKind( ComponentKind.on_off_component );
component.setName( randomName() );
component.setUnitPrice( 10. );
- final Component createdComponent = chargify.createComponent( productFamily.getId(), component );
+ final Component createdComponent = chargify.createComponent( productFamily.getId(), component ).block();
assertEquals( "Wrong component kind", ComponentKind.on_off_component, createdComponent.getKind() );
}
@AfterClass
public static void cleanup()
{
- chargify.archiveProductFamilyById( productFamily.getId() );
+ chargify.archiveProductFamilyById( productFamily.getId() ).block();
}
}
diff --git a/src/test/java/com/chargify/CustomersTest.java b/src/test/java/com/chargify/CustomersTest.java
index 46badc2..74bcfb8 100644
--- a/src/test/java/com/chargify/CustomersTest.java
+++ b/src/test/java/com/chargify/CustomersTest.java
@@ -7,9 +7,9 @@
import java.util.List;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
public class CustomersTest extends ChargifyTest
{
@@ -20,52 +20,52 @@ public class CustomersTest extends ChargifyTest
public static void setup()
{
customerUnderTest = chargify.createCustomer( new Customer( "Andy", "Panda",
- "andypanda@email.com" ) );
+ "andypanda@email.com" ) ).block();
final Customer customer = new Customer( "Martha", "Washington", "martha@example.com" );
customer.setReference( randomName() );
- customerWithReferenceUnderTest = chargify.createCustomer( customer );
+ customerWithReferenceUnderTest = chargify.createCustomer( customer ).block();
}
@AfterClass
public static void cleanup()
{
- chargify.deleteCustomerById( customerUnderTest.getId() );
- chargify.deleteCustomerById( customerWithReferenceUnderTest.getId() );
+ chargify.deleteCustomerById( customerUnderTest.getId() ).block();
+ chargify.deleteCustomerById( customerWithReferenceUnderTest.getId() ).block();
}
@Test
public void customerShouldBeFoundByValidId()
{
- final Customer customer = chargify.findCustomerById( customerUnderTest.getId() );
+ final Customer customer = chargify.findCustomerById( customerUnderTest.getId() ).block();
assertNotNull( "Customer not found", customer );
}
@Test
public void customerShouldNotBeFoundByInvalidId()
{
- final Customer customer = chargify.findCustomerById( "nonexisting" );
+ final Customer customer = chargify.findCustomerById( "nonexistent" ).block();
assertNull( "Customer should not have been found", customer );
}
@Test
public void findAllShouldFindAtLeastOne()
{
- final List customers = chargify.findAllCustomers();
- assertTrue( "No customers found", customers.size() > 0 );
+ final List customers = chargify.findAllCustomers().collectList().block();
+ assertFalse( "No customers found", customers.isEmpty() );
}
@Test
public void customerShouldBeFoundByValidReference()
{
- final Customer customer = chargify.findCustomerByReference( customerWithReferenceUnderTest.getReference() );
+ final Customer customer = chargify.findCustomerByReference( customerWithReferenceUnderTest.getReference() ).block();
assertNotNull( "Customer not found by reference", customer );
}
@Test
public void customerShouldNotBeFoundByInvalidReference()
{
- final Customer customer = chargify.findCustomerByReference( "invalid" );
+ final Customer customer = chargify.findCustomerByReference( "invalid" ).block();
assertNull( "Customer should not have been found", customer );
}
}
diff --git a/src/test/java/com/chargify/ProductFamiliesTest.java b/src/test/java/com/chargify/ProductFamiliesTest.java
index 3e3083c..9f42352 100644
--- a/src/test/java/com/chargify/ProductFamiliesTest.java
+++ b/src/test/java/com/chargify/ProductFamiliesTest.java
@@ -1,7 +1,7 @@
package com.chargify;
import com.chargify.exceptions.ApiHandleNotUniqueException;
-import com.chargify.model.ProductFamily;
+import com.chargify.model.product.ProductFamily;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -14,25 +14,25 @@ public class ProductFamiliesTest extends ChargifyTest
@BeforeClass
public static void setup()
{
- existingProductFamily = chargify.createProductFamily( new ProductFamily( randomName() ) );
+ existingProductFamily = chargify.createProductFamily( new ProductFamily( randomName() ) ).block();
}
@AfterClass
public static void cleanup()
{
- chargify.archiveProductFamilyById( existingProductFamily.getId() );
+ chargify.archiveProductFamilyById( existingProductFamily.getId() ).block();
}
@Test( expected = ApiHandleNotUniqueException.class )
public void productFamilyApiHandleShouldBeUnique()
{
- chargify.createProductFamily( existingProductFamily );
+ chargify.createProductFamily( existingProductFamily ).block();
}
@Test
public void productFamilyRetrievedByIdShouldHaveProperHandle()
{
- final ProductFamily retrievedProductFamily = chargify.findProductFamilyById( existingProductFamily.getId() );
+ final ProductFamily retrievedProductFamily = chargify.findProductFamilyById( existingProductFamily.getId() ).block();
Assert.assertNotNull( "Product family not found by ID " + existingProductFamily.getId(),
retrievedProductFamily );
@@ -43,14 +43,13 @@ public void productFamilyRetrievedByIdShouldHaveProperHandle()
@Test
public void readAllShouldRetrieveAtLeastOneProductFamily()
{
- Assert.assertTrue( "At least one product family should exist",
- chargify.findAllProductFamilies().size() > 0 );
+ Assert.assertFalse( "At least one product family should exist", chargify.findAllProductFamilies().collectList().block().isEmpty() );
}
@Test
public void readNonExistingShouldReturnEmptyOptional()
{
- final ProductFamily productFamily = chargify.findProductFamilyById( "nonexisting" );
+ final ProductFamily productFamily = chargify.findProductFamilyById( "nonexistent" ).block();
Assert.assertNull( "Non existing product family found", productFamily );
}
@@ -58,7 +57,7 @@ public void readNonExistingShouldReturnEmptyOptional()
@Test
public void archiveNonExistingShouldReturnEmptyOptional()
{
- final ProductFamily archivedProductFamily = chargify.archiveProductFamilyById( "nonexisting" );
+ final ProductFamily archivedProductFamily = chargify.archiveProductFamilyById( "nonexistent" ).block();
Assert.assertNull( "Non existing product family found", archivedProductFamily );
}
diff --git a/src/test/java/com/chargify/ProductsTest.java b/src/test/java/com/chargify/ProductsTest.java
index a211308..56522c0 100644
--- a/src/test/java/com/chargify/ProductsTest.java
+++ b/src/test/java/com/chargify/ProductsTest.java
@@ -1,8 +1,8 @@
package com.chargify;
-import com.chargify.exceptions.ChargifyException;
-import com.chargify.model.Product;
-import com.chargify.model.ProductFamily;
+import com.chargify.model.PricePointIntervalUnit;
+import com.chargify.model.product.Product;
+import com.chargify.model.product.ProductFamily;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -19,29 +19,29 @@ public class ProductsTest extends ChargifyTest
@BeforeClass
public static void setup()
{
- productFamilyUnderTest = chargify.createProductFamily( new ProductFamily( randomName() ) );
+ productFamilyUnderTest = chargify.createProductFamily( new ProductFamily( randomName() ) ).block();
productUnderTest = chargify.createProduct( productFamilyUnderTest.getId(),
new Product( randomName(), 0, 1,
- Product.IntervalUnit.month ) );
+ PricePointIntervalUnit.month ) ).block();
- final Product productWithHandle = new Product( randomName(), 0, 1, Product.IntervalUnit.month );
+ final Product productWithHandle = new Product( randomName(), 0, 1, PricePointIntervalUnit.month );
productWithHandle.setHandle( randomName() );
- productWithHandleUnderTest = chargify.createProduct( productFamilyUnderTest.getId(), productWithHandle );
+ productWithHandleUnderTest = chargify.createProduct( productFamilyUnderTest.getId(), productWithHandle ).block();
}
@AfterClass
public static void cleanup()
{
- chargify.archiveProductById( productUnderTest.getId() );
- chargify.archiveProductById( productWithHandleUnderTest.getId() );
- chargify.archiveProductFamilyById( productFamilyUnderTest.getId() );
+ chargify.archiveProductById( productUnderTest.getId() ).block();
+ chargify.archiveProductById( productWithHandleUnderTest.getId() ).block();
+ chargify.archiveProductFamilyById( productFamilyUnderTest.getId() ).block();
}
@Test
public void productShouldBeFoundById()
{
- final Product product = chargify.findProductById( productUnderTest.getId() );
+ final Product product = chargify.findProductById( productUnderTest.getId() ).block();
Assert.assertNotNull( "Product not found", product );
}
@@ -49,7 +49,7 @@ public void productShouldBeFoundById()
@Test
public void productShouldNotBeFoundByInvalidId()
{
- final Product product = chargify.findProductById( "nonexisting" );
+ final Product product = chargify.findProductById( "nonexistent" ).block();
Assert.assertNull( "Product should not be found by invalid ID", product );
}
@@ -57,7 +57,7 @@ public void productShouldNotBeFoundByInvalidId()
@Test
public void productShouldBeFoundByApiHandle()
{
- final Product product = chargify.findProductByApiHandle( productWithHandleUnderTest.getHandle() );
+ final Product product = chargify.findProductByApiHandle( productWithHandleUnderTest.getHandle() ).block();
Assert.assertNotNull( "Product not found", product );
}
@@ -65,7 +65,7 @@ public void productShouldBeFoundByApiHandle()
@Test
public void productShouldNotBeFoundByInvalidApiHandle()
{
- final Product product = chargify.findProductByApiHandle( productUnderTest.getHandle() );
+ final Product product = chargify.findProductByApiHandle( productUnderTest.getHandle() ).block();
Assert.assertNull( "Product should not be found by invalid ID", product );
}
@@ -73,31 +73,29 @@ public void productShouldNotBeFoundByInvalidApiHandle()
@Test
public void readAllShouldRetrieveAtLeastOne()
{
- final List products = chargify.findAllProducts();
+ final List products = chargify.findAllProducts().collectList().block();
- Assert.assertTrue( "At least one product should be present", products.size() > 0 );
+ Assert.assertFalse( "At least one product should be present", products.isEmpty() );
}
@Test
public void readAllByFamilyIdShouldRetrieveAtLeastOne()
{
- final List familyProducts = chargify.findProductsByProductFamilyId( productFamilyUnderTest.getId() );
+ final List familyProducts = chargify.findProductsByProductFamilyId( productFamilyUnderTest.getId() ).collectList().block();
- Assert.assertTrue( "At least one product should be present in the family",
- familyProducts.size() > 0 );
+ Assert.assertFalse( "At least one product should be present in the family", familyProducts.isEmpty() );
}
- // TODO: see issue https://chargify.zendesk.com/hc/en-us/requests/69553
- @Test( expected = ChargifyException.class )
- public void readByNonExistingFamilyShouldThrowException()
+ @Test
+ public void readByNonExistingFamilyShouldReturnNull()
{
- chargify.findProductFamilyById( "nonexisting" );
+ Assert.assertNull( chargify.findProductFamilyById( "nonexistent" ).block() );
}
@Test
public void archiveNonExisting()
{
- final Product archivedProduct = chargify.archiveProductById( "nonexisting" );
+ final Product archivedProduct = chargify.archiveProductById( "nonexistent" ).block();
Assert.assertNull( "Non existing product has been archived", archivedProduct );
}
diff --git a/src/test/java/com/chargify/SubscriptionDelayedChangeTest.java b/src/test/java/com/chargify/SubscriptionDelayedChangeTest.java
index ac3fb8f..0dddc99 100644
--- a/src/test/java/com/chargify/SubscriptionDelayedChangeTest.java
+++ b/src/test/java/com/chargify/SubscriptionDelayedChangeTest.java
@@ -1,8 +1,11 @@
package com.chargify;
+import com.chargify.model.CreateSubscription;
import com.chargify.model.Customer;
-import com.chargify.model.Product;
-import com.chargify.model.ProductFamily;
+import com.chargify.model.PricePointIntervalUnit;
+import com.chargify.model.SubscriptionProductUpdate;
+import com.chargify.model.product.Product;
+import com.chargify.model.product.ProductFamily;
import com.chargify.model.Subscription;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -22,33 +25,36 @@ public class SubscriptionDelayedChangeTest extends ChargifyTest
@BeforeClass
public static void setup()
{
- productFamily = chargify.createProductFamily( new ProductFamily( randomName() ) );
+ productFamily = chargify.createProductFamily( new ProductFamily( randomName() ) ).block();
- final Product initialProduct = new Product( randomName(), 0, 1, Product.IntervalUnit.month );
+ final Product initialProduct = new Product( randomName(), 0, 1, PricePointIntervalUnit.month );
initialProduct.setRequestCreditCard( false );
initialProduct.setRequireCreditCard( false );
- SubscriptionDelayedChangeTest.initialProduct = chargify.createProduct( productFamily.getId(), initialProduct );
+ SubscriptionDelayedChangeTest.initialProduct = chargify.createProduct( productFamily.getId(), initialProduct ).block();
- final Product targetProduct = new Product( randomName(), 0, 1, Product.IntervalUnit.month );
+ final Product targetProduct = new Product( randomName(), 0, 1, PricePointIntervalUnit.month );
targetProduct.setRequestCreditCard( false );
targetProduct.setRequireCreditCard( false );
targetProduct.setHandle( randomName() );
- SubscriptionDelayedChangeTest.targetProduct = chargify.createProduct( productFamily.getId(), targetProduct );
+ SubscriptionDelayedChangeTest.targetProduct = chargify.createProduct( productFamily.getId(), targetProduct ).block();
- customer = chargify.createCustomer( new Customer( randomName(), randomName(), randomEmail() ) );
+ customer = chargify.createCustomer( new Customer( randomName(), randomName(), randomEmail() ) ).block();
- final Subscription subscription = new Subscription();
+ final CreateSubscription subscription = new CreateSubscription();
subscription.setProductId( SubscriptionDelayedChangeTest.initialProduct.getId() );
subscription.setCustomerId( customer.getId() );
- SubscriptionDelayedChangeTest.subscription = chargify.createSubscription( subscription );
+ SubscriptionDelayedChangeTest.subscription = chargify.createSubscription( subscription ).block();
}
@Test
public void delayedProductChangeShouldModifyNextProductIdAndNotChangeCurrentProduct()
{
- final Subscription resultSubscription = chargify.changeSubscriptionProduct( subscription.getId(),
- targetProduct.getHandle(),
- true );
+ final Subscription resultSubscription = chargify.changeSubscriptionProduct(
+ subscription.getId(),
+ SubscriptionProductUpdate.builder()
+ .productHandle( targetProduct.getHandle() )
+ .changeDelayed( true ).build()
+ ).block();
assertNotNull( "Product change not scheduled", resultSubscription.getNextProductId() );
assertEquals( "Scheduled change to wrong product", targetProduct.getId(), resultSubscription.getNextProductId() );
assertEquals( "Current product changed", initialProduct.getId(), resultSubscription.getProduct().getId() );
@@ -57,11 +63,11 @@ public void delayedProductChangeShouldModifyNextProductIdAndNotChangeCurrentProd
@AfterClass
public static void cleanup()
{
- chargify.cancelSubscriptionProductChange( subscription.getId() );
- chargify.cancelSubscriptionById( subscription.getId() );
- chargify.archiveProductById( targetProduct.getId() );
- chargify.archiveProductById( initialProduct.getId() );
- chargify.archiveProductFamilyById( productFamily.getId() );
+ chargify.cancelSubscriptionProductChange( subscription.getId() ).block();
+ chargify.cancelSubscriptionById( subscription.getId() ).block();
+ chargify.archiveProductById( targetProduct.getId() ).block();
+ chargify.archiveProductById( initialProduct.getId() ).block();
+ chargify.archiveProductFamilyById( productFamily.getId() ).block();
// The customer could not be deleted because there are subscriptions associated with this account. You may want to delete the individual subscriptions first.
// chargify.deleteCustomerById( customer.getId() );
}
diff --git a/src/test/java/com/chargify/SubscriptionsTest.java b/src/test/java/com/chargify/SubscriptionsTest.java
index 727a4c1..859a19d 100644
--- a/src/test/java/com/chargify/SubscriptionsTest.java
+++ b/src/test/java/com/chargify/SubscriptionsTest.java
@@ -1,8 +1,12 @@
package com.chargify;
+import com.chargify.model.CreateSubscription;
import com.chargify.model.Customer;
-import com.chargify.model.Product;
-import com.chargify.model.ProductFamily;
+import com.chargify.model.Migration;
+import com.chargify.model.PricePointIntervalUnit;
+import com.chargify.model.SubscriptionProductUpdate;
+import com.chargify.model.product.Product;
+import com.chargify.model.product.ProductFamily;
import com.chargify.model.Subscription;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -11,9 +15,9 @@
import java.util.List;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
public class SubscriptionsTest extends ChargifyTest
{
@@ -28,36 +32,36 @@ public class SubscriptionsTest extends ChargifyTest
@BeforeClass
public static void setup()
{
- productFamilyUnderTest = chargify.createProductFamily( new ProductFamily( randomName() ) );
+ productFamilyUnderTest = chargify.createProductFamily( new ProductFamily( randomName() ) ).block();
- final Product product = new Product( randomName(), 0, 1, Product.IntervalUnit.month );
+ final Product product = new Product( randomName(), 0, 1, PricePointIntervalUnit.month );
product.setRequestCreditCard( false );
product.setRequireCreditCard( false );
- productUnderTest = chargify.createProduct( productFamilyUnderTest.getId(), product );
+ productUnderTest = chargify.createProduct( productFamilyUnderTest.getId(), product ).block();
product.setHandle( randomName() );
- productForDelayedChange = chargify.createProduct( productFamilyUnderTest.getId(), product );
+ productForDelayedChange = chargify.createProduct( productFamilyUnderTest.getId(), product ).block();
product.setHandle( randomName() );
- productForImmediateChange = chargify.createProduct( productFamilyUnderTest.getId(), product );
+ productForImmediateChange = chargify.createProduct( productFamilyUnderTest.getId(), product ).block();
product.setHandle( randomName() );
- productForMigration = chargify.createProduct( productFamilyUnderTest.getId(), product );
+ productForMigration = chargify.createProduct( productFamilyUnderTest.getId(), product ).block();
customerUnderTest = chargify.createCustomer( new Customer( "Andy", "Panda",
- "andypanda@example.com" ) );
+ "andypanda@example.com" ) ).block();
- final Subscription subscription = new Subscription();
+ final CreateSubscription subscription = new CreateSubscription();
subscription.setProductId( productUnderTest.getId() );
subscription.setCustomerId( customerUnderTest.getId() );
- subscriptionUnderTest = chargify.createSubscription( subscription );
+ subscriptionUnderTest = chargify.createSubscription( subscription ).block();
}
@AfterClass
public static void cleanup()
{
- chargify.cancelSubscriptionById( subscriptionUnderTest.getId() );
- chargify.archiveProductById( productUnderTest.getId() );
+ chargify.cancelSubscriptionById( subscriptionUnderTest.getId() ).block();
+ chargify.archiveProductById( productUnderTest.getId() ).block();
// cannot be archived - subscription change pending
// chargify.archiveProductById( productForDelayedChange.getId() );
// cannot be archived - product still exists
@@ -69,37 +73,39 @@ public static void cleanup()
@Test
public void subscriptionShouldBeFoundByValidId()
{
- final Subscription subscription = chargify.findSubscriptionById( subscriptionUnderTest.getId() );
+ final Subscription subscription = chargify.findSubscriptionById( subscriptionUnderTest.getId() ).block();
assertNotNull( "Subscription not found", subscription );
}
@Test
- public void subscriptionShoudNotBeFoundByInvalidId()
+ public void subscriptionShouldNotBeFoundByInvalidId()
{
- final Subscription subscription = chargify.findSubscriptionById( "invalid" );
+ final Subscription subscription = chargify.findSubscriptionById( "invalid" ).block();
assertNull( "Subscription should not have been found", subscription );
}
@Test
public void customerShouldHaveAtLeastOneSubscription()
{
- final List subscriptions = chargify.findSubscriptionsByCustomerId( customerUnderTest.getId() );
- assertTrue( "No subscriptions found for customer", subscriptions.size() > 0 );
+ final List subscriptions = chargify.findSubscriptionsByCustomerId( customerUnderTest.getId() ).collectList().block();
+ assertFalse( "No subscriptions found for customer", subscriptions.isEmpty() );
}
@Test
public void findAllShouldReturnAtLeastOne()
{
- final List subscriptions = chargify.findAllSubscriptions();
- assertTrue( "No subscriptions found", subscriptions.size() > 0 );
+ final List subscriptions = chargify.findAllSubscriptions().collectList().block();
+ assertFalse( "No subscriptions found", subscriptions.isEmpty() );
}
@Test
public void immediateProductChangeShouldChangeProduct()
{
- final Subscription subscription = chargify.changeSubscriptionProduct( subscriptionUnderTest.getId(),
- productForImmediateChange.getHandle(),
- false );
+ final Subscription subscription = chargify.changeSubscriptionProduct(
+ subscriptionUnderTest.getId(), SubscriptionProductUpdate.builder()
+ .productHandle( productForImmediateChange.getHandle() )
+ .changeDelayed( false ).build()
+ ).block();
assertNull( "Product change scheduled", subscription.getNextProductId() );
assertEquals( "Product should have been changed", productForImmediateChange.getId(), subscription.getProduct().getId() );
}
@@ -107,8 +113,8 @@ public void immediateProductChangeShouldChangeProduct()
@Test
public void migrationShouldChangeProduct()
{
- final Subscription subscription = chargify.migrateSubscription( subscriptionUnderTest.getId(),
- productForMigration.getHandle() );
+ final Subscription subscription = chargify.migrateSubscription(
+ subscriptionUnderTest.getId(), Migration.builder().productHandle( productForMigration.getHandle() ).build() ).block();
assertNull( "Product change scheduled", subscription.getNextProductId() );
assertEquals( "Product has not been migrated", productForMigration.getHandle(), subscription.getProduct().getHandle() );
}