-
Notifications
You must be signed in to change notification settings - Fork 0
Create a Swik
JuniorFt edited this page Feb 8, 2017
·
1 revision
#Create a Swik
Before reading this make sure you understood the Initialization process. It will be required for Step 3.
<?php
$swik = new Swik();
Optional parameters:
-
ClientFirstName, ClientLastName, ClientPhoneNumber, SendEmail.
-
SendEmail: you need to use a string. By default the value is "true". Possible values: "true", "false". All other values are converted to "false" automatically. If set to true Swikly sends an email to the client to warn him about the new Swik. If set to false nothing is sent and you need to warn the client yourself.
All the others parameters are REQUIRED.
<?php
$swik->setClientFirstName("Jean")
->setClientLastName("Dupont")
->setClientPhoneNumber("+33 6 20 20 20 20")
->setClientEmail("jean.dupont@gmail.com")
->setClientLanguage("FR") // "EN" or "FR"
->setSwikAmount("50")
->setSwikDescription("1h de canyoning le 12/08/2017....")
->setSwikEndDay("12")
->setSwikEndMonth("08")
->setSwikEndYear("2017")
->setSwikId("YOUR_ID")
->setSendEmail("true")
->setSwikType("security deposit") // "reservation" or "security deposit" used only when setSendEmail("true")
->setCallbackUrl('https://mywebsite.com/resultSwik');
The newSwik function makes a call on the Swikly API. If all the information provided is correct the swik is created.
<?php
$result = $swkAPI->newSwik($swik);
- If no error happened, a status ok is returned with the acceptUrl you have to send to your client if you set setSendMail to "false".
- If there is an error in the information you provided or with the Swikly API you can log it or take any action needed by your application.
<?php
if ($result['status'] == 'ok') {
echo "New swik created";
echo "Your client can accept the swik at that address: " . $result['acceptUrl'];
} else {
echo "Failed create swik";
echo "Error = " . $result['message'];
}
<?php
// 1. Load the composer file.
require 'vendor/autoload.php';
use Swikly\SwiklyAPI;
use Swikly\Swik;
$swkAPI = new SwiklyAPI('Your_Api_Key', 'YOUR_API_SECRET', 'developement');
// Create a swik object
$swik = new Swik();
// Set all the swik informations
$swik->setClientFirstName("Jean")
->setClientLastName("Dupont")
->setClientEmail("jean.dupont@gmail.com")
->setClientPhoneNumber("+33 6 20 20 20 20")
->setClientLanguage("FR") // "EN" or "FR"
->setSwikAmount("50")
->setSwikDescription("1h de canyoning le 12/08/2017....")
->setSwikEndDay("12")
->setSwikEndMonth("08")
->setSwikEndYear("2017")
->setSwikId("YOUR_ID")
->setSendEmail("true")
->setSwikType("security deposit") // "reservation" or "security deposit" used only when setSendEmail("true")
->setCallbackUrl('https://mywebsite.com/resultSwik');
// Send your new swik to your client
$result = $swkAPI->newSwik($swik);
// Print result of the operation
if ($result['status'] == 'ok') {
echo "New swik created";
echo "Your client can accept the swik at that address: " . $result['acceptUrl'];
} else {
echo "Failed create swik";
echo "Error = " . $result['message'];
}