Skip to content

Commit

Permalink
[DE-117] Update Payment profiles and Component price points
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-nedza authored Jan 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 12e69e6 + 56e5d9f commit 36ae9bd
Showing 88 changed files with 1,038 additions and 1,921 deletions.
6 changes: 6 additions & 0 deletions components_controller.go
Original file line number Diff line number Diff line change
@@ -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
}

@@ -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
}

8 changes: 1 addition & 7 deletions custom_fields_controller.go
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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)
}
26 changes: 19 additions & 7 deletions doc/controllers/components.md
Original file line number Diff line number Diff line change
@@ -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{
@@ -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

@@ -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

10 changes: 5 additions & 5 deletions doc/controllers/coupons.md
Original file line number Diff line number Diff line change
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
7 changes: 1 addition & 6 deletions doc/controllers/custom-fields.md
Original file line number Diff line number Diff line change
@@ -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)
@@ -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
@@ -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 {
2 changes: 1 addition & 1 deletion doc/controllers/invoices.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion doc/controllers/offers.md
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 36ae9bd

Please sign in to comment.