chore: initial commit
This commit is contained in:
43
api/config/api.php
Normal file
43
api/config/api.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* API Key Header Name
|
||||
*/
|
||||
$config['api_key_header_name'] = 'Authtoken';
|
||||
|
||||
|
||||
/**
|
||||
* API Key GET Request Parameter Name
|
||||
*/
|
||||
$config['api_key_get_name'] = 'key';
|
||||
|
||||
|
||||
/**
|
||||
* API Key POST Request Parameter Name
|
||||
*/
|
||||
$config['api_key_post_name'] = 'key';
|
||||
|
||||
|
||||
/**
|
||||
* Set API Timezone
|
||||
*/
|
||||
$config['api_timezone'] = 'Europe/London';
|
||||
|
||||
|
||||
/**
|
||||
* API Limit database table name
|
||||
*/
|
||||
$config['api_limit_table_name'] = 'api_usage_logs';
|
||||
|
||||
/**
|
||||
* API keys database table name
|
||||
*/
|
||||
$config['api_keys_table_name'] = 'user_api';
|
||||
|
||||
/**
|
||||
* Default API Rate Limit
|
||||
* [limit_number, limit_type, time_period]
|
||||
* Example: [100, 'ip', 60] = 100 requests per IP per 60 minutes
|
||||
* Set to false to disable default rate limiting
|
||||
*/
|
||||
$config['api_default_limit'] = [100, 'ip', 60];
|
||||
928
api/config/api_samples.php
Normal file
928
api/config/api_samples.php
Normal file
@@ -0,0 +1,928 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Comprehensive API Samples for Sandbox
|
||||
* This file contains all available API endpoints with sample requests
|
||||
*/
|
||||
|
||||
return [
|
||||
// Leads
|
||||
'get_leads' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'leads',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all leads'
|
||||
],
|
||||
'get_lead_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'leads/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific lead by ID'
|
||||
],
|
||||
'create_lead' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'leads',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "John Doe",
|
||||
"email": "john@example.com",
|
||||
"phone": "+1234567890",
|
||||
"company": "Example Corp",
|
||||
"source": "Website",
|
||||
"status": "New"
|
||||
}',
|
||||
'description' => 'Create a new lead with sample data'
|
||||
],
|
||||
'update_lead' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'leads/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "John Smith",
|
||||
"email": "johnsmith@example.com",
|
||||
"status": "Qualified"
|
||||
}',
|
||||
'description' => 'Update lead information'
|
||||
],
|
||||
'search_leads' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'leads/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search leads by keyword'
|
||||
],
|
||||
'delete_lead' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'leads/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a lead'
|
||||
],
|
||||
|
||||
// Projects
|
||||
'get_projects' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'projects',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get all projects'
|
||||
],
|
||||
'get_project_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'projects/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific project by ID'
|
||||
],
|
||||
'create_project' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'projects',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "API Test Project",
|
||||
"description": "A test project created via API",
|
||||
"client_id": 1,
|
||||
"start_date": "2024-01-01",
|
||||
"deadline": "2024-12-31",
|
||||
"status": "In Progress"
|
||||
}',
|
||||
'description' => 'Create a new project'
|
||||
],
|
||||
'update_project' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'projects/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "Updated Project Name",
|
||||
"status": "Completed",
|
||||
"description": "Updated project description"
|
||||
}',
|
||||
'description' => 'Update project information'
|
||||
],
|
||||
'delete_project' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'projects/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a project'
|
||||
],
|
||||
|
||||
// Tasks
|
||||
'get_tasks' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'tasks',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get all tasks'
|
||||
],
|
||||
'get_task_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'tasks/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific task by ID'
|
||||
],
|
||||
'create_task' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'tasks',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "API Test Task",
|
||||
"description": "A test task created via API",
|
||||
"project_id": 1,
|
||||
"priority": "Medium",
|
||||
"status": "To Do",
|
||||
"start_date": "2024-01-01",
|
||||
"due_date": "2024-01-31"
|
||||
}',
|
||||
'description' => 'Create a new task'
|
||||
],
|
||||
'update_task' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'tasks/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "Updated Task Name",
|
||||
"status": "In Progress",
|
||||
"priority": "High"
|
||||
}',
|
||||
'description' => 'Update task information'
|
||||
],
|
||||
'delete_task' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'tasks/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a task'
|
||||
],
|
||||
|
||||
// Tickets
|
||||
'get_tickets' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'tickets',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all support tickets'
|
||||
],
|
||||
'get_ticket_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'tickets/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific ticket by ID'
|
||||
],
|
||||
'create_ticket' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'tickets',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"subject": "API Test Ticket",
|
||||
"message": "This is a test ticket created via API",
|
||||
"department": "Support",
|
||||
"priority": "Medium",
|
||||
"status": "Open"
|
||||
}',
|
||||
'description' => 'Create a new support ticket'
|
||||
],
|
||||
'update_ticket' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'tickets/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "In Progress",
|
||||
"priority": "High",
|
||||
"message": "Updated ticket message"
|
||||
}',
|
||||
'description' => 'Update ticket information'
|
||||
],
|
||||
'delete_ticket' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'tickets/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a ticket'
|
||||
],
|
||||
|
||||
// Invoices
|
||||
'get_invoices' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'invoices',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all invoices'
|
||||
],
|
||||
'get_invoice_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'invoices/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific invoice by ID'
|
||||
],
|
||||
'create_invoice' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'invoices',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"client_id": 1,
|
||||
"date": "2024-01-15",
|
||||
"due_date": "2024-02-15",
|
||||
"currency": "USD",
|
||||
"subtotal": 1000.00,
|
||||
"total": 1000.00,
|
||||
"status": "Draft"
|
||||
}',
|
||||
'description' => 'Create a new invoice'
|
||||
],
|
||||
'update_invoice' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'invoices/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "Sent",
|
||||
"total": 1200.00,
|
||||
"notes": "Updated invoice notes"
|
||||
}',
|
||||
'description' => 'Update invoice information'
|
||||
],
|
||||
'search_invoices' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'invoices/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search invoices by keyword'
|
||||
],
|
||||
'delete_invoice' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'invoices/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete an invoice'
|
||||
],
|
||||
|
||||
// Estimates
|
||||
'get_estimates' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'estimates',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all estimates'
|
||||
],
|
||||
'get_estimate_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'estimates/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific estimate by ID'
|
||||
],
|
||||
'create_estimate' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'estimates',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"client_id": 1,
|
||||
"date": "2024-01-15",
|
||||
"expirydate": "2024-02-15",
|
||||
"currency": "USD",
|
||||
"subtotal": 800.00,
|
||||
"total": 800.00,
|
||||
"status": "Draft"
|
||||
}',
|
||||
'description' => 'Create a new estimate'
|
||||
],
|
||||
'update_estimate' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'estimates/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "Sent",
|
||||
"total": 900.00,
|
||||
"notes": "Updated estimate notes"
|
||||
}',
|
||||
'description' => 'Update estimate information'
|
||||
],
|
||||
'search_estimates' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'estimates/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search estimates by keyword'
|
||||
],
|
||||
'delete_estimate' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'estimates/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete an estimate'
|
||||
],
|
||||
|
||||
// Contracts
|
||||
'get_contracts' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'contracts',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all contracts'
|
||||
],
|
||||
'get_contract_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'contracts/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific contract by ID'
|
||||
],
|
||||
'create_contract' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'contracts',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"subject": "API Test Contract",
|
||||
"client": 1,
|
||||
"contract_type": "Service Agreement",
|
||||
"start_date": "2024-01-01",
|
||||
"end_date": "2024-12-31",
|
||||
"contract_value": 50000.00,
|
||||
"status": "Draft"
|
||||
}',
|
||||
'description' => 'Create a new contract'
|
||||
],
|
||||
'update_contract' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'contracts/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "Active",
|
||||
"contract_value": 55000.00,
|
||||
"notes": "Updated contract terms"
|
||||
}',
|
||||
'description' => 'Update contract information'
|
||||
],
|
||||
'delete_contract' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'contracts/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a contract'
|
||||
],
|
||||
|
||||
// Credit Notes
|
||||
'get_credit_notes' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'credit_notes',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all credit notes'
|
||||
],
|
||||
'get_credit_note_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'credit_notes/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific credit note by ID'
|
||||
],
|
||||
'create_credit_note' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'credit_notes',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"client_id": 1,
|
||||
"date": "2024-01-15",
|
||||
"currency": "USD",
|
||||
"subtotal": 100.00,
|
||||
"total": 100.00,
|
||||
"status": "Draft"
|
||||
}',
|
||||
'description' => 'Create a new credit note'
|
||||
],
|
||||
'update_credit_note' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'credit_notes/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "Sent",
|
||||
"total": 120.00,
|
||||
"notes": "Updated credit note"
|
||||
}',
|
||||
'description' => 'Update credit note information'
|
||||
],
|
||||
'search_credit_notes' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'credit_notes/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search credit notes by keyword'
|
||||
],
|
||||
'delete_credit_note' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'credit_notes/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a credit note'
|
||||
],
|
||||
|
||||
// Expenses
|
||||
'get_expenses' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'expenses',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all expenses'
|
||||
],
|
||||
'get_expense_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'expenses/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific expense by ID'
|
||||
],
|
||||
'create_expense' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'expenses',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"category": "Travel",
|
||||
"amount": 150.00,
|
||||
"date": "2024-01-15",
|
||||
"description": "Business trip expenses",
|
||||
"client_id": 1,
|
||||
"currency": "USD"
|
||||
}',
|
||||
'description' => 'Create a new expense'
|
||||
],
|
||||
'update_expense' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'expenses/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"amount": 175.00,
|
||||
"description": "Updated expense description"
|
||||
}',
|
||||
'description' => 'Update expense information'
|
||||
],
|
||||
'search_expenses' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'expenses/search/travel',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search expenses by keyword'
|
||||
],
|
||||
'delete_expense' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'expenses/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete an expense'
|
||||
],
|
||||
|
||||
// Items
|
||||
'get_items' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'items',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all items'
|
||||
],
|
||||
'get_item_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'items/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific item by ID'
|
||||
],
|
||||
'search_items' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'items/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search items by keyword'
|
||||
],
|
||||
|
||||
// Contacts
|
||||
'get_contacts' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'contacts',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all contacts'
|
||||
],
|
||||
'get_contact_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'contacts/1/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific contact by ID'
|
||||
],
|
||||
'create_contact' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'contacts',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"firstname": "John",
|
||||
"lastname": "Doe",
|
||||
"email": "john.doe@example.com",
|
||||
"phonenumber": "+1234567890",
|
||||
"title": "Manager",
|
||||
"customer_id": 1
|
||||
}',
|
||||
'description' => 'Create a new contact'
|
||||
],
|
||||
'update_contact' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'contacts/1/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"firstname": "John",
|
||||
"lastname": "Smith",
|
||||
"email": "john.smith@example.com",
|
||||
"title": "Senior Manager"
|
||||
}',
|
||||
'description' => 'Update contact information'
|
||||
],
|
||||
'search_contacts' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'contacts/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search contacts by keyword'
|
||||
],
|
||||
'delete_contact' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'contacts/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a contact'
|
||||
],
|
||||
|
||||
// Staff
|
||||
'get_staff' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'staff',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all staff members'
|
||||
],
|
||||
'get_staff_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'staff/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific staff member by ID'
|
||||
],
|
||||
|
||||
// Payments
|
||||
'get_payments' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'payments',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all payments'
|
||||
],
|
||||
'get_payment_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'payments/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific payment by ID'
|
||||
],
|
||||
'create_payment' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'payments',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"invoice_id": 1,
|
||||
"amount": 1000.00,
|
||||
"paymentmode": "Bank Transfer",
|
||||
"date": "2024-01-15",
|
||||
"note": "Payment via API"
|
||||
}',
|
||||
'description' => 'Create a new payment'
|
||||
],
|
||||
'update_payment' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'payments/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"amount": 1200.00,
|
||||
"note": "Updated payment note"
|
||||
}',
|
||||
'description' => 'Update payment information'
|
||||
],
|
||||
'delete_payment' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'payments/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a payment'
|
||||
],
|
||||
|
||||
// Proposals
|
||||
'get_proposals' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'proposals',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all proposals'
|
||||
],
|
||||
'get_proposal_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'proposals/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific proposal by ID'
|
||||
],
|
||||
'create_proposal' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'proposals',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"subject": "API Test Proposal",
|
||||
"client_id": 1,
|
||||
"date": "2024-01-15",
|
||||
"open_till": "2024-02-15",
|
||||
"currency": "USD",
|
||||
"subtotal": 2000.00,
|
||||
"total": 2000.00,
|
||||
"status": "Draft"
|
||||
}',
|
||||
'description' => 'Create a new proposal'
|
||||
],
|
||||
'update_proposal' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'proposals/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "Sent",
|
||||
"total": 2200.00,
|
||||
"notes": "Updated proposal"
|
||||
}',
|
||||
'description' => 'Update proposal information'
|
||||
],
|
||||
'delete_proposal' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'proposals/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a proposal'
|
||||
],
|
||||
|
||||
// Subscriptions
|
||||
'get_subscriptions' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'subscriptions',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all subscriptions'
|
||||
],
|
||||
'get_subscription_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'subscriptions/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific subscription by ID'
|
||||
],
|
||||
'create_subscription' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'subscriptions',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "API Test Subscription",
|
||||
"client_id": 1,
|
||||
"description": "Test subscription created via API",
|
||||
"date": "2024-01-15",
|
||||
"next_billing_cycle": "2024-02-15",
|
||||
"status": "Active"
|
||||
}',
|
||||
'description' => 'Create a new subscription'
|
||||
],
|
||||
'update_subscription' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'subscriptions/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "Inactive",
|
||||
"description": "Updated subscription"
|
||||
}',
|
||||
'description' => 'Update subscription information'
|
||||
],
|
||||
'delete_subscription' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'subscriptions/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a subscription'
|
||||
],
|
||||
|
||||
// Milestones
|
||||
'get_milestones' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'milestones',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all milestones'
|
||||
],
|
||||
'get_milestone_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'milestones/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific milestone by ID'
|
||||
],
|
||||
'create_milestone' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'milestones',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"name": "API Test Milestone",
|
||||
"description": "Test milestone created via API",
|
||||
"project_id": 1,
|
||||
"due_date": "2024-02-15",
|
||||
"status": "Not Started"
|
||||
}',
|
||||
'description' => 'Create a new milestone'
|
||||
],
|
||||
'update_milestone' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'milestones/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"status": "In Progress",
|
||||
"description": "Updated milestone"
|
||||
}',
|
||||
'description' => 'Update milestone information'
|
||||
],
|
||||
'search_milestones' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'milestones/search/example',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Search milestones by keyword'
|
||||
],
|
||||
'delete_milestone' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'milestones/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a milestone'
|
||||
],
|
||||
|
||||
// Timesheets
|
||||
'get_timesheets' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'timesheets',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all timesheets'
|
||||
],
|
||||
'get_timesheet_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'timesheets/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific timesheet by ID'
|
||||
],
|
||||
'create_timesheet' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'timesheets',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"project_id": 1,
|
||||
"task_id": 1,
|
||||
"staff_id": 1,
|
||||
"date": "2024-01-15",
|
||||
"hours": 8.0,
|
||||
"note": "API test timesheet entry"
|
||||
}',
|
||||
'description' => 'Create a new timesheet entry'
|
||||
],
|
||||
'update_timesheet' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'timesheets/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"hours": 7.5,
|
||||
"note": "Updated timesheet entry"
|
||||
}',
|
||||
'description' => 'Update timesheet information'
|
||||
],
|
||||
'delete_timesheet' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'timesheets/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a timesheet entry'
|
||||
],
|
||||
|
||||
// Calendar
|
||||
'get_calendar' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'calendar',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Retrieve all calendar events'
|
||||
],
|
||||
'get_calendar_event_by_id' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'calendar/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get specific calendar event by ID'
|
||||
],
|
||||
'create_calendar_event' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'calendar',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"title": "API Test Event",
|
||||
"description": "Test event created via API",
|
||||
"start": "2024-01-15 09:00:00",
|
||||
"end": "2024-01-15 17:00:00",
|
||||
"color": "#3498db"
|
||||
}',
|
||||
'description' => 'Create a new calendar event'
|
||||
],
|
||||
'update_calendar_event' => [
|
||||
'method' => 'PUT',
|
||||
'endpoint' => 'calendar/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '{
|
||||
"title": "Updated Event Title",
|
||||
"description": "Updated event description"
|
||||
}',
|
||||
'description' => 'Update calendar event information'
|
||||
],
|
||||
'delete_calendar_event' => [
|
||||
'method' => 'DELETE',
|
||||
'endpoint' => 'calendar/1',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Delete a calendar event'
|
||||
],
|
||||
|
||||
// Common Data
|
||||
'get_expense_categories' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'common/expense_category',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get expense categories'
|
||||
],
|
||||
'get_payment_modes' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'common/payment_mode',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get payment modes'
|
||||
],
|
||||
'get_tax_data' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'common/tax_data',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get tax data'
|
||||
],
|
||||
|
||||
// Custom Fields
|
||||
'get_custom_fields' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'custom_fields/company',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get custom fields for company'
|
||||
],
|
||||
'get_custom_fields_leads' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'custom_fields/leads',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get custom fields for leads'
|
||||
],
|
||||
'get_custom_fields_customers' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'custom_fields/customers',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get custom fields for customers'
|
||||
],
|
||||
|
||||
// Authentication
|
||||
'login' => [
|
||||
'method' => 'POST',
|
||||
'endpoint' => 'login/auth',
|
||||
'headers' => 'Content-Type: application/json',
|
||||
'data' => '{
|
||||
"email": "admin@example.com",
|
||||
"password": "your_password"
|
||||
}',
|
||||
'description' => 'Authenticate user and get API key'
|
||||
],
|
||||
'get_api_key' => [
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'login/key',
|
||||
'headers' => 'authtoken: YOUR_API_KEY',
|
||||
'data' => '',
|
||||
'description' => 'Get API key information'
|
||||
]
|
||||
];
|
||||
7
api/config/autoload.php
Normal file
7
api/config/autoload.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
$autoload['libraries'] = [
|
||||
'Format', 'app_tabs', 'app_object_cache', 'form_validation', 'mails/App_mail_template', 'merge_fields/app_merge_fields'
|
||||
];
|
||||
37
api/config/jwt.php
Normal file
37
api/config/jwt.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------
|
||||
| JWT Secure Key
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
$config['jwt_key'] = 'eyJ0eXAiOiJKV1QiLCJhbGciTWeLUzI1NiJ9IiRkYXRhIz';
|
||||
|
||||
|
||||
/*
|
||||
|-----------------------
|
||||
| JWT Algorithm Type
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
$config['jwt_algorithm'] = 'HS256';
|
||||
|
||||
|
||||
/*
|
||||
|-----------------------
|
||||
| Token Request Header Name
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
$config['token_header'] = 'authtoken';
|
||||
|
||||
|
||||
/*
|
||||
|-----------------------
|
||||
| Token Expire Time
|
||||
|
||||
| https://www.tools4noobs.com/online_tools/hh_mm_ss_to_seconds/
|
||||
|--------------------------------------------------------------------------
|
||||
| ( 1 Day ) : 60 * 60 * 24 = 86400
|
||||
| ( 1 Hour ) : 60 * 60 = 3600
|
||||
| ( 1 Minute ) : 60 = 60
|
||||
*/
|
||||
$config['token_expire_time'] = 315569260;
|
||||
15
api/config/ldap.php
Normal file
15
api/config/ldap.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
$config['binduser'] = 'cn=Authentication,ou=Services,dc=example,dc=org';
|
||||
$config['basedn'] = 'dc=example,dc=org';
|
||||
$config['bindpw'] = 'E984asdy2';
|
||||
/*
|
||||
* The host name parameter can be a space separated list of host names.
|
||||
* This means that the LDAP code will talk to a backup server if the main server is not operational.
|
||||
* There will be a delay while the code times out trying to talk to the main server but things will still work.
|
||||
*/
|
||||
$config['server'] = 'ldapserver1.example.org ldapserver2.example.org';
|
||||
$config['port'] = NULL;
|
||||
/*
|
||||
* Controls the LDAP_OPT_NETWORK_TIMEOUT option, this is how long the code will attempt to talk to the primary server if it is unreachable.
|
||||
*/
|
||||
$config['timeout'] = 5;
|
||||
628
api/config/rest.php
Normal file
628
api/config/rest.php
Normal file
@@ -0,0 +1,628 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP protocol
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set to force the use of HTTPS for REST API calls
|
||||
|
|
||||
*/
|
||||
$config['force_https'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Output Format
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default format of the response
|
||||
|
|
||||
| 'array': Array data structure
|
||||
| 'csv': Comma separated file
|
||||
| 'json': Uses json_encode(). Note: If a GET query string
|
||||
| called 'callback' is passed, then jsonp will be returned
|
||||
| 'html' HTML using the table library in CodeIgniter
|
||||
| 'php': Uses var_export()
|
||||
| 'serialized': Uses serialize()
|
||||
| 'xml': Uses simplexml_load_string()
|
||||
|
|
||||
*/
|
||||
$config['rest_default_format'] = 'json';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Supported Output Formats
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following setting contains a list of the supported/allowed formats.
|
||||
| You may remove those formats that you don't want to use.
|
||||
| If the default format $config['rest_default_format'] is missing within
|
||||
| $config['rest_supported_formats'], it will be added silently during
|
||||
| REST_Controller initialization.
|
||||
|
|
||||
*/
|
||||
$config['rest_supported_formats'] = [
|
||||
'json',
|
||||
'array',
|
||||
'csv',
|
||||
'html',
|
||||
'jsonp',
|
||||
'php',
|
||||
'serialized',
|
||||
'xml',
|
||||
];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Status Field Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The field name for the status inside the response
|
||||
|
|
||||
*/
|
||||
$config['rest_status_field_name'] = 'status';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Message Field Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The field name for the message inside the response
|
||||
|
|
||||
*/
|
||||
$config['rest_message_field_name'] = 'error';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable Emulate Request
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Should we enable emulation of the request (e.g. used in Mootools request)
|
||||
|
|
||||
*/
|
||||
$config['enable_emulate_request'] = TRUE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Realm
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Name of the password protected REST API displayed on login dialogs
|
||||
|
|
||||
| e.g: My Secret REST API
|
||||
|
|
||||
*/
|
||||
$config['rest_realm'] = 'REST API';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Login
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set to specify the REST API requires to be logged in
|
||||
|
|
||||
| FALSE No login required
|
||||
| 'basic' Unsecured login
|
||||
| 'digest' More secured login
|
||||
| 'session' Check for a PHP session variable. See 'auth_source' to set the
|
||||
| authorization key
|
||||
|
|
||||
*/
|
||||
$config['rest_auth'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Login Source
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Is login required and if so, the user store to use
|
||||
|
|
||||
| '' Use config based users or wildcard testing
|
||||
| 'ldap' Use LDAP authentication
|
||||
| 'library' Use a authentication library
|
||||
|
|
||||
| Note: If 'rest_auth' is set to 'session' then change 'auth_source' to the name of the session variable
|
||||
|
|
||||
*/
|
||||
$config['auth_source'] = 'ldap';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allow Authentication and API Keys
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Where you wish to have Basic, Digest or Session login, but also want to use API Keys (for limiting
|
||||
| requests etc), set to TRUE;
|
||||
|
|
||||
*/
|
||||
$config['allow_auth_and_keys'] = TRUE;
|
||||
$config['strict_api_and_auth'] = TRUE; // force the use of both api and auth before a valid api request is made
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Login Class and Function
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If library authentication is used define the class and function name
|
||||
|
|
||||
| The function should accept two parameters: class->function($username, $password)
|
||||
| In other cases override the function _perform_library_auth in your controller
|
||||
|
|
||||
| For digest authentication the library function should return already a stored
|
||||
| md5(username:restrealm:password) for that username
|
||||
|
|
||||
| e.g: md5('admin:REST API:1234') = '1e957ebc35631ab22d5bd6526bd14ea2'
|
||||
|
|
||||
*/
|
||||
$config['auth_library_class'] = '';
|
||||
$config['auth_library_function'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Override auth types for specific class/method
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set specific authentication types for methods within a class (controller)
|
||||
|
|
||||
| Set as many config entries as needed. Any methods not set will use the default 'rest_auth' config value.
|
||||
|
|
||||
| e.g:
|
||||
|
|
||||
| $config['auth_override_class_method']['deals']['view'] = 'none';
|
||||
| $config['auth_override_class_method']['deals']['insert'] = 'digest';
|
||||
| $config['auth_override_class_method']['accounts']['user'] = 'basic';
|
||||
| $config['auth_override_class_method']['dashboard']['*'] = 'none|digest|basic';
|
||||
|
|
||||
| Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. An asterisk may also be used to specify an authentication method for an entire classes methods. Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end of the method name)
|
||||
| Acceptable values are; 'none', 'digest' and 'basic'.
|
||||
|
|
||||
*/
|
||||
// $config['auth_override_class_method']['deals']['view'] = 'none';
|
||||
// $config['auth_override_class_method']['deals']['insert'] = 'digest';
|
||||
// $config['auth_override_class_method']['accounts']['user'] = 'basic';
|
||||
// $config['auth_override_class_method']['dashboard']['*'] = 'basic';
|
||||
|
||||
|
||||
// ---Uncomment list line for the wildard unit test
|
||||
// $config['auth_override_class_method']['wildcard_test_cases']['*'] = 'basic';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Override auth types for specific 'class/method/HTTP method'
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| example:
|
||||
|
|
||||
| $config['auth_override_class_method_http']['deals']['view']['get'] = 'none';
|
||||
| $config['auth_override_class_method_http']['deals']['insert']['post'] = 'none';
|
||||
| $config['auth_override_class_method_http']['deals']['*']['options'] = 'none';
|
||||
*/
|
||||
|
||||
// ---Uncomment list line for the wildard unit test
|
||||
// $config['auth_override_class_method_http']['wildcard_test_cases']['*']['options'] = 'basic';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Login Usernames
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Array of usernames and passwords for login, if ldap is configured this is ignored
|
||||
|
|
||||
*/
|
||||
$config['rest_valid_logins'] = ['admin' => 'notastrongpasswordhere'];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global IP White-listing
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Limit connections to your REST server to White-listed IP addresses
|
||||
|
|
||||
| Usage:
|
||||
| 1. Set to TRUE and select an auth option for extreme security (client's IP
|
||||
| address must be in white-list and they must also log in)
|
||||
| 2. Set to TRUE with auth set to FALSE to allow White-listed IPs access with no login
|
||||
| 3. Set to FALSE but set 'auth_override_class_method' to 'white-list' to
|
||||
| restrict certain methods to IPs in your white-list
|
||||
|
|
||||
*/
|
||||
$config['rest_ip_whitelist_enabled'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Handle Exceptions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Handle exceptions caused by the controller
|
||||
|
|
||||
*/
|
||||
$config['rest_handle_exceptions'] = TRUE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST IP White-list
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Limit connections to your REST server with a comma separated
|
||||
| list of IP addresses
|
||||
|
|
||||
| e.g: '123.456.789.0, 987.654.32.1'
|
||||
|
|
||||
| 127.0.0.1 and 0.0.0.0 are allowed by default
|
||||
|
|
||||
*/
|
||||
$config['rest_ip_whitelist'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global IP Blacklisting
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Prevent connections to the REST server from blacklisted IP addresses
|
||||
|
|
||||
| Usage:
|
||||
| 1. Set to TRUE and add any IP address to 'rest_ip_blacklist'
|
||||
|
|
||||
*/
|
||||
$config['rest_ip_blacklist_enabled'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST IP Blacklist
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Prevent connections from the following IP addresses
|
||||
|
|
||||
| e.g: '123.456.789.0, 987.654.32.1'
|
||||
|
|
||||
*/
|
||||
$config['rest_ip_blacklist'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Database Group
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Connect to a database group for keys, logging, etc. It will only connect
|
||||
| if you have any of these features enabled
|
||||
|
|
||||
*/
|
||||
$config['rest_database_group'] = 'default';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Keys Table Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The table name in your database that stores API keys
|
||||
|
|
||||
*/
|
||||
$config['rest_keys_table'] = 'user_api';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Enable Keys
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When set to TRUE, the REST API will look for a column name called 'key'.
|
||||
| If no key is provided, the request will result in an error. To override the
|
||||
| column name see 'rest_key_column'
|
||||
|
|
||||
| Default table schema:
|
||||
| CREATE TABLE `keys` (
|
||||
| `id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
| `user_id` INT(11) NOT NULL,
|
||||
| `key` VARCHAR(40) NOT NULL,
|
||||
| `level` INT(2) NOT NULL,
|
||||
| `ignore_limits` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
| `is_private_key` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
| `ip_addresses` TEXT NULL DEFAULT NULL,
|
||||
| `date_created` INT(11) NOT NULL,
|
||||
| PRIMARY KEY (`id`)
|
||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
||||
*/
|
||||
$config['rest_enable_keys'] = TRUE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Table Key Column Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If not using the default table schema in 'rest_enable_keys', specify the
|
||||
| column name to match e.g. my_key
|
||||
|
|
||||
*/
|
||||
$config['rest_key_column'] = 'token';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Limits method
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the method used to limit the API calls
|
||||
|
|
||||
| Available methods are :
|
||||
| $config['rest_limits_method'] = 'IP_ADDRESS'; // Put a limit per ip address
|
||||
| $config['rest_limits_method'] = 'API_KEY'; // Put a limit per api key
|
||||
| $config['rest_limits_method'] = 'METHOD_NAME'; // Put a limit on method calls
|
||||
| $config['rest_limits_method'] = 'ROUTED_URL'; // Put a limit on the routed URL
|
||||
|
|
||||
*/
|
||||
$config['rest_limits_method'] = 'IP_ADDRESS';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Key Length
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Length of the created keys. Check your default database schema on the
|
||||
| maximum length allowed
|
||||
|
|
||||
| Note: The maximum length is 40
|
||||
|
|
||||
*/
|
||||
$config['rest_key_length'] = 40;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Key Variable
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Custom header to specify the API key
|
||||
|
||||
| Note: Custom headers with the X- prefix are deprecated as of
|
||||
| 2012/06/12. See RFC 6648 specification for more details
|
||||
|
|
||||
*/
|
||||
$config['rest_key_name'] = 'Authtoken';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Enable Logging
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When set to TRUE, the REST API will log actions based on the column names 'key', 'date',
|
||||
| 'time' and 'ip_address'. This is a general rule that can be overridden in the
|
||||
| $this->method array for each controller
|
||||
|
|
||||
| Default table schema:
|
||||
| CREATE TABLE `logs` (
|
||||
| `id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
| `uri` VARCHAR(255) NOT NULL,
|
||||
| `method` VARCHAR(6) NOT NULL,
|
||||
| `params` TEXT DEFAULT NULL,
|
||||
| `api_key` VARCHAR(40) NOT NULL,
|
||||
| `ip_address` VARCHAR(45) NOT NULL,
|
||||
| `time` INT(11) NOT NULL,
|
||||
| `rtime` FLOAT DEFAULT NULL,
|
||||
| `authorized` VARCHAR(1) NOT NULL,
|
||||
| `response_code` smallint(3) DEFAULT '0',
|
||||
| PRIMARY KEY (`id`)
|
||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
||||
*/
|
||||
$config['rest_enable_logging'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Logs Table Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If not using the default table schema in 'rest_enable_logging', specify the
|
||||
| table name to match e.g. my_logs
|
||||
|
|
||||
*/
|
||||
$config['rest_logs_table'] = 'pi_usage_logs';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Method Access Control
|
||||
|--------------------------------------------------------------------------
|
||||
| When set to TRUE, the REST API will check the access table to see if
|
||||
| the API key can access that controller. 'rest_enable_keys' must be enabled
|
||||
| to use this
|
||||
|
|
||||
| Default table schema:
|
||||
| CREATE TABLE `access` (
|
||||
| `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
| `key` VARCHAR(40) NOT NULL DEFAULT '',
|
||||
| `all_access` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
| `controller` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
| `date_created` DATETIME DEFAULT NULL,
|
||||
| `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
| PRIMARY KEY (`id`)
|
||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
||||
*/
|
||||
$config['rest_enable_access'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Access Table Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If not using the default table schema in 'rest_enable_access', specify the
|
||||
| table name to match e.g. my_access
|
||||
|
|
||||
*/
|
||||
$config['rest_access_table'] = 'access';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Param Log Format
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When set to TRUE, the REST API log parameters will be stored in the database as JSON
|
||||
| Set to FALSE to log as serialized PHP
|
||||
|
|
||||
*/
|
||||
$config['rest_logs_json_params'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Enable Limits
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When set to TRUE, the REST API will count the number of uses of each method
|
||||
| by an API key each hour. This is a general rule that can be overridden in the
|
||||
| $this->method array in each controller
|
||||
|
|
||||
| Default table schema:
|
||||
| CREATE TABLE `limits` (
|
||||
| `id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
| `uri` VARCHAR(255) NOT NULL,
|
||||
| `count` INT(10) NOT NULL,
|
||||
| `hour_started` INT(11) NOT NULL,
|
||||
| `api_key` VARCHAR(40) NOT NULL,
|
||||
| PRIMARY KEY (`id`)
|
||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
||||
| To specify the limits within the controller's __construct() method, add per-method
|
||||
| limits with:
|
||||
|
|
||||
| $this->method['METHOD_NAME']['limit'] = [NUM_REQUESTS_PER_HOUR];
|
||||
|
|
||||
| See application/controllers/api/example.php for examples
|
||||
*/
|
||||
$config['rest_enable_limits'] = TRUE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Limits Table Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If not using the default table schema in 'rest_enable_limits', specify the
|
||||
| table name to match e.g. my_limits
|
||||
|
|
||||
*/
|
||||
$config['rest_limits_table'] = 'api_usage_logs';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Default Limit
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default limit for API endpoints that don't have a specific limit defined
|
||||
| Value is the number of requests allowed per time period (default: 1 hour)
|
||||
| Set to FALSE to disable default limits
|
||||
|
|
||||
*/
|
||||
$config['rest_default_limit'] = 100;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST API Default Limit Time Period
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Time period in seconds for the default limit (default: 3600 = 1 hour)
|
||||
|
|
||||
*/
|
||||
$config['rest_default_limit_time'] = 3600;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Ignore HTTP Accept
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set to TRUE to ignore the HTTP Accept and speed up each request a little.
|
||||
| Only do this if you are using the $this->rest_format or /format/xml in URLs
|
||||
|
|
||||
*/
|
||||
$config['rest_ignore_http_accept'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST AJAX Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set to TRUE to allow AJAX requests only. Set to FALSE to accept HTTP requests
|
||||
|
|
||||
| Note: If set to TRUE and the request is not AJAX, a 505 response with the
|
||||
| error message 'Only AJAX requests are accepted.' will be returned.
|
||||
|
|
||||
| Hint: This is good for production environments
|
||||
|
|
||||
*/
|
||||
$config['rest_ajax_only'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| REST Language File
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Language file to load from the language directory
|
||||
|
|
||||
*/
|
||||
$config['rest_language'] = 'english';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CORS Check
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set to TRUE to enable Cross-Origin Resource Sharing (CORS). Useful if you
|
||||
| are hosting your API on a different domain from the application that
|
||||
| will access it through a browser
|
||||
|
|
||||
*/
|
||||
$config['check_cors'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CORS Allowable Headers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If using CORS checks, set the allowable headers here
|
||||
|
|
||||
*/
|
||||
$config['allowed_cors_headers'] = [
|
||||
'Origin',
|
||||
'X-Requested-With',
|
||||
'Content-Type',
|
||||
'Accept',
|
||||
'Access-Control-Request-Method'
|
||||
];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CORS Allowable Methods
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If using CORS checks, you can set the methods you want to be allowed
|
||||
|
|
||||
*/
|
||||
$config['allowed_cors_methods'] = [
|
||||
'GET',
|
||||
'POST',
|
||||
'OPTIONS',
|
||||
'PUT',
|
||||
'PATCH',
|
||||
'DELETE'
|
||||
];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CORS Allow Any Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set to TRUE to enable Cross-Origin Resource Sharing (CORS) from any
|
||||
| source domain
|
||||
|
|
||||
*/
|
||||
$config['allow_any_cors_domain'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CORS Allowable Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Used if $config['check_cors'] is set to TRUE and $config['allow_any_cors_domain']
|
||||
| is set to FALSE. Set all the allowable domains within the array
|
||||
|
|
||||
| e.g. $config['allowed_origins'] = ['http://www.example.com', 'https://spa.example.com']
|
||||
|
|
||||
*/
|
||||
$config['allowed_cors_origins'] = [];
|
||||
36
api/config/routes.php
Normal file
36
api/config/routes.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
// Specific API routes (must come before generic routes)
|
||||
$route['api/playground'] = 'playground/index';
|
||||
$route['api/playground/swagger'] = 'playground/swagger';
|
||||
$route['api/sandbox'] = 'playground/sandbox';
|
||||
$route['api/sandbox/execute_request'] = 'playground/execute_request';
|
||||
$route['api/sandbox/get_samples'] = 'playground/get_samples';
|
||||
$route['api/sandbox/get_endpoints'] = 'playground/get_endpoints';
|
||||
$route['api/sandbox/get_environment_config'] = 'playground/get_environment_config';
|
||||
$route['api/sandbox/documentation'] = 'playground/documentation';
|
||||
|
||||
$route['api/users/stats/(:num)'] = 'api/user_stats/$1';
|
||||
$route['api/users/stats'] = 'api/user_stats';
|
||||
|
||||
$route['api/reporting'] = 'reporting/index';
|
||||
$route['api/reporting/get_chart_data'] = 'reporting/get_chart_data';
|
||||
$route['api/reporting/export'] = 'reporting/export';
|
||||
|
||||
// Generic API routes (must come after specific routes)
|
||||
$route['api/delete/(:any)/(:num)'] = '$1/data/$2';
|
||||
$route['api/(:any)/search/(:any)'] = '$1/data_search/$2';
|
||||
$route['api/(:any)/search'] = '$1/data_search';
|
||||
$route['api/login/auth'] = 'login/login_api';
|
||||
$route['api/login/view'] = 'login/view';
|
||||
$route['api/login/key'] = 'login/api_key';
|
||||
$route['api/(:any)/(:any)/(:num)'] = '$1/data/$2/$3';
|
||||
$route['api/(:any)/(:num)/(:num)'] = '$1/data/$2/$3';
|
||||
$route['api/custom_fields/(:any)/(:num)'] = 'custom_fields/data/$1/$2';
|
||||
$route['api/custom_fields/(:any)'] = 'custom_fields/data/$1';
|
||||
$route['api/common/(:any)/(:num)'] = 'common/data/$1/$2';
|
||||
$route['api/common/(:any)'] = 'common/data/$1';
|
||||
$route['api/(:any)/(:num)'] = '$1/data/$2';
|
||||
$route['api/(:any)'] = '$1/data';
|
||||
2337
api/config/swagger.json
Normal file
2337
api/config/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user