Skip to content

Commit 740cd1e

Browse files
authored
[DE-1091] Release 6.0.0 (#37)
1 parent 4d92f5e commit 740cd1e

File tree

603 files changed

+7410
-5707
lines changed

Some content is hidden

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

603 files changed

+7410
-5707
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
env:
1010
TEST_API_KEY: ${{secrets.TEST_API_KEY}}
1111
TEST_API_PASSWORD: ${{secrets.TEST_API_PASSWORD}}
12-
TEST_DOMAIN: ${{vars.TEST_DOMAIN}}
1312
TEST_SUBDOMAIN: ${{vars.TEST_SUBDOMAIN}}
1413

1514
jobs:

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Introduction
55

66
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).
7+
One of the many reasons to use Advanced Billing is the immense feature set and surrounding community [client libraries](http://localhost:8080/go/development-tools/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
@@ -38,10 +38,10 @@ The following section explains how to use the advancedbilling library in a new p
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

4040
```bash
41-
$ go get github.com/maxio-com/ab-golang-sdk@v0.4.2
41+
$ go get github.com/maxio-com/ab-golang-sdk@v5.0.0
4242
```
4343

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

4646
## Initialize the API Client
4747

@@ -51,9 +51,8 @@ The following parameters are configurable for the API Client:
5151

5252
| Parameter | Type | Description |
5353
| --- | --- | --- |
54-
| `subdomain` | `string` | The subdomain for your Advanced Billing site.<br>*Default*: `"subdomain"` |
55-
| `domain` | `string` | The Advanced Billing server domain.<br>*Default*: `"chargify.com"` |
56-
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
54+
| `site` | `string` | The subdomain for your Advanced Billing site.<br>*Default*: `"subdomain"` |
55+
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.US`** |
5756
| `httpConfiguration` | [`HttpConfiguration`](doc/http-configuration.md) | Configurable http client options like timeout and retries. |
5857
| `basicAuthCredentials` | [`BasicAuthCredentials`](doc/auth/basic-authentication.md) | The Credentials Setter for Basic Authentication |
5958

@@ -67,15 +66,14 @@ client := advancedbilling.NewClient(
6766
advancedbilling.WithTimeout(120),
6867
),
6968
),
70-
advancedbilling.WithEnvironment(advancedbilling.PRODUCTION),
69+
advancedbilling.WithEnvironment(advancedbilling.US),
7170
advancedbilling.WithBasicAuthCredentials(
7271
advancedbilling.NewBasicAuthCredentials(
7372
"BasicAuthUserName",
7473
"BasicAuthPassword",
7574
),
7675
),
77-
advancedbilling.WithSubdomain("subdomain"),
78-
advancedbilling.WithDomain("chargify.com"),
76+
advancedbilling.WithSite("subdomain"),
7977
),
8078
)
8179
```
@@ -88,8 +86,8 @@ The SDK can be configured to use a different environment for making API calls. A
8886

8987
| Name | Description |
9088
| --- | --- |
91-
| production | **Default** Production server |
92-
| environment2 | Production server |
89+
| US | **Default** Default Advanced Billing environment hosted in US. Valid for the majority of our customers. |
90+
| EU | Advanced Billing environment hosted in EU. Use only when you requested EU hosting for your AB account. |
9391

9492
## Authorization
9593

client.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ func NewClient(configuration Configuration) ClientInterface {
9898
configuration: configuration,
9999
}
100100

101-
client.userAgent = utilities.UpdateUserAgent("AB SDK Go:0.4.2 on OS {os-info}")
101+
client.userAgent = utilities.UpdateUserAgent("AB SDK Go:5.0.0 on OS {os-info}")
102102
client.callBuilderFactory = callBuilderHandler(
103103
func(server string) string {
104104
if server == "" {
105-
server = "default"
105+
server = "production"
106106
}
107107
return getBaseUri(Server(server), client.configuration)
108108
},
@@ -334,14 +334,20 @@ func (c *client) GetCallBuilder() https.CallBuilderFactory {
334334
func getBaseUri(
335335
server Server,
336336
configuration Configuration) string {
337-
if configuration.Environment() == Environment(PRODUCTION) {
338-
if server == Server(ENUMDEFAULT) {
339-
return fmt.Sprintf("https://%v.%v", configuration.Subdomain(), configuration.Domain())
337+
if configuration.Environment() == Environment(US) {
338+
if server == Server(PRODUCTION) {
339+
return fmt.Sprintf("https://%v.chargify.com", configuration.Site())
340+
}
341+
if server == Server(EBB) {
342+
return fmt.Sprintf("https://events.chargify.com/%v", configuration.Site())
340343
}
341344
}
342-
if configuration.Environment() == Environment(ENVIRONMENT2) {
343-
if server == Server(ENUMDEFAULT) {
344-
return "https://events.chargify.com"
345+
if configuration.Environment() == Environment(EU) {
346+
if server == Server(PRODUCTION) {
347+
return fmt.Sprintf("https://%v.ebilling.maxio.com", configuration.Site())
348+
}
349+
if server == Server(EBB) {
350+
return fmt.Sprintf("https://events.chargify.com/%v", configuration.Site())
345351
}
346352
}
347353
return "TODO: Select a valid server."

component_price_points_controller.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ func (c *ComponentPricePointsController) CreateComponentPricePoint(
7171
fmt.Sprintf("/components/%v/price_points.json", componentId),
7272
)
7373
req.Authenticate(NewAuth("BasicAuth"))
74+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
75+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorArrayMapResponse},
76+
})
7477
req.Header("Content-Type", "application/json")
7578
if body != nil {
7679
req.Json(body)
@@ -159,6 +162,9 @@ func (c *ComponentPricePointsController) BulkCreateComponentPricePoints(
159162
fmt.Sprintf("/components/%v/price_points/bulk.json", componentId),
160163
)
161164
req.Authenticate(NewAuth("BasicAuth"))
165+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
166+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorListResponse},
167+
})
162168
req.Header("Content-Type", "application/json")
163169
if body != nil {
164170
req.Json(body)
@@ -212,14 +218,15 @@ func (c *ComponentPricePointsController) UpdateComponentPricePoint(
212218
return models.NewApiResponse(result, resp), err
213219
}
214220

215-
// ReadComponentPricePoint takes context, componentId, pricePointId as parameters and
221+
// ReadComponentPricePoint takes context, componentId, pricePointId, currencyPrices as parameters and
216222
// returns an models.ApiResponse with models.ComponentPricePointResponse data and
217223
// an error if there was an issue with the request or response.
218224
// Use this endpoint to retrieve details for a specific component price point. You can achieve this by using either the component price point ID or handle.
219225
func (c *ComponentPricePointsController) ReadComponentPricePoint(
220226
ctx context.Context,
221227
componentId models.ReadComponentPricePointComponentId,
222-
pricePointId models.ReadComponentPricePointPricePointId) (
228+
pricePointId models.ReadComponentPricePointPricePointId,
229+
currencyPrices *bool) (
223230
models.ApiResponse[models.ComponentPricePointResponse],
224231
error) {
225232
req := c.prepareRequest(
@@ -228,6 +235,9 @@ func (c *ComponentPricePointsController) ReadComponentPricePoint(
228235
fmt.Sprintf("/components/%v/price_points/%v.json", componentId, pricePointId),
229236
)
230237
req.Authenticate(NewAuth("BasicAuth"))
238+
if currencyPrices != nil {
239+
req.QueryParam("currency_prices", *currencyPrices)
240+
}
231241

232242
var result models.ComponentPricePointResponse
233243
decoder, resp, err := req.CallAsJson()
@@ -315,7 +325,7 @@ func (c *ComponentPricePointsController) CreateCurrencyPrices(
315325
)
316326
req.Authenticate(NewAuth("BasicAuth"))
317327
req.AppendErrors(map[string]https.ErrorBuilder[error]{
318-
"422": {Message: "Unprocessable Entity (WebDAV)", Unmarshaller: errors.NewErrorArrayMapResponse},
328+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorArrayMapResponse},
319329
})
320330
req.Header("Content-Type", "application/json")
321331
if body != nil {
@@ -350,7 +360,7 @@ func (c *ComponentPricePointsController) UpdateCurrencyPrices(
350360
)
351361
req.Authenticate(NewAuth("BasicAuth"))
352362
req.AppendErrors(map[string]https.ErrorBuilder[error]{
353-
"422": {Message: "Unprocessable Entity (WebDAV)", Unmarshaller: errors.NewErrorArrayMapResponse},
363+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorArrayMapResponse},
354364
})
355365
req.Header("Content-Type", "application/json")
356366
if body != nil {

configuration.go

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ type ConfigurationOptions func(*Configuration)
1515
// Configuration holds configuration settings.
1616
type Configuration struct {
1717
environment Environment
18-
subdomain string
19-
domain string
18+
site string
2019
httpConfiguration HttpConfiguration
2120
basicAuthCredentials BasicAuthCredentials
2221
}
@@ -46,17 +45,10 @@ func WithEnvironment(environment Environment) ConfigurationOptions {
4645
}
4746
}
4847

49-
// WithSubdomain is an option that sets the Subdomain in the Configuration.
50-
func WithSubdomain(subdomain string) ConfigurationOptions {
48+
// WithSite is an option that sets the Site in the Configuration.
49+
func WithSite(site string) ConfigurationOptions {
5150
return func(c *Configuration) {
52-
c.subdomain = subdomain
53-
}
54-
}
55-
56-
// WithDomain is an option that sets the Domain in the Configuration.
57-
func WithDomain(domain string) ConfigurationOptions {
58-
return func(c *Configuration) {
59-
c.domain = domain
51+
c.site = site
6052
}
6153
}
6254

@@ -79,14 +71,9 @@ func (c Configuration) Environment() Environment {
7971
return c.environment
8072
}
8173

82-
// Subdomain returns the subdomain from the Configuration.
83-
func (c Configuration) Subdomain() string {
84-
return c.subdomain
85-
}
86-
87-
// Domain returns the domain from the Configuration.
88-
func (c Configuration) Domain() string {
89-
return c.domain
74+
// Site returns the site from the Configuration.
75+
func (c Configuration) Site() string {
76+
return c.site
9077
}
9178

9279
// HttpConfiguration returns the httpConfiguration from the Configuration.
@@ -108,13 +95,9 @@ func CreateConfigurationFromEnvironment(options ...ConfigurationOptions) Configu
10895
if environment != "" {
10996
config.environment = Environment(environment)
11097
}
111-
subdomain := os.Getenv("ADVANCEDBILLING_SUBDOMAIN")
112-
if subdomain != "" {
113-
config.subdomain = subdomain
114-
}
115-
domain := os.Getenv("ADVANCEDBILLING_DOMAIN")
116-
if domain != "" {
117-
config.domain = domain
98+
site := os.Getenv("ADVANCEDBILLING_SITE")
99+
if site != "" {
100+
config.site = site
118101
}
119102
basicAuthUserName := os.Getenv("ADVANCEDBILLING_BASIC_AUTH_USER_NAME")
120103
if basicAuthUserName != "" {
@@ -134,15 +117,16 @@ func CreateConfigurationFromEnvironment(options ...ConfigurationOptions) Configu
134117
type Server string
135118

136119
const (
137-
ENUMDEFAULT Server = "default"
120+
PRODUCTION Server = "production"
121+
EBB Server = "ebb"
138122
)
139123

140124
// Environment represents available environments.
141125
type Environment string
142126

143127
const (
144-
PRODUCTION Environment = "production"
145-
ENVIRONMENT2 Environment = "environment2"
128+
US Environment = "US"
129+
EU Environment = "EU"
146130
)
147131

148132
// CreateRetryConfiguration creates a new RetryConfiguration with the provided options.

coupons_controller.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ func NewCouponsController(baseController baseController) *CouponsController {
3535
// Additionally, for documentation on how to apply a coupon to a subscription within the Advanced Billing UI, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions).
3636
// ## Create Coupon
3737
// This request will create a coupon, based on the provided information.
38-
// When creating a coupon, you must specify a product family using the `product_family_id`. If no `product_family_id` is passed, the first product family available is used. You will also need to formulate your URL to cite the Product Family ID in your request.
39-
// You can restrict a coupon to only apply to specific products / components by optionally passing in hashes of `restricted_products` and/or `restricted_components` in the format:
40-
// `{ "<product/component_id>": boolean_value }`
38+
// You can create either a flat amount coupon, by specyfing `amount_in_cents`, or percentage coupon by specyfing `percentage`.
39+
// You can restrict a coupon to only apply to specific products / components by optionally passing in `restricted_products` and/or `restricted_components` objects in the format:
40+
// `{ "<product_id/component_id>": boolean_value }`
4141
func (c *CouponsController) CreateCoupon(
4242
ctx context.Context,
4343
productFamilyId int,
44-
body *models.CreateOrUpdateCoupon) (
44+
body *models.CouponRequest) (
4545
models.ApiResponse[models.CouponResponse],
4646
error) {
4747
req := c.prepareRequest(
@@ -123,15 +123,16 @@ func (c *CouponsController) ListCouponsForProductFamily(
123123
return models.NewApiResponse(result, resp), err
124124
}
125125

126-
// FindCoupon takes context, productFamilyId, code as parameters and
126+
// FindCoupon takes context, productFamilyId, code, currencyPrices as parameters and
127127
// returns an models.ApiResponse with models.CouponResponse data and
128128
// an error if there was an issue with the request or response.
129129
// You can search for a coupon via the API with the find method. By passing a code parameter, the find will attempt to locate a coupon that matches that code. If no coupon is found, a 404 is returned.
130130
// If you have more than one product family and if the coupon you are trying to find does not belong to the default product family in your site, then you will need to specify (either in the url or as a query string param) the product family id.
131131
func (c *CouponsController) FindCoupon(
132132
ctx context.Context,
133133
productFamilyId *int,
134-
code *string) (
134+
code *string,
135+
currencyPrices *bool) (
135136
models.ApiResponse[models.CouponResponse],
136137
error) {
137138
req := c.prepareRequest(ctx, "GET", "/coupons/find.json")
@@ -142,6 +143,9 @@ func (c *CouponsController) FindCoupon(
142143
if code != nil {
143144
req.QueryParam("code", *code)
144145
}
146+
if currencyPrices != nil {
147+
req.QueryParam("currency_prices", *currencyPrices)
148+
}
145149
var result models.CouponResponse
146150
decoder, resp, err := req.CallAsJson()
147151
if err != nil {
@@ -152,7 +156,7 @@ func (c *CouponsController) FindCoupon(
152156
return models.NewApiResponse(result, resp), err
153157
}
154158

155-
// ReadCoupon takes context, productFamilyId, couponId as parameters and
159+
// ReadCoupon takes context, productFamilyId, couponId, currencyPrices as parameters and
156160
// returns an models.ApiResponse with models.CouponResponse data and
157161
// an error if there was an issue with the request or response.
158162
// You can retrieve the Coupon via the API with the Show method. You must identify the Coupon in this call by the ID parameter that Advanced Billing assigns.
@@ -162,7 +166,8 @@ func (c *CouponsController) FindCoupon(
162166
func (c *CouponsController) ReadCoupon(
163167
ctx context.Context,
164168
productFamilyId int,
165-
couponId int) (
169+
couponId int,
170+
currencyPrices *bool) (
166171
models.ApiResponse[models.CouponResponse],
167172
error) {
168173
req := c.prepareRequest(
@@ -171,6 +176,9 @@ func (c *CouponsController) ReadCoupon(
171176
fmt.Sprintf("/product_families/%v/coupons/%v.json", productFamilyId, couponId),
172177
)
173178
req.Authenticate(NewAuth("BasicAuth"))
179+
if currencyPrices != nil {
180+
req.QueryParam("currency_prices", *currencyPrices)
181+
}
174182

175183
var result models.CouponResponse
176184
decoder, resp, err := req.CallAsJson()
@@ -193,7 +201,7 @@ func (c *CouponsController) UpdateCoupon(
193201
ctx context.Context,
194202
productFamilyId int,
195203
couponId int,
196-
body *models.CreateOrUpdateCoupon) (
204+
body *models.CouponRequest) (
197205
models.ApiResponse[models.CouponResponse],
198206
error) {
199207
req := c.prepareRequest(
@@ -202,6 +210,9 @@ func (c *CouponsController) UpdateCoupon(
202210
fmt.Sprintf("/product_families/%v/coupons/%v.json", productFamilyId, couponId),
203211
)
204212
req.Authenticate(NewAuth("BasicAuth"))
213+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
214+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorListResponse},
215+
})
205216
req.Header("Content-Type", "application/json")
206217
if body != nil {
207218
req.Json(body)
@@ -380,6 +391,9 @@ func (c *CouponsController) CreateOrUpdateCouponCurrencyPrices(
380391
fmt.Sprintf("/coupons/%v/currency_prices.json", couponId),
381392
)
382393
req.Authenticate(NewAuth("BasicAuth"))
394+
req.AppendErrors(map[string]https.ErrorBuilder[error]{
395+
"422": {TemplatedMessage: "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", Unmarshaller: errors.NewErrorStringMapResponse},
396+
})
383397
req.Header("Content-Type", "application/json")
384398
if body != nil {
385399
req.Json(body)

default_configuration.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ func DefaultHttpConfiguration() HttpConfiguration {
3636
// DefaultConfiguration returns the default Configuration.
3737
func DefaultConfiguration() Configuration {
3838
return newConfiguration(
39-
WithEnvironment(PRODUCTION),
40-
WithSubdomain("subdomain"),
41-
WithDomain("chargify.com"),
39+
WithEnvironment(US),
40+
WithSite("subdomain"),
4241
WithHttpConfiguration(DefaultHttpConfiguration()),
4342
)
4443
}

0 commit comments

Comments
 (0)