### Java Code Generation Example for Tripletex API (Swagger) Source: https://github.com/tripletex/tripletex-api2/blob/master/README.md This section covers Java examples generated using Swagger, focusing on common use-cases like order and token management within the Tripletex API. It requires a Gradle build setup for managing dependencies. ```java // Example for Order use-case (conceptual - actual code depends on Swagger generation) /* import com.tripletex.api.v2.model.Order; import com.tripletex.api.v2.client.OrderApiClient; public class OrderExample { public static void main(String[] args) { // Assuming ApiClient is initialized with credentials and base URL OrderApiClient orderClient = new OrderApiClient(apiClient); try { // Example: Get a specific order by ID Order order = orderClient.getById(123); System.out.println("Order Name: " + order.getName()); // Example: Create a new order (requires Order object with details) // Order newOrder = new Order(); // newOrder.setName("New Test Order"); // ... set other properties ... // Order createdOrder = orderClient.create(newOrder); // System.out.println("Created Order ID: " + createdOrder.getId()); } catch (ApiException e) { System.err.println("Error interacting with Tripletex API: " + e.getMessage()); e.printStackTrace(); } } } */ ``` ```java // Example for Token use-case (conceptual - actual code depends on Swagger generation) /* import com.tripletex.api.v2.client.TokenApiClient; import com.tripletex.api.v2.model.TokenInfo; public class TokenExample { public static void main(String[] args) { // Assuming ApiClient is initialized with credentials and base URL TokenApiClient tokenClient = new TokenApiClient(apiClient); try { // Example: Get information about the current token TokenInfo tokenInfo = tokenClient.getCurrentTokenInfo(); System.out.println("Token User: " + tokenInfo.getUser().getFullName()); System.out.println("Token Expiry: " + tokenInfo.getExpiry()); // Example: Refresh token (if applicable and supported by API spec) // TokenInfo refreshedToken = tokenClient.refreshToken(); // System.out.println("New Token Expiry: " + refreshedToken.getExpiry()); } catch (ApiException e) { System.err.println("Error interacting with Tripletex API: " + e.getMessage()); e.printStackTrace(); } } } */ ``` -------------------------------- ### JSON Payload Examples for Tripletex API Source: https://github.com/tripletex/tripletex-api2/blob/master/README.md A collection of JSON payload examples for various Tripletex API entities, including travel expenses, employees, customers, suppliers, and companies. These examples illustrate the expected structure for request bodies. ```json // Example: Travel Expense Payload /* { "invoiceDate": "2023-10-27", "expenseDate": "2023-10-25", "amount": 150.50, "currency": { "id": 1 }, "employee": { "id": 101 }, "description": "Business lunch meeting", "expenseType": { "id": 5 } } */ ``` ```json // Example: Employee Payload /* { "firstName": "Jane", "lastName": "Doe", "email": "jane.doe@example.com", "department": { "id": 2 }, "position": "Software Engineer" } */ ``` ```json // Example: Customer Payload /* { "name": "Example Corp", "street": "123 Main St", "city": "Anytown", "zipCode": "12345", "country": { "id": 3 } } */ ``` ```json // Example: Supplier Payload /* { "name": "Tech Supplies Inc.", "organizationNumber": "987654321", "contactPerson": { "firstName": "John", "lastName": "Smith" }, "email": "info@techsupplies.com" } */ ``` ```json // Example: Company Payload (for updates or specific company details) /* { "name": "Tripletex AS", "organizationNumber": "112233445", "address": { "street": "Tripletexveien 1", "city": "Oslo", "zipCode": "0123", "country": { "id": 1 } } } */ ``` -------------------------------- ### Bash Authentication Example for Tripletex API Source: https://github.com/tripletex/tripletex-api2/blob/master/README.md A simple Bash script demonstrating authentication use-cases with the Tripletex API. This example is useful for understanding how to establish a connection and authenticate requests to the API. ```bash #!/bin/bash # Tripletex API v2 Example: Simple Authentication # Replace with your actual consumer token and secret token CONSUMER_TOKEN="YOUR_CONSUMER_TOKEN" SECRET_TOKEN="YOUR_SECRET_TOKEN" # Base URL for Tripletex API v2 BASE_URL="https://api.tripletex.io/v2" # Generate a checksum for the request. # The checksum is calculated by hashing the concatenated # consumer token, secret token, and current timestamp. TIMESTAMP=$(date +%s%3) CHECKSUM=$(echo -n "${CONSUMER_TOKEN}${SECRET_TOKEN}${TIMESTAMP}" | openssl dgst -sha512 | cut -d' ' -f2) # Construct the authentication header AUTH_HEADER="Tripletex-Token: ${CONSUMER_TOKEN}:${CHECKSUM}:${TIMESTAMP}" # Example: Get company information (requires 'company' endpoint) # Note: This is a conceptual example. You might need to adjust the # endpoint and parameters based on the actual API structure. # # curl -X GET \ # "${BASE_URL}/company" \ # -H "${AUTH_HEADER}" echo "Authentication header generated successfully:" echo "${AUTH_HEADER}" echo "Timestamp: ${TIMESTAMP}" ``` -------------------------------- ### Example Event Data Structure Source: https://github.com/tripletex/tripletex-api2/blob/master/docs/webhooks/README.md Shows an example of the data structure returned when listing available events, demonstrating the event name, description, and payload model. ```json { "value": { "product.create": { "description": "Product created", "payloadModel": "Product" }, "order.delete": { "description": "Order deleted" } } } ``` -------------------------------- ### Bash Checksum Example for Tripletex API Source: https://github.com/tripletex/tripletex-api2/blob/master/README.md This Bash script provides an example of how to generate a checksum, a crucial part of the authentication process for the Tripletex API. It demonstrates the use of openssl for hashing. ```bash #!/bin/bash # Tripletex API v2 Example: Checksum Generation # Replace with your actual consumer token and secret token CONSUMER_TOKEN="YOUR_CONSUMER_TOKEN" SECRET_TOKEN="YOUR_SECRET_TOKEN" # Get the current timestamp in milliseconds TIMESTAMP=$(date +%s%3) # Generate the checksum by hashing the concatenated tokens and timestamp # The output is then processed to extract only the hash value. CHECKSUM=$(echo -n "${CONSUMER_TOKEN}${SECRET_TOKEN}${TIMESTAMP}" | openssl dgst -sha512 | cut -d' ' -f2) echo "Consumer Token: ${CONSUMER_TOKEN}" echo "Secret Token: ${SECRET_TOKEN}" echo "Timestamp: ${TIMESTAMP}" echo "Generated Checksum (SHA512): ${CHECKSUM}" # The authentication header format is: # Tripletex-Token: CONSUMER_TOKEN:CHECKSUM:TIMESTAMP # Example: # Tripletex-Token: YOUR_CONSUMER_TOKEN:generated_checksum:timestamp ``` -------------------------------- ### Python Examples for Tripletex API Source: https://github.com/tripletex/tripletex-api2/blob/master/README.md This section provides links and references to Python code examples for interacting with the Tripletex API. Specific functionalities like authentication or data retrieval are often demonstrated. ```python # Conceptual Python example for Tripletex API interaction # This often involves using libraries like 'requests' and handling authentication. # import requests # import hashlib # import time # CONSUMER_TOKEN = "YOUR_CONSUMER_TOKEN" # SECRET_TOKEN = "YOUR_SECRET_TOKEN" # BASE_URL = "https://api.tripletex.io/v2" # def generate_auth_header(): # timestamp = int(time.time() * 1000) # checksum_data = f"{CONSUMER_TOKEN}{SECRET_TOKEN}{timestamp}" # checksum = hashlib.sha512(checksum_data.encode()).hexdigest() # return f"Tripletex-Token: {CONSUMER_TOKEN}:{checksum}:{timestamp}" # def get_company_info(): # headers = { # 'Authorization': generate_auth_header() # } # try: # response = requests.get(f"{BASE_URL}/company", headers=headers) # response.raise_for_status() # Raise an exception for bad status codes # return response.json() # except requests.exceptions.RequestException as e: # print(f"Error fetching company info: {e}") # return None # if __name__ == "__main__": # company_data = get_company_info() # if company_data: # print("Company Information:") # print(company_data) ``` -------------------------------- ### Create Employee with Address (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/employee.md Example JSON payload for creating a new employee resource, including their address details. This is used with a POST request to the /employee endpoint. ```json { "firstName": "John", "lastName": "Doe", "address": { "addressLine1": "Address line1", "addressLine2": "Address line2", "postalCode": "Postal code", "city": "Oslo" } } ``` -------------------------------- ### POST /timesheet/entry Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/timesheet.md Create a timesheet entry. Can be created with or without project details. Examples provided for basic entry, entry without project, and chargeable hours. ```APIDOC ## POST /timesheet/entry ### Description Creates a new timesheet entry. This endpoint supports creating entries with or without associated project information. It also allows specifying chargeable hours. ### Method POST ### Endpoint /timesheet/entry ### Parameters #### Request Body - **project** (object) - Optional - Details of the project associated with the timesheet entry. Requires an `id`. - **activity** (object) - Required - Details of the activity performed. Requires an `id`. - **employee** (object) - Required - Details of the employee who logged the hours. Requires an `id`. - **date** (string) - Required - The date of the timesheet entry (YYYY-MM-DD). - **hours** (number) - Required - The total hours logged for the entry. - **chargeableHours** (number) - Optional - The number of hours that are chargeable. - **chargeable** (boolean) - Optional - Indicates if the hours are chargeable. ### Request Example **Entry with project:** ```json { "project": { "id": 123 }, "activity": { "id": 123}, "employee": {"id": 123}, "date": "1970-01-01", "hours": 7.5 } ``` **Entry without project:** ```json { "activity": { "id": 123}, "employee": {"id": 123}, "date": "1970-01-01", "hours": 7.5 } ``` **Chargeable Hours:** ```json { "project": { "id": 123 }, "activity": { "id": 123}, "employee": {"id": 123}, "date": "1970-01-01", "hours": 8, "chargeableHours": 7.5, "chargeable": true } ``` ### Response #### Success Response (200) (Success response structure not provided in the input.) ``` -------------------------------- ### Using the 'fields' Parameter for GET Requests Source: https://github.com/tripletex/tripletex-api2/blob/master/FAQ.md Demonstrates how to use the 'fields' parameter to optimize GET requests by specifying which data to include, such as expanding to related objects like order lines. ```APIDOC ## GET /v2/order ### Description Fetches orders with options to filter by date and specify returned fields. ### Method GET ### Endpoint `/v2/order` ### Parameters #### Query Parameters - **orderDateFrom** (string) - Optional - Filter orders from this date (YYYY-MM-DD). - **orderDateTo** (string) - Optional - Filter orders to this date (YYYY-MM-DD). - **fields** (string) - Optional - Specifies the fields to return. Use `*` for all fields, and `objectName(*)` to expand related objects. ### Request Example ``` GET /v2/order?orderDateFrom=2017-01-01&orderDateTo=2017-02-01&fields=*,orderLines(*) ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the order. - **orderLines** (array) - A list of order lines associated with the order. - **description** (string) - Description of the order line. - **count** (number) - The quantity of the item. - **price** (number) - The price of the order line. - **[other fields]** ``` -------------------------------- ### POST/PUT /timesheet/salaryTypeSpecification Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/timesheet.md Create or update a salary type specification for an employee. Examples cover minimum required fields and an entry with a description. ```APIDOC ## POST/PUT /timesheet/salaryTypeSpecification ### Description Creates or updates a salary type specification for an employee. This endpoint allows for basic specification with required fields or includes an optional description. ### Method POST/PUT ### Endpoint /timesheet/salaryTypeSpecification ### Parameters #### Request Body - **employee** (object) - Required - Details of the employee. Requires an `id`. - **salaryType** (object) - Required - Details of the salary type. Requires an `id`. - **date** (string) - Required - The effective date of the specification (YYYY-MM-DD). - **count** (number) - Required - The count or value associated with the salary type specification. - **description** (string) - Optional - A text description for the salary type specification. ### Request Example **Minimum:** ```json { "employee": { "id": 123 }, "salaryType": { "id": 123 }, "date": "1970-01-01", "count": 2 } ``` **With description:** ```json { "employee": { "id": 123 }, "salaryType": { "id": 123 }, "description": "some text", "date": "1970-01-01", "count": 2 } ``` ### Response #### Success Response (200) (Success response structure not provided in the input.) ``` -------------------------------- ### POST /customer Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/customer.md Create a new customer with their postal, physical, and delivery addresses. ```APIDOC ## POST /customer ### Description Create a new customer along with its postal, physical, and delivery addresses. ### Method POST ### Endpoint /customer ### Parameters #### Request Body - **name** (string) - Required - The name of the customer. - **postalAddress** (object) - Optional - The postal address details. - **addressLine1** (string) - Required - The first line of the postal address. - **addressLine2** (string) - Optional - The second line of the postal address. - **postalCode** (string) - Required - The postal code of the address. - **city** (string) - Required - The city of the address. - **physicalAddress** (object) - Optional - The physical address details. - **addressLine1** (string) - Required - The first line of the physical address. - **addressLine2** (string) - Optional - The second line of the physical address. - **postalCode** (string) - Required - The postal code of the address. - **city** (string) - Required - The city of the address. - **deliveryAddress** (object) - Optional - The delivery address details. - **addressLine1** (string) - Required - The first line of the delivery address. - **addressLine2** (string) - Optional - The second line of the delivery address. - **postalCode** (string) - Required - The postal code of the address. - **city** (string) - Required - The city of the address. ### Request Example ```json { "name": "New customer name", "postalAddress": { "addressLine1": "New postal address line 1", "addressLine2": "New postal address line 2", "postalCode": "0000", "city": "Oslo" }, "physicalAddress": { "addressLine1": "New physical address line 1", "addressLine2": "New physical address line 2", "postalCode": "0000", "city": "Oslo" }, "deliveryAddress": { "addressLine1": "New delivery address line 1", "addressLine2": "New delivery address line 2", "postalCode": "0000", "city": "Oslo" } } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the newly created customer. - **name** (string) - The name of the customer. - **postalAddress** (object) - The postal address details of the customer. - **physicalAddress** (object) - The physical address details of the customer. - **deliveryAddress** (object) - The delivery address details of the customer. #### Response Example ```json { "id": 123, "name": "New customer name", "postalAddress": { "id": 456, "addressLine1": "New postal address line 1", "addressLine2": "New postal address line 2", "postalCode": "0000", "city": "Oslo" }, "physicalAddress": { "id": 789, "addressLine1": "New physical address line 1", "addressLine2": "New physical address line 2", "postalCode": "0000", "city": "Oslo" }, "deliveryAddress": { "id": 101, "addressLine1": "New delivery address line 1", "addressLine2": "New delivery address line 2", "postalCode": "0000", "city": "Oslo" } } ``` ``` -------------------------------- ### POST /supplier Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/supplier.md Create a new supplier with postal, physical, and delivery addresses. ```APIDOC ## POST /supplier ### Description Creates a new supplier and associated addresses (postal, physical, delivery). ### Method POST ### Endpoint /supplier ### Parameters #### Request Body - **name** (string) - Required - The name of the supplier. - **postalAddress** (object) - Optional - The postal address details. - **addressLine1** (string) - Required - The first line of the postal address. - **addressLine2** (string) - Optional - The second line of the postal address. - **postalCode** (string) - Required - The postal code. - **city** (string) - Required - The city. - **physicalAddress** (object) - Optional - The physical address details. - **addressLine1** (string) - Required - The first line of the physical address. - **addressLine2** (string) - Optional - The second line of the physical address. - **postalCode** (string) - Required - The postal code. - **city** (string) - Required - The city. - **deliveryAddress** (object) - Optional - The delivery address details. - **addressLine1** (string) - Required - The first line of the delivery address. - **addressLine2** (string) - Optional - The second line of the delivery address. - **postalCode** (string) - Required - The postal code. - **city** (string) - Required - The city. ### Request Example ```json { "name": "New supplier name", "postalAddress": { "addressLine1": "New postal address line 1", "addressLine2": "New postal address line 2", "postalCode": "0000", "city": "Oslo" }, "physicalAddress": { "addressLine1": "New physical address line 1", "addressLine2": "New physical address line 2", "postalCode": "0000", "city": "Oslo" }, "deliveryAddress": { "addressLine1": "New delivery address line 1", "addressLine2": "New delivery address line 2", "postalCode": "0000", "city": "Oslo" } } ``` ### Response #### Success Response (200) - **id** (integer) - The ID of the newly created supplier. - **name** (string) - The name of the supplier. - **postalAddress** (object) - The postal address details. - **physicalAddress** (object) - The physical address details. - **deliveryAddress** (object) - The delivery address details. ``` -------------------------------- ### POST /travelExpense - Expense without cost Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/travelExpense.md Example payload for creating a travel expense entry that does not include any cost information. ```APIDOC ## POST /travelExpense - Expense without cost ### Description This payload is used to create a travel expense entry for an employee without specifying any associated costs. ### Method POST ### Endpoint /travelExpense ### Parameters #### Request Body - **employee** (object) - Required - Information about the employee associated with the expense. - **id** (integer) - Required - The ID of the employee. - **isChargeable** (boolean) - Required - Indicates if the expense is chargeable. - **isFixedInvoicedAmount** (boolean) - Required - Indicates if the invoiced amount is fixed. - **isIncludeAttachedReceiptsWhenReinvoicing** (boolean) - Required - Indicates if attached receipts should be included when re-invoicing. ### Request Example ```json { "employee":{"id":EMPLOYEE_ID}, "isChargeable":false, "isFixedInvoicedAmount":false, "isIncludeAttachedReceiptsWhenReinvoicing":false } ``` ``` -------------------------------- ### Subscription Status Check (JSON Response) Source: https://github.com/tripletex/tripletex-api2/blob/master/docs/webhooks/README.md Provides an example of the JSON response when checking the status of subscriptions using the GET /v2/event/subscription endpoint. ```json { .........., "values": [ { "id": 1, "version": 0, // Simply shows how many times this record has been modified (using PUT) "url": "https://tripletex.no/v2/event/subscription/1", "event": "product.create", "targetUrl": "http://webhook.target.io/foo", "fields": "*,currency(*)", "status": "ACTIVE" } ] } ``` -------------------------------- ### POST /travelExpense - Travel expense with mileage allowances Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/travelExpense.md Example payload for creating a travel expense that includes mileage allowances, specifying passenger rate for 2018. ```APIDOC ## POST /travelExpense - Travel expense with mileage allowances ### Description This payload includes travel details and mileage allowances, demonstrating how to specify passenger rates for a given date and route. ### Method POST ### Endpoint /travelExpense ### Parameters #### Request Body - **employee** (object) - Required - Information about the employee. - **id** (integer) - Required - The ID of the employee. - **travelDetails** (object) - Required - Details about the travel. - **isForeignTravel** (boolean) - Required - Indicates if the travel was international. - **isDayTrip** (boolean) - Required - Indicates if it was a day trip. - **departureDate** (string) - Required - The departure date in 'YYYY-MM-DD' format. - **returnDate** (string) - Required - The return date in 'YYYY-MM-DD' format. - **departureFrom** (string) - Required - The departure location. - **destination** (string) - Required - The destination location. - **departureTime** (string) - Required - The departure time in 'HH:MM' format. - **returnTime** (string) - Required - The return time in 'HH:MM' format. - **purpose** (string) - Required - The purpose of the travel. - **isChargeable** (boolean) - Required - Indicates if the expense is chargeable. - **isFixedInvoicedAmount** (boolean) - Required - Indicates if the invoiced amount is fixed. - **isIncludeAttachedReceiptsWhenReinvoicing** (boolean) - Required - Indicates if attached receipts should be included when re-invoicing. - **mileageAllowances** (array) - Optional - A list of mileage allowances. - **rateType** (object) - Required - The type of rate applied. - **id** (integer) - Required - The ID of the rate type. - **date** (string) - Required - The date of the allowance in 'YYYY-MM-DD' format. - **departureLocation** (string) - Required - The departure location for the mileage. - **destination** (string) - Required - The destination location for the mileage. - **rate** (number) - Required - The rate per kilometer. - **km** (number) - Required - The number of kilometers traveled. - **passengers** (array) - Optional - Information about passengers. - **name** (string) - Required - The name of the passenger. ### Request Example ```json { "employee":{"id":EMPLOYEE_ID}, "travelDetails": { "isForeignTravel":false, "isDayTrip":false, "departureDate":"2018-10-03", "returnDate":"2018-10-03", "departureFrom":"Haslum", "destination":"Oslo", "departureTime":"08:00", "returnTime":"17:00", "purpose":"work" }, "isChargeable":false, "isFixedInvoicedAmount":false, "isIncludeAttachedReceiptsWhenReinvoicing":false, "mileageAllowances":[ { "rateType":{"id":13603}, "date":"2018-10-03", "departureLocation":"Haslum", "destination":"Oslo", "rate":1, "km":1, "passengers":[ { "name":"Per" } ] } ] } ``` ``` -------------------------------- ### Update Employee with Address (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/employee.md Example JSON payload for updating an existing employee resource and their associated address. This is used with a PUT request to the /employee/{id} endpoint. ```json { "id": EMPLOYEE_ID, "firstName": "John", "lastName": "Doe", "address": { "id": ADDRESS_ID, "addressLine1": "Updated address line1", "addressLine2": "Updated address line2", "postalCode": "Updated code", "city": "Oslo" } } ``` -------------------------------- ### Optimize GET Requests with Fields Parameter Source: https://github.com/tripletex/tripletex-api2/blob/master/FAQ.md Demonstrates how to use the 'fields' parameter in GET requests to selectively retrieve data and improve efficiency. It shows fetching orders with basic information and then expanding to include related order lines. ```HTTP GET /v2/order?orderDateFrom=2017-01-01&orderDateTo=2017-02-01 GET /v2/order?orderDateFrom=2017-01-01&orderDateTo=2017-02-01&fields=*,orderLines(*) ``` -------------------------------- ### Example Shell Script for Tripletex API Checksum Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/bash/checksum/README.md This script demonstrates a basic usage of the checksum feature with the Tripletex API. It shows how to set the `If-None-Match` header and handle responses, including HTTP 304 Not Modified. ```shell #!/bin/bash # Base URL for the Tripletex API API_URL="https://api.tripletex.io/v2" # Your API consumer token and session token CONSUMER_TOKEN="YOUR_CONSUMER_TOKEN" SESSION_TOKEN="YOUR_SESSION_TOKEN" # Endpoint to fetch projects ENDPOINT="/project" # --- First request: Get initial data and checksum --- echo "Making initial request to $ENDPOINT..." RESPONSE_INITIAL=$(curl -s -X GET \ -H "Authorization: Basic $(echo -n $CONSUMER_TOKEN:$SESSION_TOKEN | base64)" \ -H "If-None-Match: any-non-empty-string" \ "$API_URL$ENDPOINT") # Extract versionDigest (checksum) VERSION_DIGEST=$(echo $RESPONSE_INITIAL | grep -o '"versionDigest":"[^"]*"' | cut -d':' -f2 | tr -d '"') # Check if versionDigest was found if [ -z "$VERSION_DIGEST" ]; then echo "Failed to get versionDigest." echo "Response: $RESPONSE_INITIAL" exit 1 fi echo "Initial request successful. Version Digest: $VERSION_DIGEST" # --- Second request: Use the checksum to check for changes --- echo " Making subsequent request with If-None-Match header..." RESPONSE_SUBSEQUENT=$(curl -s -X GET \ -H "Authorization: Basic $(echo -n $CONSUMER_TOKEN:$SESSION_TOKEN | base64)" \ -H "If-None-Match: $VERSION_DIGEST" \ "$API_URL$ENDPOINT") # Check the HTTP status code of the response HTTP_STATUS=$(echo $RESPONSE_SUBSEQUENT | grep -o '"httpStatus":[0-9]*' | cut -d':' -f2) if [ "$HTTP_STATUS" == "304" ]; then echo "Data has not changed (HTTP 304 Not Modified)." elif [ "$HTTP_STATUS" == "200" ]; then echo "Data has changed or initial request was made." # You can process the new data here echo "Response: $RESPONSE_SUBSEQUENT" else echo "An unexpected HTTP status code was received: $HTTP_STATUS." echo "Response: $RESPONSE_SUBSEQUENT" exit 1 fi exit 0 ``` -------------------------------- ### Timesheet Entry with Project (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/timesheet.md Example JSON payload for creating a timesheet entry associated with a specific project, activity, employee, date, and hours. This is a common structure for tracking work hours. ```json { "project": { "id": 123 }, "activity": { "id": 123}, "employee": {"id": 123}, "date": "1970-01-01", "hours": 7.5 } ``` -------------------------------- ### POST /travelExpense - Travel expense with all compensation types Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/travelExpense.md Example payload for creating a travel expense that includes all possible compensation types: per diem, mileage, accommodation, and costs. ```APIDOC ## POST /travelExpense - Travel expense with all compensation types ### Description This comprehensive payload illustrates how to include various compensation types such as per diem, mileage allowances, accommodation allowances, and itemized costs within a single travel expense entry. ### Method POST ### Endpoint /travelExpense ### Parameters #### Request Body - **employee** (object) - Required - Information about the employee. - **id** (integer) - Required - The ID of the employee. - **travelDetails** (object) - Required - Details about the travel. - **isForeignTravel** (boolean) - Required - Indicates if the travel was international. - **isDayTrip** (boolean) - Required - Indicates if it was a day trip. - **departureDate** (string) - Required - The departure date in 'YYYY-MM-DD' format. - **returnDate** (string) - Required - The return date in 'YYYY-MM-DD' format. - **departureFrom** (string) - Required - The departure location. - **destination** (string) - Required - The destination location. - **departureTime** (string) - Required - The departure time in 'HH:MM' format. - **returnTime** (string) - Required - The return time in 'HH:MM' format. - **purpose** (string) - Required - The purpose of the travel. - **isChargeable** (boolean) - Required - Indicates if the expense is chargeable. - **isFixedInvoicedAmount** (boolean) - Required - Indicates if the invoiced amount is fixed. - **isIncludeAttachedReceiptsWhenReinvoicing** (boolean) - Required - Indicates if attached receipts should be included when re-invoicing. - **perDiemCompensations** (array) - Optional - List of per diem compensations. - **rateType** (object) - Required - The type of per diem rate. - **id** (integer) - Required - The ID of the rate type. - **count** (integer) - Required - The number of days or units. - **location** (string) - Required - The location for the per diem. - **mileageAllowances** (array) - Optional - List of mileage allowances. - **rateType** (object) - Required - The type of mileage rate. - **id** (integer) - Required - The ID of the rate type. - **date** (string) - Required - The date of the allowance in 'YYYY-MM-DD' format. - **departureLocation** (string) - Required - The departure location for the mileage. - **destination** (string) - Required - The destination location for the mileage. - **rate** (number) - Required - The rate per kilometer. - **km** (number) - Required - The number of kilometers traveled. - **accommodationAllowances** (array) - Optional - List of accommodation allowances. - **rateType** (object) - Required - The type of accommodation rate. - **id** (integer) - Required - The ID of the rate type. - **count** (integer) - Required - The number of nights or units. - **rate** (number) - Required - The rate per unit. - **location** (string) - Required - The location of the accommodation. - **costs** (array) - Optional - List of itemized costs. - **paymentType** (object) - Required - The type of payment used. - **id** (integer) - Required - The ID of the payment type. - **date** (string) - Required - The date of the cost in 'YYYY-MM-DD' format. - **costCategory** (object) - Required - The category of the cost. - **id** (integer) - Required - The ID of the cost category. - **amountCurrencyIncVat** (number) - Required - The amount of the cost, including VAT. ### Request Example ```json { "employee":{"id":EMPLOYEE_ID}, "travelDetails":{ "isForeignTravel":false, "isDayTrip":false, "departureDate":"2018-10-03", "returnDate":"2018-10-03", "departureFrom":"Haslum", "destination":"Oslo", "departureTime":"08:00", "returnTime":"17:00", "purpose":"work" }, "isChargeable":false, "isFixedInvoicedAmount":false, "isIncludeAttachedReceiptsWhenReinvoicing":false, "perDiemCompensations":[ { "rateType":{"id":13593}, "count":1, "location":"Haslum" } ], "mileageAllowances":[ { "rateType":{"id":13598}, "date":"2018-10-03", "departureLocation":"Haslum", "destination":"Oslo", "rate":1, "km":1 } ], "accommodationAllowances":[ { "rateType":{"id":13609}, "count":1, "rate":1, "location":"Haslum" } ], "costs":[ { "paymentType":{"id":PAYMENT_TYPE_ID}, "date":"2018-10-03", "costCategory":{"id":COST_CATEGORY_ID}, "amountCurrencyIncVat":1 } ] } ``` ``` -------------------------------- ### Salary Type Specification with Description (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/timesheet.md Example JSON payload for a salary type specification that includes an optional description field. This allows for adding context or notes to the salary specification, providing more detail. ```json { "employee": { "id": 123 }, "salaryType": { "id": 123 }, "description": "some text", "date": "1970-01-01", "count": 2 } ``` -------------------------------- ### Create Employee Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/employee.md Creates a new employee resource, including their address information. ```APIDOC ## POST /employee ### Description Creates a new employee resource along with its address. ### Method POST ### Endpoint /employee ### Parameters #### Request Body - **firstName** (string) - Required - The first name of the employee. - **lastName** (string) - Required - The last name of the employee. - **address** (object) - Required - The address details of the employee. - **addressLine1** (string) - Required - The first line of the address. - **addressLine2** (string) - Optional - The second line of the address. - **postalCode** (string) - Required - The postal code. - **city** (string) - Required - The city. ### Request Example ```json { "firstName": "John", "lastName": "Doe", "address": { "addressLine1": "Address line1", "addressLine2": "Address line2", "postalCode": "Postal code", "city": "Oslo" } } ``` ### Response #### Success Response (201 Created) - **id** (integer) - The unique identifier for the newly created employee. - **addressId** (integer) - The unique identifier for the newly created address. #### Response Example ```json { "id": 123, "addressId": 456, "firstName": "John", "lastName": "Doe", "address": { "id": 456, "addressLine1": "Address line1", "addressLine2": "Address line2", "postalCode": "Postal code", "city": "Oslo" } } ``` ``` -------------------------------- ### POST /travelExpense - Travel expense without compensations Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/travelExpense.md Example payload for creating a travel expense entry that includes travel details but no specific compensation types. ```APIDOC ## POST /travelExpense - Travel expense without compensations ### Description This payload demonstrates creating a travel expense with detailed travel information such as departure and destination, but without any compensation details. ### Method POST ### Endpoint /travelExpense ### Parameters #### Request Body - **employee** (object) - Required - Information about the employee. - **id** (integer) - Required - The ID of the employee. - **travelDetails** (object) - Required - Details about the travel. - **isForeignTravel** (boolean) - Required - Indicates if the travel was international. - **isDayTrip** (boolean) - Required - Indicates if it was a day trip. - **departureDate** (string) - Required - The departure date in 'YYYY-MM-DD' format. - **returnDate** (string) - Required - The return date in 'YYYY-MM-DD' format. - **departureFrom** (string) - Required - The departure location. - **destination** (string) - Required - The destination location. - **departureTime** (string) - Required - The departure time in 'HH:MM' format. - **returnTime** (string) - Required - The return time in 'HH:MM' format. - **purpose** (string) - Required - The purpose of the travel. - **isChargeable** (boolean) - Required - Indicates if the expense is chargeable. - **isFixedInvoicedAmount** (boolean) - Required - Indicates if the invoiced amount is fixed. - **isIncludeAttachedReceiptsWhenReinvoicing** (boolean) - Required - Indicates if attached receipts should be included when re-invoicing. ### Request Example ```json { "employee":{"id":EMPLOYEE_ID}, "travelDetails": { "isForeignTravel":false, "isDayTrip":false, "departureDate":"2018-10-03", "returnDate":"2018-10-03", "departureFrom":"Haslum", "destination":"Oslo", "departureTime":"08:00", "returnTime":"17:00", "purpose":"work" }, "isChargeable":false, "isFixedInvoicedAmount":false, "isIncludeAttachedReceiptsWhenReinvoicing":false } ``` ``` -------------------------------- ### Timesheet Entry without Project (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/timesheet.md Example JSON payload for creating a timesheet entry that is not linked to a specific project. It includes activity, employee, date, and hours. Useful for general administrative tasks or non-project specific work. ```json { "activity": { "id": 123}, "employee": {"id": 123}, "date": "1970-01-01", "hours": 7.5 } ``` -------------------------------- ### Create Customer with Addresses (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/customer.md This JSON payload demonstrates how to create a new customer, including their postal, physical, and delivery addresses. It requires the `name` field and nested address objects for each address type. ```JSON { "name": "New customer name", "postalAddress": { "addressLine1": "New postal address line 1", "addressLine2": "New postal address line 2", "postalCode": "0000", "city": "Oslo" }, "physicalAddress": { "addressLine1": "New physical address line 1", "addressLine2": "New physical address line 2", "postalCode": "0000", "city": "Oslo" }, "deliveryAddress": { "addressLine1": "New delivery address line 1", "addressLine2": "New delivery address line 2", "postalCode": "0000", "city": "Oslo" } } ``` -------------------------------- ### Create Supplier with Addresses (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/supplier.md This snippet demonstrates the JSON payload required to create a new supplier. It includes fields for the supplier's name and detailed postal, physical, and delivery addresses. Ensure all required fields are populated. ```json { "name": "New supplier name", ... "postalAddress": { "addressLine1": "New postal address line 1", "addressLine2": "New postal address line 2", "postalCode": "0000", "city": "Oslo" }, "physicalAddress": { "addressLine1": "New physical address line 1", "addressLine2": "New physical address line 2", "postalCode": "0000", "city": "Oslo" }, "deliveryAddress": { "addressLine1": "New delivery address line 1", "addressLine2": "New delivery address line 2", "postalCode": "0000", "city": "Oslo" } } ``` -------------------------------- ### Timesheet Entry with Chargeable Hours (JSON) Source: https://github.com/tripletex/tripletex-api2/blob/master/examples/json/timesheet.md Example JSON payload for a timesheet entry that specifies chargeable hours and a chargeable status. This allows for differentiating between total hours worked and hours billable to clients. ```json { "project": { "id": 123 }, "activity": { "id": 123}, "employee": {"id": 123}, "date": "1970-01-01", "hours": 8, "chargeableHours": 7.5, "chargeable": true } ```