فیلدهای دفترچه
هر دفترچه میتواند فیلدهای سفارشی داشته باشد؛ مقدار آنها برای هر مخاطب جدا ذخیره میشود و در کمپینها به پارامتر الگو نگاشت میشود.
ساختار فیلد
| فیلد | نوع | الزامی | توضیح |
|---|---|---|---|
key | رشته | خیر | کلید انگلیسی، حداکثر ۳۲ نویسه. اگر ارسال نشود، خودکار field1, field2, … ساخته میشود |
title | رشته | بله | عنوان، یکتا در هر دفترچه و حداکثر ۵۰ نویسه |
type | عدد | بله | نوع فیلد؛ جدول زیر |
type | نوع | قالب مقدار |
|---|---|---|
0 | متن | حداکثر ۵۰۰ نویسه |
1 | عدد | عددی |
2 | تاریخ | شمسی یا میلادی |
3 | بولی | مقدار درست/نادرست |
4 | تاریخ و ساعت | شمسی یا میلادی، به وقت تهران |
حداکثر ۳۰ فیلد در هر دفترچه مجاز است.
دریافت فیلدها
GET /cms/api/Category/GetFields/{id}
- curl
- C#
- Python
- Node.js
- PHP
- Go
curl -X GET "https://api.payavasms.com/cms/api/Category/GetFields/CATEGORY_ID" \
-H "X-Api-Key: YOUR_API_KEY"
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "YOUR_API_KEY");
var response = await client.GetAsync("https://api.payavasms.com/cms/api/Category/GetFields/CATEGORY_ID");
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
import requests
url = "https://api.payavasms.com/cms/api/Category/GetFields/CATEGORY_ID"
headers = {
"X-Api-Key": "YOUR_API_KEY",
}
response = requests.get(url, headers=headers)
print(response.status_code, response.text)
const response = await fetch("https://api.payavasms.com/cms/api/Category/GetFields/CATEGORY_ID", {
method: "GET",
headers: {
"X-Api-Key": "YOUR_API_KEY",
},
});
console.log(response.status, await response.text());
<?php
$ch = curl_init("https://api.payavasms.com/cms/api/Category/GetFields/CATEGORY_ID");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: YOUR_API_KEY",
],
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . " " . $response;
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.payavasms.com/cms/api/Category/GetFields/CATEGORY_ID", nil)
req.Header.Set("X-Api-Key", "YOUR_API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(data))
}
[
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]
ایجاد یا ویرایش فیلدها
POST /cms/api/Category/UpsertFields/{id}
بدنه آرایهای از فیلدهاست.
- curl
- C#
- Python
- Node.js
- PHP
- Go
curl -X POST "https://api.payavasms.com/cms/api/Category/UpsertFields/CATEGORY_ID" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]'
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "YOUR_API_KEY");
var json = """
[
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]
""";
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.payavasms.com/cms/api/Category/UpsertFields/CATEGORY_ID", content);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
import requests
url = "https://api.payavasms.com/cms/api/Category/UpsertFields/CATEGORY_ID"
headers = {
"X-Api-Key": "YOUR_API_KEY",
}
payload = [
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]
response = requests.post(url, headers=headers, json=payload)
print(response.status_code, response.text)
const response = await fetch("https://api.payavasms.com/cms/api/Category/UpsertFields/CATEGORY_ID", {
method: "POST",
headers: {
"X-Api-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify([
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]),
});
console.log(response.status, await response.text());
<?php
$ch = curl_init("https://api.payavasms.com/cms/api/Category/UpsertFields/CATEGORY_ID");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: YOUR_API_KEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => <<<'JSON'
[
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]
JSON,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . " " . $response;
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`[
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]`)
req, _ := http.NewRequest("POST", "https://api.payavasms.com/cms/api/Category/UpsertFields/CATEGORY_ID", body)
req.Header.Set("X-Api-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(data))
}
[
{
"key": "city",
"title": "شهر",
"type": 0
},
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]
حذف فیلدها
POST /cms/api/Category/DeleteFields/{id}
بدنه آرایهای از keyها است. پاسخ فیلدهای باقیمانده است.
- curl
- C#
- Python
- Node.js
- PHP
- Go
curl -X POST "https://api.payavasms.com/cms/api/Category/DeleteFields/CATEGORY_ID" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '[
"city"
]'
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "YOUR_API_KEY");
var json = """
[
"city"
]
""";
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.payavasms.com/cms/api/Category/DeleteFields/CATEGORY_ID", content);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
import requests
url = "https://api.payavasms.com/cms/api/Category/DeleteFields/CATEGORY_ID"
headers = {
"X-Api-Key": "YOUR_API_KEY",
}
payload = [
"city"
]
response = requests.post(url, headers=headers, json=payload)
print(response.status_code, response.text)
const response = await fetch("https://api.payavasms.com/cms/api/Category/DeleteFields/CATEGORY_ID", {
method: "POST",
headers: {
"X-Api-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify([
"city"
]),
});
console.log(response.status, await response.text());
<?php
$ch = curl_init("https://api.payavasms.com/cms/api/Category/DeleteFields/CATEGORY_ID");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: YOUR_API_KEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => <<<'JSON'
[
"city"
]
JSON,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . " " . $response;
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`[
"city"
]`)
req, _ := http.NewRequest("POST", "https://api.payavasms.com/cms/api/Category/DeleteFields/CATEGORY_ID", body)
req.Header.Set("X-Api-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(data))
}
[
{
"key": "birth",
"title": "تاریخ تولد",
"type": 2
}
]