Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
<?php
$location_id = 'location_id';
$api_instance = new SquareConnect\Api\V1ItemsApi();
$body = array(
'name'=>'Pots',
'description'=> 'Containers for gardening',
'variations'=> array(
array(
'name'=>'Large',
'price_money'=>array(
<?php
echo "Hello World"
?>
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('xxx');
$api_instance = new SquareConnect\Api\CatalogApi();
$body = new \SquareConnect\Model\UpsertCatalogObjectRequest(
array("idempotency_key"=>uniqid(),
"object"=>array(
@tristansokol
tristansokol / web-pos.html
Created August 21, 2017 19:32
simple example of a cross platform web-based point of sale
<!DOCTYPE html>
<html>
<head>
<title>Square Register API Web example</title>
<style type="text/css">
body {
background-color: #DDD;
margin: 10px;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
<?php
$location_id = 'XXXXXXXX';
$item_id = "XXXXXXXXX"; // string | The item's ID.
$api_instance = new SquareConnect\Api\V1ItemsApi();
try {
$result = $api_instance->retrieveItem($location_id, $item_id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling V1ItemsApi->retrieveItem: ', $e->getMessage(), PHP_EOL;
}
<?php
$api_instance = new SquareConnect\Api\CatalogApi();
$object_id = "XXXXXX";
$include_related_objects = true;
try {
$result = $api_instance->retrieveCatalogObject($object_id, $include_related_objects);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CatalogApi->retrieveCatalogObject: ', $e->getMessage(), PHP_EOL;
}
# Flags that we are using certbot on a different computer than the host.
manual
# Tells certbot where we want to store the ouput of respective processes
config-dir = ./config
logs-dir = ./logs
work-dir = ./work
#Specifies the domains that we want to create certificates for.
domains = example.com,www.example.com
echo "writing file to ../letsencrypt/$CERTBOT_TOKEN.txt"
echo $CERTBOT_VALIDATION > ../letsencrypt/${CERTBOT_TOKEN}.txt
gcloud app deploy ../app.yaml --project=xxx --quiet;
POST/v2/locations/LOCATION_ID/orders
{
"idempotency_key": "86ae1696-b1e3-4328-af6d-f1e04d947ad120",
"reference_id": "my-order-001",
"line_items": [
{
"catalog_object_id": "7WBTDGGMYEJYU2GINA7HHKO2",
"note": "catalog-note",
"quantity": "1",
"discounts": [
# load the gem
require 'square_connect'
# setup authorization with a personal access token
SquareConnect.configure do |config|
config.access_token = 'sq0atp-XXXXXXXXXXXXX'
end
#create a new API instance
api_instance = SquareConnect::CustomersApi.new