Skip to content

Instantly share code, notes, and snippets.

Avatar

costlockerbot

View GitHub Profile
@costlockerbot
costlockerbot / bulk-add.php
Created Jul 29, 2019
Bulk add people to running and recurring projects
View bulk-add.php
<?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',
],
View signature.php
<?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 / .env
Last active Aug 31, 2017
PHP OAuth2 Client DEMO
View .env
CL_HOST=""
CL_CLIENT_ID=""
CL_CLIENT_SECRET=""
View create-webhooks.bash
# 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"
View import-toggl-weekly-report.php
<?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',