Skip to content

Instantly share code, notes, and snippets.

View costlockerbot's full-sized avatar

costlockerbot

View GitHub Profile
# init environment variables
CL_AUTH="webhooks_test:YOUR_PERSONAL_TOKEN"
CL_API="https://new.costlocker.com/api-public/v2"
# create webhook
curl -X POST -u $CL_AUTH "$CL_API/webhooks" -d @webhooks-request.json
# test webhook
CL_WEBHOOK="UUID_OF_EXISTING_WEBHOOK"
curl -X GET -u $CL_AUTH "$CL_API/webhooks/$CL_WEBHOOK/test"
<?php
$config = [
'costlocker' => [
'url' => 'https://new.costlocker.com/api-public/v2/timeentries/',
'token' => 'COSTLOCKER_TOKEN',
],
'toggl' => [
'url' => 'https://toggl.com/reports/api/v2/weekly',
'token' => 'TOGGL_TOKEN',
@costlockerbot
costlockerbot / .env
Last active August 31, 2017 04:06
PHP OAuth2 Client DEMO
CL_HOST=""
CL_CLIENT_ID=""
CL_CLIENT_SECRET=""
@costlockerbot
costlockerbot / signature.php
Created June 26, 2017 08:04
Webhook signature
<?php
$secret = 'bceefe12-78e6-49b8-d339-88b8b635b4fe';
$body = '{"meta":{"events":{"projects.create":1,"peoplecosts.change":1}},"links":{"webhook":{"webhook":"http:\/\/costlocker.php5:8080\/api-public\/v2\/webhooks\/162edc70-8f33-41ec-8d78-69ed1a21aca1","example":"http:\/\/costlocker.php5:8080\/api-public\/v2\/webhooks\/162edc70-8f33-41ec-8d78-69ed1a21aca1\/test"}},"data":[{"event":"projects.create","data":[{"id":1,"name":"Website","state":"running","client":{"id":1,"name":"ACME"},"dates":{"date_start":"2017-06-26","date_end":"2017-07-26"},"project_id":{"id":null,"is_generated":false},"tags":[{"name":"Billable"}],"responsible_people":[{"email":"john@example.com","first_name":"John","last_name":"Doe"}],"links":{"project":"http:\/\/costlocker.php5:8080\/api-public\/v2\/projects\/1","peoplecosts":"http:\/\/costlocker.php5:8080\/api-public\/v2\/projects\/1?types=peoplecosts","billing":"http:\/\/costlocker.php5:8080\/api-public\/v2\/projects\/1?types=billing","expenses":"http:\/\/costlocker.php5:8080\/api-public
@costlockerbot
costlockerbot / bulk-add.php
Created July 29, 2019 07:41
Bulk add people to running and recurring projects
<?php
// Usage:
// time CL_TOKEN="token from https://new.costlocker.com/api-token" php bulk-add.php
// 0) configuration
$config = [
'costlocker' => [
'url' => 'https://new.costlocker.com/api-public',
'token' => getenv('CL_TOKEN') ?: 'token from https://new.costlocker.com/api-token',
],