Skip to content

Instantly share code, notes, and snippets.

View yshuman1's full-sized avatar
🎯
Focusing

Yasin Shuman yshuman1

🎯
Focusing
View GitHub Profile
{
"objects": [
{
"type": "ITEM",
"id": "HT5NBV4WEXBR6XNNH7OKUQQI",
"updated_at": "2019-02-22T07:55:53.266Z",
"version": 1550822153266,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
// GetItems returns a merchants items for a specific location
func GetItems(token string, locationID string) ([]model.Item, error) {
itemsURL := "https://connect.squareup.com/v2/catalog/list"
// create url for GET
req, err := http.NewRequest("GET", itemsURL, nil)
if err != nil {
log.Error("Error fetching items")
panic(err)
}
// set the Auth header w/ the token from square
package model
import "time"
type Item struct {
Type string `json:"type"`
ID string `json:"id"`
UpdatedAt time.Time `json:"updated_at"`
Version int64 `json:"version"`
IsDeleted bool `json:"is_deleted"`
curl -X GET --header "Accept:application/json" -v https://connect.squareup.com/v2/catalog/list -k --header "Authorization: Bearer sq0atp-4vmnKMsf5n-6ZxFa5qMlhA"
// GetItems returns a merchants items for a specific location
func GetItems(token string) ([]model.ItemInfo, error) {
itemsURL := "https://connect.squareup.com/v2/catalog/list"
// create url for GET
req, err := http.NewRequest("GET", itemsURL, nil)
if err != nil {
log.Error("Error fetching items")
panic(err)
}
// set the Auth header w/ the token from square
package model
import "time"
type Item struct {
Type string `json:"type"`
ID string `json:"id"`
UpdatedAt time.Time `json:"updated_at"`
Version int64 `json:"version"`
IsDeleted bool `json:"is_deleted"`
func (ss *SubscriptionService) Update(sub *Subscription) error {
var subscription Subscription
db := ss.db.Where(&Subscription{Name: sub.Name})
err := first(db, &subscription)
if err != nil {
log.Error("error looking up subscription")
return err
}
subscription.Price = sub.Price
subscription.Active = sub.Active
func (ss *SubscriptionService) Update(sub *Subscription) error {
var subscription Subscription
db := ss.db.Where(&Subscription{Name: sub.Name})
err := first(db, &subscription)
if err != nil {
log.Error("error looking up subscription")
return err
}
return ss.db.Save(subscription).Error
package model
import (
"github.com/jinzhu/gorm"
)
type Subscription struct {
gorm.Model
Name string `gorm:"not null"`
DevicesAllowed int
@yshuman1
yshuman1 / kiosk.go
Last active February 14, 2019 02:04
package model
import (
"github.com/jinzhu/gorm"
)
// Kiosk represents the tablet model stored in our db
type Kiosk struct {
gorm.Model
UserID uint `gorm:"not null; unique_index:user_id_service"`