Skip to content

Commit 6ba09af

Browse files
authored
Merge pull request #20 from maxio-com/0.2.0
[DE-771] Objects for filters in list requests, remove redundant container classes
2 parents ee7d333 + ce8aa6f commit 6ba09af

File tree

1,359 files changed

+90594
-83897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,359 files changed

+90594
-83897
lines changed

README.md

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
## Introduction
55

6-
Maxio Advanced Billing (formerly Chargify) provides an HTTP-based API that conforms to the principles of REST.
7-
One of the many reasons to use Advanced Billing is the immense feature set and surrounding community [client libraries](page:development-tools/client-libraries).
6+
Maxio Advanced Billing (formerly Chargify) provides an HTTP-based API that conforms to the principles of REST.
7+
One of the many reasons to use Advanced Billing is the immense feature set and surrounding community [client libraries](page:development-tools/client-libraries).
88
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.
99

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

12-
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.
13-
2. [Setup and configure authentication](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405281550477-API-Keys#api) credentials.
14-
3. Submit your API request and try it out.
15-
4. Verify results through response.
12+
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.
13+
2. [Setup and configure authentication](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405281550477-API-Keys#api) credentials.
14+
3. Submit your API request and try it out.
15+
4. Verify results through response.
1616
5. Test our integrations.
1717

1818
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.
@@ -37,11 +37,11 @@ The following section explains how to use the advancedbilling library in a new p
3737

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

40-
```bash
41-
$ go get github.com/maxio-com/ab-golang-sdk@v0.1.0
40+
```bash
41+
$ go get github.com/maxio-com/ab-golang-sdk@v3.0.0
4242
```
4343

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

4646
## Initialize the API Client
4747

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

6262
```go
63-
client := advancedbilling.NewClient(
64-
advancedbilling.CreateConfiguration(
65-
advancedbilling.WithHttpConfiguration(
66-
advancedbilling.CreateHttpConfiguration(
67-
advancedbilling.WithTimeout(30),
68-
),
69-
),
70-
advancedbilling.WithEnvironment(advancedbilling.PRODUCTION),
71-
advancedbilling.WithBasicAuthCredentials(
72-
advancedbilling.NewBasicAuthCredentials(
73-
"BasicAuthUserName",
74-
"BasicAuthPassword",
75-
),
76-
),
77-
),
63+
client := advancedbilling.NewClient(
64+
advancedbilling.CreateConfiguration(
65+
advancedbilling.WithHttpConfiguration(
66+
advancedbilling.CreateHttpConfiguration(
67+
advancedbilling.WithTimeout(30),
68+
),
69+
),
70+
advancedbilling.WithEnvironment(advancedbilling.PRODUCTION),
71+
advancedbilling.WithBasicAuthCredentials(
72+
advancedbilling.NewBasicAuthCredentials(
73+
"BasicAuthUserName",
74+
"BasicAuthPassword",
75+
),
76+
),
77+
),
7878
)
7979
```
8080

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

9292
## Authorization
9393

94-
This API uses the following authentication schemes.
95-
94+
This API uses the following authentication schemes.
95+
9696
* [`BasicAuth (Basic Authentication)`](doc/auth/basic-authentication.md)
9797

9898
## List of APIs
9999

100-
* [API Exports](doc/controllers/api-exports.md)
101-
* [Advance Invoice](doc/controllers/advance-invoice.md)
102-
* [Billing Portal](doc/controllers/billing-portal.md)
103-
* [Custom Fields](doc/controllers/custom-fields.md)
104-
* [Events-Based Billing Segments](doc/controllers/events-based-billing-segments.md)
105-
* [Payment Profiles](doc/controllers/payment-profiles.md)
106-
* [Product Families](doc/controllers/product-families.md)
107-
* [Product Price Points](doc/controllers/product-price-points.md)
108-
* [Proforma Invoices](doc/controllers/proforma-invoices.md)
109-
* [Reason Codes](doc/controllers/reason-codes.md)
110-
* [Referral Codes](doc/controllers/referral-codes.md)
111-
* [Sales Commissions](doc/controllers/sales-commissions.md)
112-
* [Subscription Components](doc/controllers/subscription-components.md)
113-
* [Subscription Groups](doc/controllers/subscription-groups.md)
114-
* [Subscription Group Invoice Account](doc/controllers/subscription-group-invoice-account.md)
115-
* [Subscription Group Status](doc/controllers/subscription-group-status.md)
116-
* [Subscription Invoice Account](doc/controllers/subscription-invoice-account.md)
117-
* [Subscription Notes](doc/controllers/subscription-notes.md)
118-
* [Subscription Products](doc/controllers/subscription-products.md)
119-
* [Subscription Status](doc/controllers/subscription-status.md)
120-
* [Coupons](doc/controllers/coupons.md)
121-
* [Components](doc/controllers/components.md)
122-
* [Customers](doc/controllers/customers.md)
123-
* [Events](doc/controllers/events.md)
124-
* [Insights](doc/controllers/insights.md)
125-
* [Invoices](doc/controllers/invoices.md)
126-
* [Offers](doc/controllers/offers.md)
127-
* [Products](doc/controllers/products.md)
128-
* [Sites](doc/controllers/sites.md)
129-
* [Subscriptions](doc/controllers/subscriptions.md)
100+
* [API Exports](doc/controllers/api-exports.md)
101+
* [Advance Invoice](doc/controllers/advance-invoice.md)
102+
* [Billing Portal](doc/controllers/billing-portal.md)
103+
* [Custom Fields](doc/controllers/custom-fields.md)
104+
* [Events-Based Billing Segments](doc/controllers/events-based-billing-segments.md)
105+
* [Payment Profiles](doc/controllers/payment-profiles.md)
106+
* [Product Families](doc/controllers/product-families.md)
107+
* [Product Price Points](doc/controllers/product-price-points.md)
108+
* [Proforma Invoices](doc/controllers/proforma-invoices.md)
109+
* [Reason Codes](doc/controllers/reason-codes.md)
110+
* [Referral Codes](doc/controllers/referral-codes.md)
111+
* [Sales Commissions](doc/controllers/sales-commissions.md)
112+
* [Subscription Components](doc/controllers/subscription-components.md)
113+
* [Subscription Groups](doc/controllers/subscription-groups.md)
114+
* [Subscription Group Invoice Account](doc/controllers/subscription-group-invoice-account.md)
115+
* [Subscription Group Status](doc/controllers/subscription-group-status.md)
116+
* [Subscription Invoice Account](doc/controllers/subscription-invoice-account.md)
117+
* [Subscription Notes](doc/controllers/subscription-notes.md)
118+
* [Subscription Products](doc/controllers/subscription-products.md)
119+
* [Subscription Status](doc/controllers/subscription-status.md)
120+
* [Coupons](doc/controllers/coupons.md)
121+
* [Components](doc/controllers/components.md)
122+
* [Customers](doc/controllers/customers.md)
123+
* [Events](doc/controllers/events.md)
124+
* [Insights](doc/controllers/insights.md)
125+
* [Invoices](doc/controllers/invoices.md)
126+
* [Offers](doc/controllers/offers.md)
127+
* [Products](doc/controllers/products.md)
128+
* [Sites](doc/controllers/sites.md)
129+
* [Subscriptions](doc/controllers/subscriptions.md)
130130
* [Webhooks](doc/controllers/webhooks.md)
131131

132132
## Classes Documentation
133133

134-
* [HttpConfiguration](doc/http-configuration.md)
134+
* [HttpConfiguration](doc/http-configuration.md)
135135
* [RetryConfiguration](doc/retry-configuration.md)
136136

advance_invoice_controller.go

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111

1212
// AdvanceInvoiceController represents a controller struct.
1313
type AdvanceInvoiceController struct {
14-
baseController
14+
baseController
1515
}
1616

1717
// NewAdvanceInvoiceController creates a new instance of AdvanceInvoiceController.
1818
// It takes a baseController as a parameter and returns a pointer to the AdvanceInvoiceController.
1919
func NewAdvanceInvoiceController(baseController baseController) *AdvanceInvoiceController {
20-
advanceInvoiceController := AdvanceInvoiceController{baseController: baseController}
21-
return &advanceInvoiceController
20+
advanceInvoiceController := AdvanceInvoiceController{baseController: baseController}
21+
return &advanceInvoiceController
2222
}
2323

2424
// IssueAdvanceInvoice takes context, subscriptionId, body as parameters and
@@ -29,63 +29,63 @@ func NewAdvanceInvoiceController(baseController baseController) *AdvanceInvoiceC
2929
// 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.
3030
// We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it.
3131
func (a *AdvanceInvoiceController) IssueAdvanceInvoice(
32-
ctx context.Context,
33-
subscriptionId int,
34-
body *models.IssueAdvanceInvoiceRequest) (
35-
models.ApiResponse[models.Invoice],
36-
error) {
37-
req := a.prepareRequest(
38-
ctx,
39-
"POST",
40-
fmt.Sprintf("/subscriptions/%v/advance_invoice/issue.json", subscriptionId),
41-
)
42-
req.Authenticate(NewAuth("BasicAuth"))
43-
req.AppendErrors(map[string]https.ErrorBuilder[error]{
44-
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
45-
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorListResponse},
46-
})
47-
req.Header("Content-Type", "application/json")
48-
if body != nil {
49-
req.Json(body)
50-
}
51-
52-
var result models.Invoice
53-
decoder, resp, err := req.CallAsJson()
54-
if err != nil {
55-
return models.NewApiResponse(result, resp), err
56-
}
57-
58-
result, err = utilities.DecodeResults[models.Invoice](decoder)
59-
return models.NewApiResponse(result, resp), err
32+
ctx context.Context,
33+
subscriptionId int,
34+
body *models.IssueAdvanceInvoiceRequest) (
35+
models.ApiResponse[models.Invoice],
36+
error) {
37+
req := a.prepareRequest(
38+
ctx,
39+
"POST",
40+
fmt.Sprintf("/subscriptions/%v/advance_invoice/issue.json", subscriptionId),
41+
)
42+
req.Authenticate(NewAuth("BasicAuth"))
43+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
44+
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
45+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorListResponse},
46+
})
47+
req.Header("Content-Type", "application/json")
48+
if body != nil {
49+
req.Json(body)
50+
}
51+
52+
var result models.Invoice
53+
decoder, resp, err := req.CallAsJson()
54+
if err != nil {
55+
return models.NewApiResponse(result, resp), err
56+
}
57+
58+
result, err = utilities.DecodeResults[models.Invoice](decoder)
59+
return models.NewApiResponse(result, resp), err
6060
}
6161

6262
// ReadAdvanceInvoice takes context, subscriptionId as parameters and
6363
// returns an models.ApiResponse with models.Invoice data and
6464
// an error if there was an issue with the request or response.
6565
// 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.
6666
func (a *AdvanceInvoiceController) ReadAdvanceInvoice(
67-
ctx context.Context,
68-
subscriptionId int) (
69-
models.ApiResponse[models.Invoice],
70-
error) {
71-
req := a.prepareRequest(
72-
ctx,
73-
"GET",
74-
fmt.Sprintf("/subscriptions/%v/advance_invoice.json", subscriptionId),
75-
)
76-
req.Authenticate(NewAuth("BasicAuth"))
77-
req.AppendErrors(map[string]https.ErrorBuilder[error]{
78-
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
79-
})
80-
81-
var result models.Invoice
82-
decoder, resp, err := req.CallAsJson()
83-
if err != nil {
84-
return models.NewApiResponse(result, resp), err
85-
}
86-
87-
result, err = utilities.DecodeResults[models.Invoice](decoder)
88-
return models.NewApiResponse(result, resp), err
67+
ctx context.Context,
68+
subscriptionId int) (
69+
models.ApiResponse[models.Invoice],
70+
error) {
71+
req := a.prepareRequest(
72+
ctx,
73+
"GET",
74+
fmt.Sprintf("/subscriptions/%v/advance_invoice.json", subscriptionId),
75+
)
76+
req.Authenticate(NewAuth("BasicAuth"))
77+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
78+
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
79+
})
80+
81+
var result models.Invoice
82+
decoder, resp, err := req.CallAsJson()
83+
if err != nil {
84+
return models.NewApiResponse(result, resp), err
85+
}
86+
87+
result, err = utilities.DecodeResults[models.Invoice](decoder)
88+
return models.NewApiResponse(result, resp), err
8989
}
9090

9191
// VoidAdvanceInvoice takes context, subscriptionId, body as parameters and
@@ -94,31 +94,31 @@ func (a *AdvanceInvoiceController) ReadAdvanceInvoice(
9494
// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
9595
// 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).
9696
func (a *AdvanceInvoiceController) VoidAdvanceInvoice(
97-
ctx context.Context,
98-
subscriptionId int,
99-
body *models.VoidInvoiceRequest) (
100-
models.ApiResponse[models.Invoice],
101-
error) {
102-
req := a.prepareRequest(
103-
ctx,
104-
"POST",
105-
fmt.Sprintf("/subscriptions/%v/advance_invoice/void.json", subscriptionId),
106-
)
107-
req.Authenticate(NewAuth("BasicAuth"))
108-
req.AppendErrors(map[string]https.ErrorBuilder[error]{
109-
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
110-
})
111-
req.Header("Content-Type", "application/json")
112-
if body != nil {
113-
req.Json(body)
114-
}
97+
ctx context.Context,
98+
subscriptionId int,
99+
body *models.VoidInvoiceRequest) (
100+
models.ApiResponse[models.Invoice],
101+
error) {
102+
req := a.prepareRequest(
103+
ctx,
104+
"POST",
105+
fmt.Sprintf("/subscriptions/%v/advance_invoice/void.json", subscriptionId),
106+
)
107+
req.Authenticate(NewAuth("BasicAuth"))
108+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
109+
"404": {TemplatedMessage: "Not Found:'{$response.body}'"},
110+
})
111+
req.Header("Content-Type", "application/json")
112+
if body != nil {
113+
req.Json(body)
114+
}
115115

116-
var result models.Invoice
117-
decoder, resp, err := req.CallAsJson()
118-
if err != nil {
119-
return models.NewApiResponse(result, resp), err
120-
}
116+
var result models.Invoice
117+
decoder, resp, err := req.CallAsJson()
118+
if err != nil {
119+
return models.NewApiResponse(result, resp), err
120+
}
121121

122-
result, err = utilities.DecodeResults[models.Invoice](decoder)
123-
return models.NewApiResponse(result, resp), err
122+
result, err = utilities.DecodeResults[models.Invoice](decoder)
123+
return models.NewApiResponse(result, resp), err
124124
}

0 commit comments

Comments
 (0)