Create
The type of campaign is determined by the partial parameter, it could be a full campaign that applies to all items in your store, or it could be a partial campaign that applies to specific items.
In the case of a partial campaign it is necessary to add the articles to which the financing campaign applies.
Learn how to manage the articles of a financing campaign.
- http
- shell
- python
- php
- C#
POST /me/campaigns HTTP/1.1
Accept: application/vnd.aplazame.v1+json
Authorization: Bearer api_private_key
Host: api.aplazame.com
Content-Type: application/json
{
"name": "Summertime",
"start_date": "2016-06-01T00:00:00",
"end_date": "2016-08-31T23:59:59",
"interest": "2500",
"partial": true,
"num_instalments": [1, 2, 3, 5, 8]
}
$ curl "https://api.aplazame.com/me/campaigns" \
-H "Accept: application/vnd.aplazame.v1+json" \
-H "Authorization: Bearer api_private_key"\
--data-binary '{
"name": "Summertime",
"start_date": "2016-06-01T00:00:00",
"end_date": "2016-08-31T23:59:59",
"interest": "2500",
"partial": true,
"num_instalments": [1, 2, 3, 5, 8]
}'
import aplazame_sdk
client = aplazame_sdk.Client('api_private_key')
response = client.post_campaign(':merchantId', {
'name': 'Summertime',
'start_date': '2016-06-01T00:00:00',
'end_date': '2016-08-31T23:59:59',
'interest': '2500',
'partial': True,
'num_instalments': [1, 2, 3, 5, 8]
})
use Aplazame\Api\Client as AplazameClient;
$aplazameClient = new AplazameClient("https://api.aplazame.com", AplazameClient::ENVIRONMENT_PRODUCTION, "api_private_key");
$campaign = [
"name" => "Summertime",
"start_date" => Aplazame\Serializer\Decimal::fromDateTime(new DateTime("2016-06-01 00:00:00")),
"end_date" => Aplazame\Serializer\Decimal::fromDateTime(new DateTime("2016-08-31 23:59:59")),
"interest" => Aplazame\Serializer\Decimal::fromFloat(25),
"partial" => true,
"num_instalments" => [1, 2, 3, 5, 8],
];
$result = $aplazameClient->post("/me/campaigns", $campaign);
using Aplazame.Api;
Client client = new Client("https://api.aplazame.com", Client.EnvironmentProduction, "api_private_key");
dynamic campaign = new {
name = "Summertime",
start_date = Aplazame.Serializer.DateType.FromDateTime(DateTime.Parse("2016-06-01 00:00:00")),
end_date = Aplazame.Serializer.DateType.FromDateTime(DateTime.Parse("2016-08-31 23:59:59")),
interest = Aplazame.Serializer.DecimalType.FromDouble(25),
partial = true,
num_instalments = [1, 2, 3, 5, 8],
};
dynamic result = client.Post($"/me/campaigns", campaign);
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Campaign name. |
| start_date | ISO 8601 | Yes | Start date of the campaign. |
| end_date | ISO 8601 | No | End date of the campaign. |
| interest | decimal | Yes | Interest discount rate. |
| partial | Boolean | No | Determines if the campaign applies to all products, false by default. |
| num_instalments | array | No | Minimum shopping cart amount (order.total_amount) to which the campaign applies. |
| min_order_amount | decimal | No | Minimum shopping cart amount (order.total_amount) to which the campaign applies. |
| max_order_amount | decimal | No | Maximum shopping cart amount (order.total_amount) to which the campaign applies. |
Response
HTTP/1.1 201 CREATED
Content-Type: application/json
X-Aplazame-Media-Type: aplazame.v1
{
"id": "c994e03e42d24be7bf6e1fcbad3334c0",
"name": "Summertime",
"start_date": "2016-06-01T00:00:00",
"end_date": "2016-08-31T23:59:59",
"interest": 2500,
"partial": true,
"num_instalments": [1, 2, 3, 5, 8],
"created": "2016-03-10T11:08:57.265971"
}