商品並び替え
curl --request PATCH \
--url https://api.utage-system.com/v1/products/reorder \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"groups": [
{
"product_group_id": "<string>",
"product_ids": [
"<string>"
]
}
]
}
'import requests
url = "https://api.utage-system.com/v1/products/reorder"
payload = { "groups": [
{
"product_group_id": "<string>",
"product_ids": ["<string>"]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({groups: [{product_group_id: '<string>', product_ids: ['<string>']}]})
};
fetch('https://api.utage-system.com/v1/products/reorder', 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.utage-system.com/v1/products/reorder",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'groups' => [
[
'product_group_id' => '<string>',
'product_ids' => [
'<string>'
]
]
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.utage-system.com/v1/products/reorder"
payload := strings.NewReader("{\n \"groups\": [\n {\n \"product_group_id\": \"<string>\",\n \"product_ids\": [\n \"<string>\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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))
}HttpResponse<String> response = Unirest.patch("https://api.utage-system.com/v1/products/reorder")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"groups\": [\n {\n \"product_group_id\": \"<string>\",\n \"product_ids\": [\n \"<string>\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.utage-system.com/v1/products/reorder")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"groups\": [\n {\n \"product_group_id\": \"<string>\",\n \"product_ids\": [\n \"<string>\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "<string>",
"name": "<string>",
"product_group_id": "<string>",
"order": 123
}
]
}商品
商品並び替え
商品を並び替えます(管理画面「商品管理」の「表示順変更」と同じ)。商品グループの並び順、各商品の所属する商品グループ、グループ内の商品の並び順を一括で更新します。
groups には、未分類(product_group_id が null)の要素を先頭に1つ置き、その後に全ての商品グループを1つずつ並べます(配列の順序がグループの表示順になります)。各要素の product_ids には、そのグループに所属させる商品のIDを並べたい順に指定します(空配列可)。アーカイブ済みを除く全ての商品を、いずれかの要素に重複なく含めてください。
次の場合は 422(validation_error。details はありません)を返します: 未分類の要素が先頭に1つだけ無い、product_group_id が重複している、商品グループに過不足がある、商品に過不足がある、アーカイブ済みの商品を指定した。
商品の所属グループだけを変えたい場合は、商品更新(PATCH /products/{product_id})の product_group_id でも変更できます。
商品並び替え
curl --request PATCH \
--url https://api.utage-system.com/v1/products/reorder \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"groups": [
{
"product_group_id": "<string>",
"product_ids": [
"<string>"
]
}
]
}
'import requests
url = "https://api.utage-system.com/v1/products/reorder"
payload = { "groups": [
{
"product_group_id": "<string>",
"product_ids": ["<string>"]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({groups: [{product_group_id: '<string>', product_ids: ['<string>']}]})
};
fetch('https://api.utage-system.com/v1/products/reorder', 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.utage-system.com/v1/products/reorder",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'groups' => [
[
'product_group_id' => '<string>',
'product_ids' => [
'<string>'
]
]
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.utage-system.com/v1/products/reorder"
payload := strings.NewReader("{\n \"groups\": [\n {\n \"product_group_id\": \"<string>\",\n \"product_ids\": [\n \"<string>\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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))
}HttpResponse<String> response = Unirest.patch("https://api.utage-system.com/v1/products/reorder")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"groups\": [\n {\n \"product_group_id\": \"<string>\",\n \"product_ids\": [\n \"<string>\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.utage-system.com/v1/products/reorder")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"groups\": [\n {\n \"product_group_id\": \"<string>\",\n \"product_ids\": [\n \"<string>\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "<string>",
"name": "<string>",
"product_group_id": "<string>",
"order": 123
}
]
}PATCH
https://api.utage-system.com/v1/products/reorder