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-117] Update Payment profiles and Component price points #7

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions components_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ func (c *ComponentsController) UpdateComponentPricePoint(
return models.NewApiResponse(result, resp), err
}

if resp.StatusCode == 422 {
err = errors.NewErrorArrayMapResponse(422, "Unprocessable Entity (WebDAV)")
}
return models.NewApiResponse(result, resp), err
}

Expand Down Expand Up @@ -648,6 +651,9 @@ func (c *ComponentsController) ArchiveComponentPricePoint(
return models.NewApiResponse(result, resp), err
}

if resp.StatusCode == 422 {
err = errors.NewErrorListResponse(422, "Unprocessable Entity (WebDAV)")
}
return models.NewApiResponse(result, resp), err
}

Expand Down
8 changes: 1 addition & 7 deletions custom_fields_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,13 @@ func (c *CustomFieldsController) ListMetafields(
return models.NewApiResponse(result, resp), err
}

// UpdateMetafield takes context, resourceType, name, currentName, body as parameters and
// UpdateMetafield takes context, resourceType, body as parameters and
// returns an models.ApiResponse with []models.Metafield data and
// an error if there was an issue with the request or response.
// Use the following method to update metafields for your Site. Metafields can be populated with metadata after the fact.
func (c *CustomFieldsController) UpdateMetafield(
ctx context.Context,
resourceType models.ResourceType,
name string,
currentName *string,
body *models.UpdateMetafieldsRequest) (
models.ApiResponse[[]models.Metafield],
error) {
Expand All @@ -144,10 +142,6 @@ func (c *CustomFieldsController) UpdateMetafield(
)
req.Authenticate(true)
req.Header("Content-Type", "application/json")
req.QueryParam("name", name)
if currentName != nil {
req.QueryParam("current_name", *currentName)
}
if body != nil {
req.Json(*body)
}
Expand Down
26 changes: 19 additions & 7 deletions doc/controllers/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -1232,24 +1232,24 @@ pricePointId := 10

bodyPricePointPrices0 := models.UpdatePrice{
Id: models.ToPointer(1),
EndingQuantity: models.ToPointer(100),
UnitPrice: models.ToPointer(5),
EndingQuantity: models.ToPointer(interface{}("[key1, val1][key2, val2]")),
UnitPrice: models.ToPointer(interface{}("[key1, val1][key2, val2]")),
}

bodyPricePointPrices1 := models.UpdatePrice{
Id: models.ToPointer(2),
Destroy: models.ToPointer("true"),
Destroy: models.ToPointer(true),
}

bodyPricePointPrices2 := models.UpdatePrice{
UnitPrice: models.ToPointer(4),
StartingQuantity: models.ToPointer(101),
UnitPrice: models.ToPointer(interface{}("[key1, val1][key2, val2]")),
StartingQuantity: models.ToPointer(interface{}("[key1, val1][key2, val2]")),
}

bodyPricePointPrices := []models.UpdatePrice{bodyPricePointPrices0, bodyPricePointPrices1, bodyPricePointPrices2}
bodyPricePoint := models.UpdateComponentPricePoint{
Name: models.ToPointer("Default"),
Prices: bodyPricePointPrices,
Name: models.ToPointer("Default"),
Prices: bodyPricePointPrices,
}

body := models.UpdateComponentPricePointRequest{
Expand All @@ -1266,6 +1266,12 @@ if err != nil {
}
```

## Errors

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 422 | Unprocessable Entity (WebDAV) | [`ErrorArrayMapResponseException`](../../doc/models/error-array-map-response-exception.md) |


# Archive Component Price Point

Expand Down Expand Up @@ -1342,6 +1348,12 @@ if err != nil {
}
```

## Errors

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 422 | Unprocessable Entity (WebDAV) | [`ErrorListResponseException`](../../doc/models/error-list-response-exception.md) |


# Unarchive Component Price Point

Expand Down
10 changes: 5 additions & 5 deletions doc/controllers/coupons.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ if err != nil {
"updated_at": "2016-10-21T17:06:11-04:00",
"start_date": "2016-10-21T17:02:08-04:00",
"end_date": null,
"percentage": 50,
"percentage": "50",
"recurring": true,
"duration_period_count": null,
"duration_interval": 1,
Expand All @@ -192,7 +192,7 @@ if err != nil {
"updated_at": "2016-10-21T17:06:11-04:00",
"start_date": "2016-10-21T17:02:08-04:00",
"end_date": null,
"percentage": 50,
"percentage": "50",
"recurring": true,
"duration_period_count": null,
"duration_interval": 1,
Expand All @@ -218,7 +218,7 @@ if err != nil {
"updated_at": "2016-10-21T17:06:11-04:00",
"start_date": "2016-10-21T17:02:08-04:00",
"end_date": null,
"percentage": 25,
"percentage": "25",
"recurring": true,
"duration_period_count": null,
"duration_interval": 1,
Expand Down Expand Up @@ -348,7 +348,7 @@ if err != nil {
"updated_at": "2017-11-08T10:01:15-05:00",
"start_date": "2017-11-08T10:01:15-05:00",
"end_date": null,
"percentage": 33.3333,
"percentage": "33.3333",
"duration_period_count": null,
"duration_interval": null,
"duration_interval_unit": null,
Expand Down Expand Up @@ -612,7 +612,7 @@ if err != nil {
"product_family_name": "string",
"start_date": "string",
"end_date": "string",
"percentage": 0,
"percentage": "10",
"recurring": true,
"recurring_scheme": "do_not_recur",
"duration_period_count": 0,
Expand Down
7 changes: 1 addition & 6 deletions doc/controllers/custom-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ Use the following method to update metafields for your Site. Metafields can be p
UpdateMetafield(
ctx context.Context,
resourceType models.ResourceType,
name string,
currentName *string,
body *models.UpdateMetafieldsRequest) (
models.ApiResponse[[]models.Metafield],
error)
Expand All @@ -220,8 +218,6 @@ UpdateMetafield(
| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `resourceType` | [`models.ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong |
| `name` | `string` | Query, Required | Name of the custom field. |
| `currentName` | `*string` | Query, Optional | This only applies when you are updating an existing record and you wish to rename the field. Note you must supply name and current_name to rename the field |
| `body` | [`*models.UpdateMetafieldsRequest`](../../doc/models/update-metafields-request.md) | Body, Optional | - |

## Response Type
Expand All @@ -233,9 +229,8 @@ UpdateMetafield(
```go
ctx := context.Background()
resourceType := models.ResourceType("subscriptions")
name := "name0"

apiResponse, err := customFieldsController.UpdateMetafield(ctx, resourceType, name, nil, nil)
apiResponse, err := customFieldsController.UpdateMetafield(ctx, resourceType, nil)
if err != nil {
log.Fatalln(err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion doc/controllers/invoices.md
Original file line number Diff line number Diff line change
Expand Up @@ -2735,7 +2735,7 @@ if err != nil {

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 422 | Unprocessable Entity (WebDAV) | [`NestedErrorResponseException`](../../doc/models/nested-error-response-exception.md) |
| 422 | Unprocessable Entity (WebDAV) | [`ErrorArrayMapResponseException`](../../doc/models/error-array-map-response-exception.md) |


# Send Invoice
Expand Down
2 changes: 1 addition & 1 deletion doc/controllers/offers.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ if err != nil {

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 422 | Unprocessable Entity (WebDAV) | [`ErrorMapResponseException`](../../doc/models/error-map-response-exception.md) |
| 422 | Unprocessable Entity (WebDAV) | [`ErrorArrayMapResponseException`](../../doc/models/error-array-map-response-exception.md) |


# List Offers
Expand Down
Loading
Loading