Skip to content

Commit 0fc80bb

Browse files
authored
[DE-679] 1.0.0-alpha (#12)
1 parent 6053676 commit 0fc80bb

File tree

1,015 files changed

+66704
-66082
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,015 files changed

+66704
-66082
lines changed

README.md

Lines changed: 273 additions & 273 deletions
Large diffs are not rendered by default.

advance_invoice_controller.go

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,149 @@
11
package advancedbilling
22

33
import (
4-
"context"
5-
"fmt"
6-
"github.com/apimatic/go-core-runtime/utilities"
7-
"github.com/maxio-com/ab-golang-sdk/errors"
8-
"github.com/maxio-com/ab-golang-sdk/models"
4+
"context"
5+
"fmt"
6+
"github.com/apimatic/go-core-runtime/utilities"
7+
"github.com/maxio-com/ab-golang-sdk/errors"
8+
"github.com/maxio-com/ab-golang-sdk/models"
99
)
1010

1111
// AdvanceInvoiceController represents a controller struct.
1212
type AdvanceInvoiceController struct {
13-
baseController
13+
baseController
1414
}
1515

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

23-
// IssueAdvanceInvoice takes context, subscriptionId, body as parameters and
24-
// returns an models.ApiResponse with models.Invoice data and
25-
// an error if there was an issue with the request or response.
26-
// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice) 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.
27-
// 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.
28-
// 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.
23+
// IssueAdvanceInvoice takes context, subscriptionId, body as parameters and
24+
// returns an models.ApiResponse with models.Invoice data and
25+
// an error if there was an issue with the request or response.
26+
// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice) 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.
27+
// 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.
28+
// 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.
2929
// We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it.
3030
func (a *AdvanceInvoiceController) IssueAdvanceInvoice(
31-
ctx context.Context,
32-
subscriptionId int,
33-
body *models.IssueAdvanceInvoiceRequest) (
34-
models.ApiResponse[models.Invoice],
35-
error) {
36-
req := a.prepareRequest(
37-
ctx,
38-
"POST",
39-
fmt.Sprintf("/subscriptions/%v/advance_invoice/issue.json", subscriptionId),
40-
)
41-
req.Authenticate(true)
42-
req.Header("Content-Type", "application/json")
43-
if body != nil {
44-
req.Json(*body)
45-
}
46-
47-
var result models.Invoice
48-
decoder, resp, err := req.CallAsJson()
49-
if err != nil {
50-
return models.NewApiResponse(result, resp), err
51-
}
52-
err = validateResponse(*resp)
53-
if err != nil {
54-
return models.NewApiResponse(result, resp), err
55-
}
56-
57-
result, err = utilities.DecodeResults[models.Invoice](decoder)
58-
if err != nil {
59-
return models.NewApiResponse(result, resp), err
60-
}
61-
62-
if resp.StatusCode == 404 {
63-
err = errors.NewApiError(404, "Not Found")
64-
}
65-
if resp.StatusCode == 422 {
66-
err = errors.NewErrorListResponse(422, "Unprocessable Entity (WebDAV)")
67-
}
68-
return models.NewApiResponse(result, resp), err
31+
ctx context.Context,
32+
subscriptionId int,
33+
body *models.IssueAdvanceInvoiceRequest) (
34+
models.ApiResponse[models.Invoice],
35+
error) {
36+
req := a.prepareRequest(
37+
ctx,
38+
"POST",
39+
fmt.Sprintf("/subscriptions/%v/advance_invoice/issue.json", subscriptionId),
40+
)
41+
req.Authenticate(true)
42+
req.Header("Content-Type", "application/json")
43+
if body != nil {
44+
req.Json(*body)
45+
}
46+
47+
var result models.Invoice
48+
decoder, resp, err := req.CallAsJson()
49+
if err != nil {
50+
return models.NewApiResponse(result, resp), err
51+
}
52+
err = validateResponse(*resp)
53+
if err != nil {
54+
return models.NewApiResponse(result, resp), err
55+
}
56+
57+
result, err = utilities.DecodeResults[models.Invoice](decoder)
58+
if err != nil {
59+
return models.NewApiResponse(result, resp), err
60+
}
61+
62+
if resp.StatusCode == 404 {
63+
err = errors.NewApiError(404, "Not Found")
64+
}
65+
if resp.StatusCode == 422 {
66+
err = errors.NewErrorListResponse(422, "Unprocessable Entity (WebDAV)")
67+
}
68+
return models.NewApiResponse(result, resp), err
6969
}
7070

71-
// ReadAdvanceInvoice takes context, subscriptionId as parameters and
72-
// returns an models.ApiResponse with models.Invoice data and
73-
// an error if there was an issue with the request or response.
71+
// ReadAdvanceInvoice takes context, subscriptionId as parameters and
72+
// returns an models.ApiResponse with models.Invoice data and
73+
// an error if there was an issue with the request or response.
7474
// 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.
7575
func (a *AdvanceInvoiceController) ReadAdvanceInvoice(
76-
ctx context.Context,
77-
subscriptionId int) (
78-
models.ApiResponse[models.Invoice],
79-
error) {
80-
req := a.prepareRequest(
81-
ctx,
82-
"GET",
83-
fmt.Sprintf("/subscriptions/%v/advance_invoice.json", subscriptionId),
84-
)
85-
req.Authenticate(true)
86-
87-
var result models.Invoice
88-
decoder, resp, err := req.CallAsJson()
89-
if err != nil {
90-
return models.NewApiResponse(result, resp), err
91-
}
92-
err = validateResponse(*resp)
93-
if err != nil {
94-
return models.NewApiResponse(result, resp), err
95-
}
96-
97-
result, err = utilities.DecodeResults[models.Invoice](decoder)
98-
if err != nil {
99-
return models.NewApiResponse(result, resp), err
100-
}
101-
102-
if resp.StatusCode == 404 {
103-
err = errors.NewApiError(404, "Not Found")
104-
}
105-
return models.NewApiResponse(result, resp), err
76+
ctx context.Context,
77+
subscriptionId int) (
78+
models.ApiResponse[models.Invoice],
79+
error) {
80+
req := a.prepareRequest(
81+
ctx,
82+
"GET",
83+
fmt.Sprintf("/subscriptions/%v/advance_invoice.json", subscriptionId),
84+
)
85+
req.Authenticate(true)
86+
87+
var result models.Invoice
88+
decoder, resp, err := req.CallAsJson()
89+
if err != nil {
90+
return models.NewApiResponse(result, resp), err
91+
}
92+
err = validateResponse(*resp)
93+
if err != nil {
94+
return models.NewApiResponse(result, resp), err
95+
}
96+
97+
result, err = utilities.DecodeResults[models.Invoice](decoder)
98+
if err != nil {
99+
return models.NewApiResponse(result, resp), err
100+
}
101+
102+
if resp.StatusCode == 404 {
103+
err = errors.NewApiError(404, "Not Found")
104+
}
105+
return models.NewApiResponse(result, resp), err
106106
}
107107

108-
// VoidAdvanceInvoice takes context, subscriptionId, body as parameters and
109-
// returns an models.ApiResponse with models.Invoice data and
110-
// an error if there was an issue with the request or response.
111-
// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
108+
// VoidAdvanceInvoice takes context, subscriptionId, body as parameters and
109+
// returns an models.ApiResponse with models.Invoice data and
110+
// an error if there was an issue with the request or response.
111+
// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
112112
// 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](reference/Chargify-API.v1.yaml/components/schemas/Invoice).
113113
func (a *AdvanceInvoiceController) VoidAdvanceInvoice(
114-
ctx context.Context,
115-
subscriptionId int,
116-
body *models.VoidInvoiceRequest) (
117-
models.ApiResponse[models.Invoice],
118-
error) {
119-
req := a.prepareRequest(
120-
ctx,
121-
"POST",
122-
fmt.Sprintf("/subscriptions/%v/advance_invoice/void.json", subscriptionId),
123-
)
124-
req.Authenticate(true)
125-
req.Header("Content-Type", "application/json")
126-
if body != nil {
127-
req.Json(*body)
128-
}
129-
130-
var result models.Invoice
131-
decoder, resp, err := req.CallAsJson()
132-
if err != nil {
133-
return models.NewApiResponse(result, resp), err
134-
}
135-
err = validateResponse(*resp)
136-
if err != nil {
137-
return models.NewApiResponse(result, resp), err
138-
}
139-
140-
result, err = utilities.DecodeResults[models.Invoice](decoder)
141-
if err != nil {
142-
return models.NewApiResponse(result, resp), err
143-
}
144-
145-
if resp.StatusCode == 404 {
146-
err = errors.NewApiError(404, "Not Found")
147-
}
148-
return models.NewApiResponse(result, resp), err
114+
ctx context.Context,
115+
subscriptionId int,
116+
body *models.VoidInvoiceRequest) (
117+
models.ApiResponse[models.Invoice],
118+
error) {
119+
req := a.prepareRequest(
120+
ctx,
121+
"POST",
122+
fmt.Sprintf("/subscriptions/%v/advance_invoice/void.json", subscriptionId),
123+
)
124+
req.Authenticate(true)
125+
req.Header("Content-Type", "application/json")
126+
if body != nil {
127+
req.Json(*body)
128+
}
129+
130+
var result models.Invoice
131+
decoder, resp, err := req.CallAsJson()
132+
if err != nil {
133+
return models.NewApiResponse(result, resp), err
134+
}
135+
err = validateResponse(*resp)
136+
if err != nil {
137+
return models.NewApiResponse(result, resp), err
138+
}
139+
140+
result, err = utilities.DecodeResults[models.Invoice](decoder)
141+
if err != nil {
142+
return models.NewApiResponse(result, resp), err
143+
}
144+
145+
if resp.StatusCode == 404 {
146+
err = errors.NewApiError(404, "Not Found")
147+
}
148+
return models.NewApiResponse(result, resp), err
149149
}

0 commit comments

Comments
 (0)