Swift3 / easybill REST API / Create document payment
Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "document_id": "<long>",
// "amount": "<integer>",
// "id": "<long>",
// "is_overdue_fee": "<boolean>",
// "login_id": "<long>",
// "notice": "",
// "payment_at": "<date>",
// "type": "",
// "provider": "",
// "reference": ""
// }
let json = CkoJsonObject()!
json.update("document_id", value: "<long>")
json.update("amount", value: "<integer>")
json.update("id", value: "<long>")
json.update("is_overdue_fee", value: "<boolean>")
json.update("login_id", value: "<long>")
json.update("notice", value: "")
json.update("payment_at", value: "<date>")
json.update("type", value: "")
json.update("provider", value: "")
json.update("reference", value: "")
http.setRequestHeader("Content-Type", value: "application/json")
http.setRequestHeader("Authorization", value: "{{apiKey}}")
http.setRequestHeader("Accept", value: "application/json")
var resp: CkoHttpResponse? = http.postJson3("https://api.easybill.de/rest/v1/document-payments?paid=<boolean>", contentType: "application/json", json: json)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "document_id": "<long>",
// "amount": "<integer>",
// "id": "<long>",
// "is_overdue_fee": "<boolean>",
// "login_id": "<long>",
// "notice": "",
// "payment_at": "<date>",
// "type": "",
// "provider": "",
// "reference": ""
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var document_id: String? = jResp.string(of: "document_id")
var amount: String? = jResp.string(of: "amount")
var id: String? = jResp.string(of: "id")
var is_overdue_fee: String? = jResp.string(of: "is_overdue_fee")
var login_id: String? = jResp.string(of: "login_id")
var notice: String? = jResp.string(of: "notice")
var payment_at: String? = jResp.string(of: "payment_at")
var v_type: String? = jResp.string(of: "type")
var provider: String? = jResp.string(of: "provider")
var reference: String? = jResp.string(of: "reference")
}
Curl Command
curl -X POST
-H "Authorization: {{apiKey}}"
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"document_id": "<long>",
"amount": "<integer>",
"id": "<long>",
"is_overdue_fee": "<boolean>",
"login_id": "<long>",
"notice": "",
"payment_at": "<date>",
"type": "",
"provider": "",
"reference": ""
}'
https://api.easybill.de/rest/v1/document-payments?paid=<boolean>
Postman Collection Item JSON
{
"name": "Create document payment",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"document_id\": \"<long>\",\n \"amount\": \"<integer>\",\n \"id\": \"<long>\",\n \"is_overdue_fee\": \"<boolean>\",\n \"login_id\": \"<long>\",\n \"notice\": \"\",\n \"payment_at\": \"<date>\",\n \"type\": \"\",\n \"provider\": \"\",\n \"reference\": \"\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/document-payments?paid=<boolean>",
"host": [
"{{baseUrl}}"
],
"path": [
"document-payments"
],
"query": [
{
"key": "paid",
"value": "<boolean>",
"description": "Mark document as paid when amount less then payment amount."
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"document_id\": \"<long>\",\n \"amount\": \"<integer>\",\n \"id\": \"<long>\",\n \"is_overdue_fee\": \"<boolean>\",\n \"login_id\": \"<long>\",\n \"notice\": \"\",\n \"payment_at\": \"<date>\",\n \"type\": \"\",\n \"provider\": \"\",\n \"reference\": \"\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/document-payments?paid=<boolean>",
"host": [
"{{baseUrl}}"
],
"path": [
"document-payments"
],
"query": [
{
"key": "paid",
"value": "<boolean>",
"description": "Mark document as paid when amount less then payment amount."
}
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"document_id\": \"<long>\",\n \"amount\": \"<integer>\",\n \"id\": \"<long>\",\n \"is_overdue_fee\": \"<boolean>\",\n \"login_id\": \"<long>\",\n \"notice\": \"\",\n \"payment_at\": \"<date>\",\n \"type\": \"\",\n \"provider\": \"\",\n \"reference\": \"\"\n}"
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"document_id\": \"<long>\",\n \"amount\": \"<integer>\",\n \"id\": \"<long>\",\n \"is_overdue_fee\": \"<boolean>\",\n \"login_id\": \"<long>\",\n \"notice\": \"\",\n \"payment_at\": \"<date>\",\n \"type\": \"\",\n \"provider\": \"\",\n \"reference\": \"\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/document-payments?paid=<boolean>",
"host": [
"{{baseUrl}}"
],
"path": [
"document-payments"
],
"query": [
{
"key": "paid",
"value": "<boolean>",
"description": "Mark document as paid when amount less then payment amount."
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}