Definir ofertas do checkout
curl --request PUT \
--url https://api.ephra.io/v1/checkouts/{checkoutId}/offers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"offerIds": [
4821,
4822
],
"defaultOfferId": 4821
}
'import requests
url = "https://api.ephra.io/v1/checkouts/{checkoutId}/offers"
payload = {
"offerIds": [4821, 4822],
"defaultOfferId": 4821
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({offerIds: [4821, 4822], defaultOfferId: 4821})
};
fetch('https://api.ephra.io/v1/checkouts/{checkoutId}/offers', 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.ephra.io/v1/checkouts/{checkoutId}/offers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'offerIds' => [
4821,
4822
],
'defaultOfferId' => 4821
]),
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.ephra.io/v1/checkouts/{checkoutId}/offers"
payload := strings.NewReader("{\n \"offerIds\": [\n 4821,\n 4822\n ],\n \"defaultOfferId\": 4821\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.ephra.io/v1/checkouts/{checkoutId}/offers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"offerIds\": [\n 4821,\n 4822\n ],\n \"defaultOfferId\": 4821\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ephra.io/v1/checkouts/{checkoutId}/offers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"offerIds\": [\n 4821,\n 4822\n ],\n \"defaultOfferId\": 4821\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "clx9f1m2p0004qz0a7h8j9k0l",
"defaultOfferId": 4821,
"offers": [
{
"id": 4821,
"slug": "trafego-pago-anual",
"title": "Plano anual",
"price": 149900,
"isDefault": true,
"active": true,
"promotional": false,
"frequency": "annual",
"expiresAt": null,
"sortOrder": 0
},
{
"id": 4822,
"slug": "trafego-pago-mensal",
"title": "Plano mensal",
"price": 14900,
"isDefault": false,
"active": true,
"promotional": false,
"frequency": "monthly",
"expiresAt": null,
"sortOrder": 1
}
]
}
}{
"success": false,
"message": "Não foi possível concluir: uma regra de negócio recusou os dados enviados."
}{
"success": false,
"message": "Token inválido ou expirado"
}{
"success": false,
"message": "Checkout não encontrado"
}{
"success": false,
"message": "name: Nome é obrigatório"
}{
"success": false,
"message": "Muitas requisições. Tente novamente em breve."
}{
"success": false,
"message": "Erro interno do servidor"
}Checkout
Definir ofertas do checkout
Substitui, de uma vez, o conjunto de ofertas que este checkout vende e diz qual delas abre pela URL. A ordem do array é a ordem em que o comprador vê os preços na página. Oferta que sai da lista volta ao escopo do produto; oferta presa a outro checkout é recusada com 400 em vez de roubada. Responde 404 quando o checkout pertence a outra empresa.
PUT
/
v1
/
checkouts
/
{checkoutId}
/
offers
Definir ofertas do checkout
curl --request PUT \
--url https://api.ephra.io/v1/checkouts/{checkoutId}/offers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"offerIds": [
4821,
4822
],
"defaultOfferId": 4821
}
'import requests
url = "https://api.ephra.io/v1/checkouts/{checkoutId}/offers"
payload = {
"offerIds": [4821, 4822],
"defaultOfferId": 4821
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({offerIds: [4821, 4822], defaultOfferId: 4821})
};
fetch('https://api.ephra.io/v1/checkouts/{checkoutId}/offers', 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.ephra.io/v1/checkouts/{checkoutId}/offers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'offerIds' => [
4821,
4822
],
'defaultOfferId' => 4821
]),
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.ephra.io/v1/checkouts/{checkoutId}/offers"
payload := strings.NewReader("{\n \"offerIds\": [\n 4821,\n 4822\n ],\n \"defaultOfferId\": 4821\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.ephra.io/v1/checkouts/{checkoutId}/offers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"offerIds\": [\n 4821,\n 4822\n ],\n \"defaultOfferId\": 4821\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ephra.io/v1/checkouts/{checkoutId}/offers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"offerIds\": [\n 4821,\n 4822\n ],\n \"defaultOfferId\": 4821\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "clx9f1m2p0004qz0a7h8j9k0l",
"defaultOfferId": 4821,
"offers": [
{
"id": 4821,
"slug": "trafego-pago-anual",
"title": "Plano anual",
"price": 149900,
"isDefault": true,
"active": true,
"promotional": false,
"frequency": "annual",
"expiresAt": null,
"sortOrder": 0
},
{
"id": 4822,
"slug": "trafego-pago-mensal",
"title": "Plano mensal",
"price": 14900,
"isDefault": false,
"active": true,
"promotional": false,
"frequency": "monthly",
"expiresAt": null,
"sortOrder": 1
}
]
}
}{
"success": false,
"message": "Não foi possível concluir: uma regra de negócio recusou os dados enviados."
}{
"success": false,
"message": "Token inválido ou expirado"
}{
"success": false,
"message": "Checkout não encontrado"
}{
"success": false,
"message": "name: Nome é obrigatório"
}{
"success": false,
"message": "Muitas requisições. Tente novamente em breve."
}{
"success": false,
"message": "Erro interno do servidor"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Identificador do checkout.
Minimum string length:
1Body
application/json
Conjunto completo de ofertas do checkout, na ordem de exibição. A lista substitui a anterior.
Maximum array length:
50Required range:
x > 0Oferta que abre pela URL do checkout. Omitir mantém a atual, se ela continuar disponível.
Required range:
x > 0⌘I
