Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DE-799] Add missing nullable types #134

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/controllers/advance-invoice.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AdvanceInvoiceController advanceInvoiceController = client.getAdvanceInvoiceCont

# Issue Advance Invoice

Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](../../doc/models/invoice.md) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided.
Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404811062541-Issue-Invoice-In-Advance) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided.
A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error.
That said, regeneration of the invoice may be forced with the params `force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated.
We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it.
Expand Down
13 changes: 13 additions & 0 deletions doc/controllers/invoices.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,19 @@ try {

Use this endpoint to retrieve the details for an invoice.

## PDF Invoice retrieval

Individual PDF Invoices can be retrieved by using the "Accept" header application/pdf or appending .pdf as the format portion of the URL:

```curl -u <api_key>:x -H
Accept:application/pdf -H
https://acme.chargify.com/invoices/inv_8gd8tdhtd3hgr.pdf > output_file.pdf
URL: `https://<subdomain>.chargify.com/invoices/<uid>.<format>`
Method: GET
Required parameters: `uid`
Response: A single Invoice.
```

```java
Invoice readInvoice(
final String uid)
Expand Down
9 changes: 6 additions & 3 deletions doc/controllers/subscription-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ List<SubscriptionComponentResponse> listSubscriptionComponents(
| `sort` | [`ListSubscriptionComponentsSort`](../../doc/models/list-subscription-components-sort.md) | Query, Optional | The attribute by which to sort. Use in query `sort=updated_at`. |
| `startDate` | `String` | Query, Optional | The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. |
| `startDatetime` | `String` | Query, Optional | The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site''s time zone will be used. If provided, this parameter will be used instead of start_date. |
| `include` | [`ListSubscriptionComponentsInclude`](../../doc/models/list-subscription-components-include.md) | Query, Optional | Allows including additional data in the response. Use in query `include=subscription`. |
| `include` | [`List<ListSubscriptionComponentsInclude>`](../../doc/models/list-subscription-components-include.md) | Query, Optional | Allows including additional data in the response. Use in query `include=subscription,historic_usages`. |

## Response Type

Expand All @@ -146,7 +146,10 @@ ListSubscriptionComponentsInput listSubscriptionComponentsInput = new ListSubscr
3
))
.sort(ListSubscriptionComponentsSort.UPDATED_AT)
.include(ListSubscriptionComponentsInclude.SUBSCRIPTION)
.include(Arrays.asList(
ListSubscriptionComponentsInclude.SUBSCRIPTION,
ListSubscriptionComponentsInclude.HISTORIC_USAGES
))
.build();

try {
Expand Down Expand Up @@ -1506,7 +1509,7 @@ ListSubscriptionComponentsResponse listSubscriptionComponentsForSite(
| `subscriptionIds` | `List<Integer>` | Query, Optional | Allows fetching components allocation with matching subscription id based on provided ids. Use in query `subscription_ids=1,2,3`. |
| `pricePointIds` | [`IncludeNotNull`](../../doc/models/include-not-null.md) | Query, Optional | Allows fetching components allocation only if price point id is present. Use in query `price_point_ids=not_null`. |
| `productFamilyIds` | `List<Integer>` | Query, Optional | Allows fetching components allocation with matching product family id based on provided ids. Use in query `product_family_ids=1,2,3`. |
| `include` | [`ListSubscriptionComponentsInclude`](../../doc/models/list-subscription-components-include.md) | Query, Optional | Allows including additional data in the response. Use in query `include=subscription`. |
| `include` | [`ListSubscriptionComponentsInclude`](../../doc/models/list-subscription-components-include.md) | Query, Optional | Allows including additional data in the response. Use in query `include=subscription,historic_usages`. |

## Response Type

Expand Down
13 changes: 0 additions & 13 deletions doc/models/containers/coupon-compounding-strategy.md

This file was deleted.

13 changes: 0 additions & 13 deletions doc/models/containers/subscription-component-price-point-type.md

This file was deleted.

2 changes: 1 addition & 1 deletion doc/models/coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
| `ArchivedAt` | `ZonedDateTime` | Optional | - | ZonedDateTime getArchivedAt() | setArchivedAt(ZonedDateTime archivedAt) |
| `ConversionLimit` | `String` | Optional | - | String getConversionLimit() | setConversionLimit(String conversionLimit) |
| `Stackable` | `Boolean` | Optional | - | Boolean getStackable() | setStackable(Boolean stackable) |
| `CompoundingStrategy` | [`CouponCompoundingStrategy`](../../doc/models/containers/coupon-compounding-strategy.md) | Optional | This is a container for any-of cases. | CouponCompoundingStrategy getCompoundingStrategy() | setCompoundingStrategy(CouponCompoundingStrategy compoundingStrategy) |
| `CompoundingStrategy` | [`CompoundingStrategy`](../../doc/models/compounding-strategy.md) | Optional | - | CompoundingStrategy getCompoundingStrategy() | setCompoundingStrategy(CompoundingStrategy compoundingStrategy) |
| `UseSiteExchangeRate` | `Boolean` | Optional | - | Boolean getUseSiteExchangeRate() | setUseSiteExchangeRate(Boolean useSiteExchangeRate) |
| `CreatedAt` | `ZonedDateTime` | Optional | - | ZonedDateTime getCreatedAt() | setCreatedAt(ZonedDateTime createdAt) |
| `UpdatedAt` | `ZonedDateTime` | Optional | - | ZonedDateTime getUpdatedAt() | setUpdatedAt(ZonedDateTime updatedAt) |
Expand Down
27 changes: 27 additions & 0 deletions doc/models/historic-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# Historic Usage

An optional object for Event Based Components, will be returned if provided `include=historic_usages` query param.

## Structure

`HistoricUsage`

## Fields

| Name | Type | Tags | Description | Getter | Setter |
| --- | --- | --- | --- | --- | --- |
| `TotalUsageQuantity` | `Double` | Optional | Total usage of a component for billing period | Double getTotalUsageQuantity() | setTotalUsageQuantity(Double totalUsageQuantity) |
| `BillingPeriodStartsAt` | `ZonedDateTime` | Optional | Start date of billing period | ZonedDateTime getBillingPeriodStartsAt() | setBillingPeriodStartsAt(ZonedDateTime billingPeriodStartsAt) |
| `BillingPeriodEndsAt` | `ZonedDateTime` | Optional | End date of billing period | ZonedDateTime getBillingPeriodEndsAt() | setBillingPeriodEndsAt(ZonedDateTime billingPeriodEndsAt) |

## Example (as JSON)

```json
{
"total_usage_quantity": 26.6,
"billing_period_starts_at": "2016-03-13T12:52:32.123Z",
"billing_period_ends_at": "2016-03-13T12:52:32.123Z"
}
```

1 change: 1 addition & 0 deletions doc/models/list-subscription-components-include.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| Name |
| --- |
| `Subscription` |
| `HistoricUsages` |

## Example

Expand Down
3 changes: 2 additions & 1 deletion doc/models/subscription-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
| `ArchivedAt` | `ZonedDateTime` | Optional | - | ZonedDateTime getArchivedAt() | setArchivedAt(ZonedDateTime archivedAt) |
| `PricePointId` | `Integer` | Optional | - | Integer getPricePointId() | setPricePointId(Integer pricePointId) |
| `PricePointHandle` | `String` | Optional | - | String getPricePointHandle() | setPricePointHandle(String pricePointHandle) |
| `PricePointType` | [`SubscriptionComponentPricePointType`](../../doc/models/containers/subscription-component-price-point-type.md) | Optional | This is a container for one-of cases. | SubscriptionComponentPricePointType getPricePointType() | setPricePointType(SubscriptionComponentPricePointType pricePointType) |
| `PricePointType` | [`PricePointType`](../../doc/models/price-point-type.md) | Optional | - | PricePointType getPricePointType() | setPricePointType(PricePointType pricePointType) |
| `PricePointName` | `String` | Optional | - | String getPricePointName() | setPricePointName(String pricePointName) |
| `ProductFamilyId` | `Integer` | Optional | - | Integer getProductFamilyId() | setProductFamilyId(Integer productFamilyId) |
| `ProductFamilyHandle` | `String` | Optional | - | String getProductFamilyHandle() | setProductFamilyHandle(String productFamilyHandle) |
Expand All @@ -37,6 +37,7 @@
| `Description` | `String` | Optional | - | String getDescription() | setDescription(String description) |
| `AllowFractionalQuantities` | `Boolean` | Optional | - | Boolean getAllowFractionalQuantities() | setAllowFractionalQuantities(Boolean allowFractionalQuantities) |
| `Subscription` | [`SubscriptionComponentSubscription`](../../doc/models/subscription-component-subscription.md) | Optional | An optional object, will be returned if provided `include=subscription` query param. | SubscriptionComponentSubscription getSubscription() | setSubscription(SubscriptionComponentSubscription subscription) |
| `HistoricUsages` | [`List<HistoricUsage>`](../../doc/models/historic-usage.md) | Optional | - | List<HistoricUsage> getHistoricUsages() | setHistoricUsages(List<HistoricUsage> historicUsages) |
| `DisplayOnHostedPage` | `Boolean` | Optional | - | Boolean getDisplayOnHostedPage() | setDisplayOnHostedPage(Boolean displayOnHostedPage) |
| `Interval` | `Integer` | Optional | The numerical interval. i.e. an interval of '30' coupled with an interval_unit of day would mean this component price point would renew every 30 days. This property is only available for sites with Multifrequency enabled. | Integer getInterval() | setInterval(Integer interval) |
| `IntervalUnit` | [`IntervalUnit`](../../doc/models/interval-unit.md) | Optional | A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled. | IntervalUnit getIntervalUnit() | setIntervalUnit(IntervalUnit intervalUnit) |
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ Maxio integrates directly into your product, so you can seamlessly manage your p
<dependency>
<groupId>io.apimatic</groupId>
<artifactId>core-interfaces</artifactId>
<version>[0.2, 0.3)</version>
<version>[0.3, 0.4)</version>
</dependency>
<dependency>
<groupId>io.apimatic</groupId>
<artifactId>core</artifactId>
<version>[0.5, 0.6)</version>
<version>[0.6, 0.7)</version>
</dependency>
<dependency>
<groupId>io.apimatic</groupId>
<artifactId>okhttp-client-adapter</artifactId>
<version>[0.2, 0.3)</version>
<version>[0.3, 0.4)</version>
</dependency>
</dependencies>
<build>
Expand Down
39 changes: 20 additions & 19 deletions src/main/java/com/maxio/advancedbilling/AdvancedBillingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
* Gateway class for the library.
Expand Down Expand Up @@ -135,30 +136,21 @@ public final class AdvancedBillingClient implements Configuration {
/**
* Map of authentication Managers.
*/
private Map<String, Authentication> authentications;
private Map<String, Authentication> authentications = new HashMap<String, Authentication>();

private AdvancedBillingClient(Environment environment, String subdomain, String domain,
HttpClient httpClient, ReadonlyHttpClientConfiguration httpClientConfig,
BasicAuthModel basicAuthModel, Map<String, Authentication> authentications) {
BasicAuthModel basicAuthModel) {
this.environment = environment;
this.subdomain = subdomain;
this.domain = domain;
this.httpClient = httpClient;
this.httpClientConfig = httpClientConfig;
this.authentications =
(authentications == null) ? new HashMap<>() : new HashMap<>(authentications);
this.basicAuthModel = basicAuthModel;

if (this.authentications.containsKey("BasicAuth")) {
this.basicAuthManager = (BasicAuthManager) this.authentications.get("BasicAuth");
}
this.basicAuthModel = basicAuthModel;

if (!this.authentications.containsKey("BasicAuth")
|| !getBasicAuthCredentials().equals(basicAuthModel.getUsername(),
basicAuthModel.getPassword())) {
this.basicAuthManager = new BasicAuthManager(basicAuthModel);
this.authentications.put("BasicAuth", basicAuthManager);
}
this.basicAuthManager = new BasicAuthManager(basicAuthModel);
this.authentications.put("BasicAuth", basicAuthManager);

GlobalConfiguration globalConfig = new GlobalConfiguration.Builder()
.httpClient(httpClient).baseUri(server -> getBaseUri(server))
Expand Down Expand Up @@ -602,9 +594,7 @@ public Builder newBuilder() {
builder.httpClient = getHttpClient();
builder.basicAuthCredentials(getBasicAuthModel()
.toBuilder().build());
builder.authentications = authentications;
builder.httpClientConfig(configBldr -> configBldr =
((HttpClientConfiguration) httpClientConfig).newBuilder());
builder.httpClientConfig(() -> ((HttpClientConfiguration) httpClientConfig).newBuilder());
return builder;
}

Expand All @@ -618,7 +608,6 @@ public static class Builder {
private String domain = "chargify.com";
private HttpClient httpClient;
private BasicAuthModel basicAuthModel = new BasicAuthModel.Builder("", "").build();
private Map<String, Authentication> authentications = null;
private HttpClientConfiguration.Builder httpClientConfigBuilder =
new HttpClientConfiguration.Builder();

Expand Down Expand Up @@ -688,6 +677,18 @@ public Builder httpClientConfig(Consumer<HttpClientConfiguration.Builder> action
return this;
}

/**
* Private Setter for the Builder of httpClientConfiguration, takes in an operation to be performed
* on the builder instance of HTTP client configuration.
*
* @param supplier Supplier for the builder of httpClientConfiguration.
* @return Builder
*/
private Builder httpClientConfig(Supplier<HttpClientConfiguration.Builder> supplier) {
httpClientConfigBuilder = supplier.get();
return this;
}

/**
* Builds a new AdvancedBillingClient object using the set fields.
* @return AdvancedBillingClient
Expand All @@ -697,7 +698,7 @@ public AdvancedBillingClient build() {
httpClient = new OkClient(httpClientConfig.getConfiguration(), compatibilityFactory);

return new AdvancedBillingClient(environment, subdomain, domain, httpClient,
httpClientConfig, basicAuthModel, authentications);
httpClientConfig, basicAuthModel);
}
}
}
Loading
Loading