This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET --header "Accept:application/json" -v https://connect.squareup.com/v2/catalog/list -k --header "Authorization: Bearer sq0atp-4vmnKMsf5n-6ZxFa5qMlhA" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
import ( | |
"github.com/jinzhu/gorm" | |
) | |
type Subscription struct { | |
gorm.Model | |
Name string `gorm:"not null"` | |
DevicesAllowed int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` |