Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
@tristansokol
tristansokol / gist:3fe98b6d5a8635b148f55ec123e480ed
Created July 25, 2016 17:58
Datastore php cursor example
//my cursor is set as a url variable ($_GET['albumoffset'])
$albumStore = new \GDS\Store('Tracks');
$obj_store->query("SELECT * FROM Albums");
$obj_store->setCursor(rawurldecode($_GET['albumoffset']));
$entity = $obj_store->fetchPage(1);
//do stuff with my new entity
//meta refresh the page with the new cursor.
@tristansokol
tristansokol / navbar3.html
Last active June 26, 2017 20:28
Navbar for sandbox dashboard blog post pt 3
<div class="nav-item">
<a href="/locations.php">Locations</a>
<a href="/transactions.php">Transactions</a>
<a href="/customers.php">Customers</a>
</div>
//Get locaiton id
<cfset jsonString = serializejson(request.params)>
<cfset requestPath = "connect.squareup.com/v2/locations">;
<cfhttp url="#requestPath#" method="get" result="response">
<cfhttpparam type="HEADER" name="Accept" value="application/json">
<cfhttpparam type="HEADER" name="Content-Type" value="application/json">
<cfhttpparam type="HEADER" name="Authorization" value="Bearer myid">
<cfhttpparam type="body" name="params" value="#jsonString#">
</cfhttp>
<cfset v_result = deserializeJSON(response.FileContent)>
<?php
//Use the access token from the session to access the API
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken($_SESSION['at']);
$customersApi = new SquareConnect\Api\CustomersApi();
try {
$result = $customersApi->listCustomers(); ?>
<div id="table" style="display:flex;flex-direction:column;">
<div class="row">
<div>Created at</div>
@tristansokol
tristansokol / deleteCustomer.js
Created July 19, 2017 22:15
sandbox dashboard blog post pt3 javascript funciton
function deleteCustomer(element){
if(!confirm('Are you sure you want to delete this customer?')){
return false;
}
var location = document.getElementById('location-id').value;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(this.responseText=='deleted'){
alert('deleted');
@tristansokol
tristansokol / delete-customer.php
Created July 19, 2017 22:21
sandbox dashboard pt3
<?php
//Start a session with the client
session_start();
require('vendor/autoload.php');
//Check for some basic errors.
if (!isset($_POST['customerId'])) {
echo "No customer id was supplied";
}
"info": {
"version": "2.0",
"title": "Square Connect API",
"description": "Client library for accessing the Square Connect APIs",
"termsOfService": "https://connect.squareup.com/tos",
"contact": {
"name": "Square Developer Platform",
"email": "developers@squareup.com",
"url": "https://squareup.com/developers"
},
"/v2/locations/{location_id}/transactions/{transaction_id}/refund": {
"post": {
"tags": [
"Transactions"
],
"summary": "CreateRefund",
"operationId": "CreateRefund",
"description": "Initiates a refund for a previously charged tender.\n\nYou must issue a refund within 120 days of the associated payment. See\n(this article)[https://squareup.com/help/us/en/article/5060] for more information\non refund behavior.",
"x-oauthpermissions": [
"PAYMENTS_WRITE"
"CreateRefundResponse": {
"type": "object",
"properties": {
"errors": {
"type": "array",
"items": {
"$ref": "#/definitions/Error"
},
"description": "Any errors that occurred during the request."
},
<?php
$api_instance = new SquareConnect\Api\CatalogApi();
$body = array(
'idempotency_key'=>uniqid(),
'object'=>array(
'type'=>'ITEM',
'id'=>'#temp-item-id',
'item_data'=>array(
'name'=>'Brass Tube',
'description'=>'Great for models',