Update CounterPricing - m3ter Documentation

Update CounterPricing

cURL

curl --request PUT \
  --url https://api.m3ter.com/organizations/{orgId}/counterpricings/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "startDate": "2023-11-07T05:31:56Z",
  "pricingBands": [
    {
      "lowerLimit": 1,
      "fixedPrice": 123,
      "unitPrice": 123,
      "id": "<string>",
      "creditTypeId": "<string>"
    }
  ],
  "counterId": "<string>",
  "version": 123,
  "code": "<string>",
  "planId": "<string>",
  "planTemplateId": "<string>",
  "cumulative": true,
  "endDate": "2023-11-07T05:31:56Z",
  "description": "<string>",
  "accountingProductId": "<string>",
  "runningTotalBillInAdvance": true,
  "proRateRunningTotal": true,
  "proRateAdjustmentDebit": true,
  "proRateAdjustmentCredit": true
}
'

Python

import requests

url = "https://api.m3ter.com/organizations/{orgId}/counterpricings/{id}"

payload = {
    "startDate": "2023-11-07T05:31:56Z",
    "pricingBands": [
        {
            "lowerLimit": 1,
            "fixedPrice": 123,
            "unitPrice": 123,
            "id": "<string>",
            "creditTypeId": "<string>"
        }
    ],
    "counterId": "<string>",
    "version": 123,
    "code": "<string>",
    "planId": "<string>",
    "planTemplateId": "<string>",
    "cumulative": True,
    "endDate": "2023-11-07T05:31:56Z",
    "description": "<string>",
    "accountingProductId": "<string>",
    "runningTotalBillInAdvance": True,
    "proRateRunningTotal": True,
    "proRateAdjustmentDebit": True,
    "proRateAdjustmentCredit": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

JavaScript

const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    startDate: '2023-11-07T05:31:56Z',
    pricingBands: [
      {
        lowerLimit: 1,
        fixedPrice: 123,
        unitPrice: 123,
        id: '<string>',
        creditTypeId: '<string>'
      }
    ],
    counterId: '<string>',
    version: 123,
    code: '<string>',
    planId: '<string>',
    planTemplateId: '<string>',
    cumulative: true,
    endDate: '2023-11-07T05:31:56Z',
    description: '<string>',
    accountingProductId: '<string>',
    runningTotalBillInAdvance: true,
    proRateRunningTotal: true,
    proRateAdjustmentDebit: true,
    proRateAdjustmentCredit: true
  })
};

fetch('https://api.m3ter.com/organizations/{orgId}/counterpricings/{id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/counterpricings/{id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'startDate' => '2023-11-07T05:31:56Z',
    'pricingBands' => [
        [
                'lowerLimit' => 1,
                'fixedPrice' => 123,
                'unitPrice' => 123,
                'id' => '<string>',
                'creditTypeId' => '<string>'
        ]
    ],
    'counterId' => '<string>',
    'version' => 123,
    'code' => '<string>',
    'planId' => '<string>',
    'planTemplateId' => '<string>',
    'cumulative' => true,
    'endDate' => '2023-11-07T05:31:56Z',
    'description' => '<string>',
    'accountingProductId' => '<string>',
    'runningTotalBillInAdvance' => true,
    'proRateRunningTotal' => true,
    'proRateAdjustmentDebit' => true,
    'proRateAdjustmentCredit' => true
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://api.m3ter.com/organizations/{orgId}/counterpricings/{id}"

payload := strings.NewReader("{\n  \"startDate\": \"2023-11-07T05:31:56Z\",\n  \"pricingBands\": [\n    {\n      \"lowerLimit\": 1,\n      \"fixedPrice\": 123,\n      \"unitPrice\": 123,\n      \"id\": \"<string>\",\n      \"creditTypeId\": \"<string>\"\n    }\n  ],\n  \"counterId\": \"<string>\",\n  \"version\": 123,\n  \"code\": \"<string>\",\n  \"planId\": \"<string>\",\n  \"planTemplateId\": \"<string>\",\n  \"cumulative\": true,\n  \"endDate\": \"2023-11-07T05:31:56Z\",\n  \"description\": \"<string>\",\n  \"accountingProductId\": \"<string>\",\n  \"runningTotalBillInAdvance\": true,\n  \"proRateRunningTotal\": true,\n  \"proRateAdjustmentDebit\": true,\n  \"proRateAdjustmentCredit\": true\}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Response Schema

{
  "id": "<string>",
  "version": 123,
  "dtCreated": "2023-11-07T05:31:56Z",
  "dtLastModified": "2023-11-07T05:31:56Z",
  "createdBy": "<string>",
  "lastModifiedBy": "<string>",
  "planId": "<string>",
  "planTemplateId": "<string>",
  "cumulative": true,
  "startDate": "2023-11-07T05:31:56Z",
  "endDate": "2023-11-07T05:31:56Z",
  "code": "<string>",
  "description": "<string>",
  "accountingProductId": "<string>",
  "pricingBands": [
    {
      "lowerLimit": 1,
      "fixedPrice": 123,
      "unitPrice": 123,
      "id": "<string>",
      "creditTypeId": "<string>"
    }
  ],
  "counterId": "<string>",
  "runningTotalBillInAdvance": true,
  "proRateRunningTotal": true,
  "proRateAdjustmentDebit": true,
  "proRateAdjustmentCredit": true
}

Error Responses

{
  "message": "<string>"
}