Skip to content

Commit

Permalink
Merge pull request #20 from maxio-com/0.2.0
Browse files Browse the repository at this point in the history
[DE-771] Objects for filters in list requests, remove redundant container classes
  • Loading branch information
maciej-nedza authored Apr 12, 2024
2 parents ee7d333 + ce8aa6f commit 6ba09af
Show file tree
Hide file tree
Showing 1,359 changed files with 90,594 additions and 83,897 deletions.
114 changes: 57 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

## Introduction

Maxio Advanced Billing (formerly Chargify) provides an HTTP-based API that conforms to the principles of REST.
One of the many reasons to use Advanced Billing is the immense feature set and surrounding community [client libraries](page:development-tools/client-libraries).
Maxio Advanced Billing (formerly Chargify) provides an HTTP-based API that conforms to the principles of REST.
One of the many reasons to use Advanced Billing is the immense feature set and surrounding community [client libraries](page:development-tools/client-libraries).
The Maxio API returns JSON responses as the primary and recommended format, but XML is also provided as a backwards compatible option for Merchants who require it.

### Steps to make your first Maxio Advanced Billing API call

1. [Sign-up](https://app.chargify.com/signup/maxio-billing-sandbox) or [log-in](https://app.chargify.com/login.html) to your [test site](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405553861773-Testing-Intro) account.
2. [Setup and configure authentication](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405281550477-API-Keys#api) credentials.
3. Submit your API request and try it out.
4. Verify results through response.
1. [Sign-up](https://app.chargify.com/signup/maxio-billing-sandbox) or [log-in](https://app.chargify.com/login.html) to your [test site](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405553861773-Testing-Intro) account.
2. [Setup and configure authentication](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405281550477-API-Keys#api) credentials.
3. Submit your API request and try it out.
4. Verify results through response.
5. Test our integrations.

We strongly suggest exploring the developer portal, our [integrations](https://www.maxio.com/integrations) and the API guide, as well as the entire set of application-based documentation to aid in your discovery of the product.
Expand All @@ -37,11 +37,11 @@ The following section explains how to use the advancedbilling library in a new p

To use the package in your application, you can install the package from [pkg.go.dev](https://pkg.go.dev/) using the following command:

```bash
$ go get github.com/maxio-com/ab-golang-sdk@v0.1.0
```bash
$ go get github.com/maxio-com/ab-golang-sdk@v3.0.0
```

You can also view the package at: https://pkg.go.dev/github.com/maxio-com/ab-golang-sdk@v0.1.0
You can also view the package at: https://pkg.go.dev/github.com/maxio-com/ab-golang-sdk@v3.0.0

## Initialize the API Client

Expand All @@ -60,21 +60,21 @@ The following parameters are configurable for the API Client:
The API client can be initialized as follows:

```go
client := advancedbilling.NewClient(
advancedbilling.CreateConfiguration(
advancedbilling.WithHttpConfiguration(
advancedbilling.CreateHttpConfiguration(
advancedbilling.WithTimeout(30),
),
),
advancedbilling.WithEnvironment(advancedbilling.PRODUCTION),
advancedbilling.WithBasicAuthCredentials(
advancedbilling.NewBasicAuthCredentials(
"BasicAuthUserName",
"BasicAuthPassword",
),
),
),
client := advancedbilling.NewClient(
advancedbilling.CreateConfiguration(
advancedbilling.WithHttpConfiguration(
advancedbilling.CreateHttpConfiguration(
advancedbilling.WithTimeout(30),
),
),
advancedbilling.WithEnvironment(advancedbilling.PRODUCTION),
advancedbilling.WithBasicAuthCredentials(
advancedbilling.NewBasicAuthCredentials(
"BasicAuthUserName",
"BasicAuthPassword",
),
),
),
)
```

Expand All @@ -91,46 +91,46 @@ The SDK can be configured to use a different environment for making API calls. A

## Authorization

This API uses the following authentication schemes.

This API uses the following authentication schemes.

* [`BasicAuth (Basic Authentication)`](doc/auth/basic-authentication.md)

## List of APIs

* [API Exports](doc/controllers/api-exports.md)
* [Advance Invoice](doc/controllers/advance-invoice.md)
* [Billing Portal](doc/controllers/billing-portal.md)
* [Custom Fields](doc/controllers/custom-fields.md)
* [Events-Based Billing Segments](doc/controllers/events-based-billing-segments.md)
* [Payment Profiles](doc/controllers/payment-profiles.md)
* [Product Families](doc/controllers/product-families.md)
* [Product Price Points](doc/controllers/product-price-points.md)
* [Proforma Invoices](doc/controllers/proforma-invoices.md)
* [Reason Codes](doc/controllers/reason-codes.md)
* [Referral Codes](doc/controllers/referral-codes.md)
* [Sales Commissions](doc/controllers/sales-commissions.md)
* [Subscription Components](doc/controllers/subscription-components.md)
* [Subscription Groups](doc/controllers/subscription-groups.md)
* [Subscription Group Invoice Account](doc/controllers/subscription-group-invoice-account.md)
* [Subscription Group Status](doc/controllers/subscription-group-status.md)
* [Subscription Invoice Account](doc/controllers/subscription-invoice-account.md)
* [Subscription Notes](doc/controllers/subscription-notes.md)
* [Subscription Products](doc/controllers/subscription-products.md)
* [Subscription Status](doc/controllers/subscription-status.md)
* [Coupons](doc/controllers/coupons.md)
* [Components](doc/controllers/components.md)
* [Customers](doc/controllers/customers.md)
* [Events](doc/controllers/events.md)
* [Insights](doc/controllers/insights.md)
* [Invoices](doc/controllers/invoices.md)
* [Offers](doc/controllers/offers.md)
* [Products](doc/controllers/products.md)
* [Sites](doc/controllers/sites.md)
* [Subscriptions](doc/controllers/subscriptions.md)
* [API Exports](doc/controllers/api-exports.md)
* [Advance Invoice](doc/controllers/advance-invoice.md)
* [Billing Portal](doc/controllers/billing-portal.md)
* [Custom Fields](doc/controllers/custom-fields.md)
* [Events-Based Billing Segments](doc/controllers/events-based-billing-segments.md)
* [Payment Profiles](doc/controllers/payment-profiles.md)
* [Product Families](doc/controllers/product-families.md)
* [Product Price Points](doc/controllers/product-price-points.md)
* [Proforma Invoices](doc/controllers/proforma-invoices.md)
* [Reason Codes](doc/controllers/reason-codes.md)
* [Referral Codes](doc/controllers/referral-codes.md)
* [Sales Commissions](doc/controllers/sales-commissions.md)
* [Subscription Components](doc/controllers/subscription-components.md)
* [Subscription Groups](doc/controllers/subscription-groups.md)
* [Subscription Group Invoice Account](doc/controllers/subscription-group-invoice-account.md)
* [Subscription Group Status](doc/controllers/subscription-group-status.md)
* [Subscription Invoice Account](doc/controllers/subscription-invoice-account.md)
* [Subscription Notes](doc/controllers/subscription-notes.md)
* [Subscription Products](doc/controllers/subscription-products.md)
* [Subscription Status](doc/controllers/subscription-status.md)
* [Coupons](doc/controllers/coupons.md)
* [Components](doc/controllers/components.md)
* [Customers](doc/controllers/customers.md)
* [Events](doc/controllers/events.md)
* [Insights](doc/controllers/insights.md)
* [Invoices](doc/controllers/invoices.md)
* [Offers](doc/controllers/offers.md)
* [Products](doc/controllers/products.md)
* [Sites](doc/controllers/sites.md)
* [Subscriptions](doc/controllers/subscriptions.md)
* [Webhooks](doc/controllers/webhooks.md)

## Classes Documentation

* [HttpConfiguration](doc/http-configuration.md)
* [HttpConfiguration](doc/http-configuration.md)
* [RetryConfiguration](doc/retry-configuration.md)

156 changes: 78 additions & 78 deletions advance_invoice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (

// AdvanceInvoiceController represents a controller struct.
type AdvanceInvoiceController struct {
baseController
baseController
}

// NewAdvanceInvoiceController creates a new instance of AdvanceInvoiceController.
// It takes a baseController as a parameter and returns a pointer to the AdvanceInvoiceController.
func NewAdvanceInvoiceController(baseController baseController) *AdvanceInvoiceController {
advanceInvoiceController := AdvanceInvoiceController{baseController: baseController}
return &advanceInvoiceController
advanceInvoiceController := AdvanceInvoiceController{baseController: baseController}
return &advanceInvoiceController
}

// IssueAdvanceInvoice takes context, subscriptionId, body as parameters and
Expand All @@ -29,63 +29,63 @@ func NewAdvanceInvoiceController(baseController baseController) *AdvanceInvoiceC
// 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.
func (a *AdvanceInvoiceController) IssueAdvanceInvoice(
ctx context.Context,
subscriptionId int,
body *models.IssueAdvanceInvoiceRequest) (
models.ApiResponse[models.Invoice],
error) {
req := a.prepareRequest(
ctx,
"POST",
fmt.Sprintf("/subscriptions/%v/advance_invoice/issue.json", subscriptionId),
)
req.Authenticate(NewAuth("BasicAuth"))
req.AppendErrors(map[string]https.ErrorBuilder[error]{
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorListResponse},
})
req.Header("Content-Type", "application/json")
if body != nil {
req.Json(body)
}

var result models.Invoice
decoder, resp, err := req.CallAsJson()
if err != nil {
return models.NewApiResponse(result, resp), err
}

result, err = utilities.DecodeResults[models.Invoice](decoder)
return models.NewApiResponse(result, resp), err
ctx context.Context,
subscriptionId int,
body *models.IssueAdvanceInvoiceRequest) (
models.ApiResponse[models.Invoice],
error) {
req := a.prepareRequest(
ctx,
"POST",
fmt.Sprintf("/subscriptions/%v/advance_invoice/issue.json", subscriptionId),
)
req.Authenticate(NewAuth("BasicAuth"))
req.AppendErrors(map[string]https.ErrorBuilder[error]{
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorListResponse},
})
req.Header("Content-Type", "application/json")
if body != nil {
req.Json(body)
}
var result models.Invoice
decoder, resp, err := req.CallAsJson()
if err != nil {
return models.NewApiResponse(result, resp), err
}
result, err = utilities.DecodeResults[models.Invoice](decoder)
return models.NewApiResponse(result, resp), err
}

// ReadAdvanceInvoice takes context, subscriptionId as parameters and
// returns an models.ApiResponse with models.Invoice data and
// an error if there was an issue with the request or response.
// Once an advance invoice has been generated for a subscription's upcoming renewal, it can be viewed through this endpoint. There can only be one advance invoice per subscription per billing cycle.
func (a *AdvanceInvoiceController) ReadAdvanceInvoice(
ctx context.Context,
subscriptionId int) (
models.ApiResponse[models.Invoice],
error) {
req := a.prepareRequest(
ctx,
"GET",
fmt.Sprintf("/subscriptions/%v/advance_invoice.json", subscriptionId),
)
req.Authenticate(NewAuth("BasicAuth"))
req.AppendErrors(map[string]https.ErrorBuilder[error]{
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
})

var result models.Invoice
decoder, resp, err := req.CallAsJson()
if err != nil {
return models.NewApiResponse(result, resp), err
}

result, err = utilities.DecodeResults[models.Invoice](decoder)
return models.NewApiResponse(result, resp), err
ctx context.Context,
subscriptionId int) (
models.ApiResponse[models.Invoice],
error) {
req := a.prepareRequest(
ctx,
"GET",
fmt.Sprintf("/subscriptions/%v/advance_invoice.json", subscriptionId),
)
req.Authenticate(NewAuth("BasicAuth"))
req.AppendErrors(map[string]https.ErrorBuilder[error]{
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
})
var result models.Invoice
decoder, resp, err := req.CallAsJson()
if err != nil {
return models.NewApiResponse(result, resp), err
}
result, err = utilities.DecodeResults[models.Invoice](decoder)
return models.NewApiResponse(result, resp), err
}

// VoidAdvanceInvoice takes context, subscriptionId, body as parameters and
Expand All @@ -94,31 +94,31 @@ func (a *AdvanceInvoiceController) ReadAdvanceInvoice(
// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
// A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs]($m/Invoice).
func (a *AdvanceInvoiceController) VoidAdvanceInvoice(
ctx context.Context,
subscriptionId int,
body *models.VoidInvoiceRequest) (
models.ApiResponse[models.Invoice],
error) {
req := a.prepareRequest(
ctx,
"POST",
fmt.Sprintf("/subscriptions/%v/advance_invoice/void.json", subscriptionId),
)
req.Authenticate(NewAuth("BasicAuth"))
req.AppendErrors(map[string]https.ErrorBuilder[error]{
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
})
req.Header("Content-Type", "application/json")
if body != nil {
req.Json(body)
}
ctx context.Context,
subscriptionId int,
body *models.VoidInvoiceRequest) (
models.ApiResponse[models.Invoice],
error) {
req := a.prepareRequest(
ctx,
"POST",
fmt.Sprintf("/subscriptions/%v/advance_invoice/void.json", subscriptionId),
)
req.Authenticate(NewAuth("BasicAuth"))
req.AppendErrors(map[string]https.ErrorBuilder[error]{
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
})
req.Header("Content-Type", "application/json")
if body != nil {
req.Json(body)
}

var result models.Invoice
decoder, resp, err := req.CallAsJson()
if err != nil {
return models.NewApiResponse(result, resp), err
}
var result models.Invoice
decoder, resp, err := req.CallAsJson()
if err != nil {
return models.NewApiResponse(result, resp), err
}

result, err = utilities.DecodeResults[models.Invoice](decoder)
return models.NewApiResponse(result, resp), err
result, err = utilities.DecodeResults[models.Invoice](decoder)
return models.NewApiResponse(result, resp), err
}
Loading

0 comments on commit 6ba09af

Please sign in to comment.