Туторіал

Створення плану

Створення плану закупівлі

Створимо план

POST /api/2.3/plans?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 2454
Content-Type: application/json
Host: api-sandbox.openprocurement.org

{
  "data": {
    "classification": {
      "scheme": "ДК021",
      "description": "Seeds",
      "id": "03111000-2"
    },
    "items": [
      {
        "description": "Насіння гірчиці",
        "classification": {
          "scheme": "ДК021",
          "description": "Mustard seeds",
          "id": "03111600-8"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.92",
            "description": "Насіння гірчиці"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-06T17:41:39.677983"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 1000
      },
      {
        "description": "Насіння соняшнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Sunflower seeds",
          "id": "03111300-5"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.95",
            "description": "Насіння соняшнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-07T17:41:39.677983"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 2000
      },
      {
        "description": "Насіння бавовнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Cotton seeds",
          "id": "03111400-6"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.84",
            "description": "Насіння бавовнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-08T17:41:39.677983"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 3000
      }
    ],
    "budget": {
      "amountNet": 12222,
      "description": "budget_description",
      "project": {
        "name": "proj_name",
        "id": "123"
      },
      "currency": "UAH",
      "amount": 10000,
      "id": "12303111000-2"
    },
    "additionalClassifications": [
      {
        "scheme": "КЕКВ",
        "id": "1",
        "description": "-"
      }
    ],
    "procuringEntity": {
      "identifier": {
        "scheme": "UA-EDR",
        "id": "111983",
        "legalName": "ДП Державне Управління Справами"
      },
      "name": "ДУС"
    },
    "tender": {
      "procurementMethod": "open",
      "procurementMethodType": "belowThreshold",
      "tenderPeriod": {
        "startDate": "2017-06-28T17:41:39.677983"
      }
    }
  }
}

Response: 201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.openprocurement.org/api/2.3/plans/52862ec099ff4debbf9f26a0980f27f3
{
  "access": {
    "token": "fc9c0f555bf24dffa2b855ed618bc81c"
  },
  "data": {
    "classification": {
      "scheme": "ДК021",
      "description": "Seeds",
      "id": "03111000-2"
    },
    "items": [
      {
        "description": "Насіння гірчиці",
        "classification": {
          "scheme": "ДК021",
          "description": "Mustard seeds",
          "id": "03111600-8"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.92",
            "description": "Насіння гірчиці"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-06T17:41:39.677983+03:00"
        },
        "id": "f8173e5bf8754aec89a47a624b3cefd1",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 1000
      },
      {
        "description": "Насіння соняшнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Sunflower seeds",
          "id": "03111300-5"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.95",
            "description": "Насіння соняшнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-07T17:41:39.677983+03:00"
        },
        "id": "3b0208637aa44a99b388a9b540533a1c",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 2000
      },
      {
        "description": "Насіння бавовнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Cotton seeds",
          "id": "03111400-6"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.84",
            "description": "Насіння бавовнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-08T17:41:39.677983+03:00"
        },
        "id": "7266c3c7b95246718021ab671207335e",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 3000
      }
    ],
    "planID": "UA-P-2017-06-21-000001",
    "budget": {
      "amountNet": 12222.0,
      "description": "budget_description",
      "project": {
        "id": "123",
        "name": "proj_name"
      },
      "currency": "UAH",
      "amount": 10000.0,
      "id": "12303111000-2"
    },
    "datePublished": "2017-06-21T17:41:40.564867+03:00",
    "tender": {
      "procurementMethod": "open",
      "procurementMethodType": "belowThreshold",
      "tenderPeriod": {
        "startDate": "2017-06-28T17:41:39.677983+03:00"
      }
    },
    "additionalClassifications": [
      {
        "scheme": "КЕКВ",
        "id": "1",
        "description": "-"
      }
    ],
    "procuringEntity": {
      "identifier": {
        "scheme": "UA-EDR",
        "id": "111983",
        "legalName": "ДП Державне Управління Справами"
      },
      "name": "ДУС"
    },
    "owner": "broker",
    "dateModified": "2017-06-21T17:41:40.588719+03:00",
    "id": "52862ec099ff4debbf9f26a0980f27f3"
  }
}

Ми отримали код відповіді 201 Created, заголовок Location і тіло з додатковим ідентифікатором id, planID та властивість dateModified - дату, що показує час, коли план закупівлі востаннє модифікувався.

Перевіримо, що містить реєстр планів закупівель:

GET /api/2.3/plans HTTP/1.0
Host: api-sandbox.openprocurement.org

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
  "next_page": {
    "path": "/api/2.3/plans?offset=",
    "uri": "http://api-sandbox.openprocurement.org/api/2.3/plans?offset=",
    "offset": ""
  },
  "data": []
}

Відображається id - внутрішній ідентифікатор (який можна використовувати, щоб побудувати повну URL-адресу, додаючи http://api-sandbox.openprocurement.org/api/0/plans/ на початку) та мітка часу dateModified.

Модифікація плану закупівлі

Оновимо план шляхом надання їй усіх інших важливих властивостей:

PATCH /api/2.3/plans/52862ec099ff4debbf9f26a0980f27f3?acc_token=fc9c0f555bf24dffa2b855ed618bc81c HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 652
Content-Type: application/json
Host: api-sandbox.openprocurement.org

{
  "data": {
    "items": [
      {
        "description": "Насіння овочевих культур",
        "classification": {
          "scheme": "ДК021",
          "description": "Vegetable seeds",
          "id": "03111700-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.13.6",
            "description": "Насіння овочевих культур"
          }
        ],
        "deliveryDate": {
          "endDate": "2016-06-01T23:06:30.023018+03:00"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 5000
      }
    ]
  }
}

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
  "data": {
    "classification": {
      "scheme": "ДК021",
      "description": "Seeds",
      "id": "03111000-2"
    },
    "items": [
      {
        "description": "Насіння овочевих культур",
        "classification": {
          "scheme": "ДК021",
          "description": "Vegetable seeds",
          "id": "03111700-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.13.6",
            "description": "Насіння овочевих культур"
          }
        ],
        "deliveryDate": {
          "endDate": "2016-06-01T23:06:30.023018+03:00"
        },
        "id": "f8173e5bf8754aec89a47a624b3cefd1",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 5000
      }
    ],
    "planID": "UA-P-2017-06-21-000001",
    "budget": {
      "amountNet": 12222.0,
      "description": "budget_description",
      "project": {
        "id": "123",
        "name": "proj_name"
      },
      "currency": "UAH",
      "amount": 10000.0,
      "id": "12303111000-2"
    },
    "datePublished": "2017-06-21T17:41:40.564867+03:00",
    "tender": {
      "procurementMethod": "open",
      "procurementMethodType": "belowThreshold",
      "tenderPeriod": {
        "startDate": "2017-06-28T17:41:39.677983+03:00"
      }
    },
    "additionalClassifications": [
      {
        "scheme": "КЕКВ",
        "id": "1",
        "description": "-"
      }
    ],
    "procuringEntity": {
      "identifier": {
        "scheme": "UA-EDR",
        "id": "111983",
        "legalName": "ДП Державне Управління Справами"
      },
      "name": "ДУС"
    },
    "owner": "broker",
    "dateModified": "2017-06-21T17:41:40.747307+03:00",
    "id": "52862ec099ff4debbf9f26a0980f27f3"
  }
}

Ми бачимо, що додаткові властивості об’єднані з існуючими даними плану. Додатково оновлена властивість dateModified, щоб відображати останню дату модифікації.

Ще одна перевірка списку відображає нову дату модифікації:

GET /api/2.3/plans HTTP/1.0
Host: api-sandbox.openprocurement.org

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
  "next_page": {
    "path": "/api/2.3/plans?offset=2017-06-21T17%3A41%3A40.588719%2B03%3A00",
    "uri": "http://api-sandbox.openprocurement.org/api/2.3/plans?offset=2017-06-21T17%3A41%3A40.588719%2B03%3A00",
    "offset": "2017-06-21T17:41:40.588719+03:00"
  },
  "data": [
    {
      "id": "52862ec099ff4debbf9f26a0980f27f3",
      "dateModified": "2017-06-21T17:41:40.588719+03:00"
    }
  ]
}