camper-api
v1.0.11
Published
camperdays api
Downloads
2
Readme
CamperDays Api ♥
Initialize API
import CamperApi from 'camper-api';
const options = {
accessToken: String,
logErrors: Boolean
}
const Api = new CamperApi(options);
Add Logger
set options.logErrors
to true
and add a logger
import CamperApi from 'camper-api';
import winston from 'winston';
const options = {
accessToken: String,
logErrors: true
}
const Api = new CamperApi(options, winston);
Destination
get list of searchable destinations
Api.destination(callback);
Search
start a new search
const searchData = {
pickup: {
city: 40,
date: 'YYYY-MM-DD'
},
dropoff: {
city: 40,
date: 'YYYY-MM-DD'
}
};
const callback = function (error, result) {
// error if connection failed
// on api error
error: {
field: 'pickup.date',
code: 'invalid_pickup_date',
message: 'the pickup date is invalid'
};
result: null;
// on api success
error: null;
result: {
requestId: ''
}
};
Api.search(searchData, callback);
Results
Get status and results
const requestId = '1037a7bac7d5d9f73ed16d0c64d18c66';
const callback = function (error, result) {
// error if connection failed
// on api error
error = {
field: null,
code: 'invalid_request_identifier',
message: 'result_lifetime_exceeded'
};
result = null;
// on api success
error = null;
result = {
requestId: '',
offers: [Offer],
status: {
hasResults: true,
searching: false
}
}
};
Api.result(requestId, callback);
Offer
get offer with live data
const requestId = '1037a7bac7d5d9f73ed16d0c64d18c66';
const offerId = '1037a7bac7d5d9f73ed16d0c64d18c66';
const callback = function (error, result) {
// error if connection failed
// on api error
error = {
field: null,
code: '',
message: ''
};
result = null;
// on api success
error: null;
result: Offer
};
Api.offer(requestId, offerId, callback);
Booking
Validate Offer, CustomerData and request reservation
const bookingData = {
status: 'saved',
type: {
kind: 'booking'
},
offer: {
requestId: 'xcdacsdaavdaa',
offerId: 'afkjanfiosu'
},
customer: {
firstName: 'Alice',
lastName: 'Liddell',
street: 'Hasty Rabbit Av.',
streetNumber: '23',
zipCode: 'OX123',
city: 'Oxford',
emailAddress: '[email protected]',
phoneNumber: '012345678',
gender: 'f',
age: '23',
countryCode: 'UK',
language: 'de-de'
},
passengers: [{
firstName: 'Alice',
lastName: 'Liddell',
age: 23,
gender: 'f'
}],
items: [{
id: 123,
amount: 2
}]
}
Api.booking(bookingData, callback);
Love ♥ Love ♥ Love ♥ Love
const appearance = {
beautiful: true,
hairColor: ['black', 'brown'],
hairLength: 'long',
style: 'cute',
relationship: 'single',
glasses: true
}
Api.girls.find(appearance, callback)