Chilkat Online Tools

SQL Server / Plivo REST API / Retrieve pricing for a country

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OASetProperty @http, 'BasicAuth', 1
    EXEC sp_OASetProperty @http, 'Login', '{{auth_id}}'
    EXEC sp_OASetProperty @http, 'Password', 'password'

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'country_iso', 'US'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.plivo.com/v1/Account/<auth_id>/Pricing/', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams


END
GO

Curl Command

curl -G -d "country_iso=US"
	-u '{{auth_id}}:password'
https://api.plivo.com/v1/Account/<auth_id>/Pricing/

Postman Collection Item JSON

{
  "name": "Retrieve pricing for a country",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Pricing/?country_iso=US",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Pricing",
        ""
      ],
      "query": [
        {
          "key": "country_iso",
          "value": "US",
          "description": "The 2 digit country ISO code. For example, US for United States."
        }
      ]
    },
    "description": "Retrieves pricing for a specified country.\n\nBelow is the list of arguments that can be passed in this API request, more information can be found [here](https://www.plivo.com/docs/account/api/pricing#the-pricing-object)\n\n| Arguments   | Description | Required/Conditional/Optional     |\n| :---        |    :----:   |          ---: |\n| country_iso      | The 2 digit country ISO code. For example, US for United States.| Required |"
  },
  "response": [
    {
      "name": "Retrieve pricing for a country",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Pricing/?country_iso=US",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Pricing",
            ""
          ],
          "query": [
            {
              "key": "country_iso",
              "value": "US",
              "description": "The 2 digit country ISO code. For example, US for United States."
            }
          ]
        }
      },
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
      ],
      "cookie": [
      ],
      "body": "{\n    \"api_id\": \"7ff5505c-93ca-11e7-9bde-024427e23b8a\",\n    \"country\": \"United States\",\n    \"country_code\": 1,\n    \"country_iso\": \"US\",\n    \"message\": {\n        \"inbound\": {\n            \"rate\": \"0.00000\"\n        },\n        \"outbound\": {\n            \"rate\": \"0.00350\"\n        },\n        \"outbound_networks_list\": [\n            {\n                \"group_name\": \"US\",\n                \"rate\": \"0.00350\"\n            },\n            {\n                \"group_name\": \"United States - AT&T Mobility\",\n                \"rate\": \"0.00350\"\n            }\n        ]\n    },\n    \"phone_numbers\": {\n        \"local\": {\n            \"rate\": \"0.80000\"\n        },\n        \"tollfree\": {\n            \"rate\": \"1.00000\"\n        }\n    },\n    \"voice\": {\n        \"inbound\": {\n            \"ip\": {\n                \"rate\": \"0.00300\"\n            },\n            \"local\": {\n                \"rate\": \"0.00850\"\n            },\n            \"tollfree\": {\n                \"rate\": \"0.02100\"\n            }\n        },\n        \"outbound\": {\n            \"ip\": {\n                \"rate\": \"0.00300\"\n            },\n            \"local\": {\n                \"rate\": \"0.00750\"\n            },\n            \"rates\": [\n                {\n                    \"prefix\": [\n                        \"1\"\n                    ],\n                    \"rate\": \"0.00750\"\n                }\n            ],\n            \"tollfree\": {\n                \"rate\": null\n            }\n        }\n    }\n}"
    }
  ]
}