Skip to content

Commit

Permalink
Location Entity: Change Closed field to bool to match API response
Browse files Browse the repository at this point in the history
  • Loading branch information
Upal Saha committed Oct 19, 2018
1 parent ee72a85 commit eaba26a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
90 changes: 45 additions & 45 deletions cftasset.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type CFTAsset struct {
Type AssetType `json:"type,omitempty"`
Description *string `json:"description,omitempty"`
ForEntities *ForEntities `json:"forEntities,omitempty"`
Usage *AssetUsageList `json:"usage,omitempty"`
Usage *AssetUsageList `json:"usage,omitempty"`
Locale *string `json:"locale,omitempty"`
Labels *UnorderedStrings `json:"labels,omitempty"`
Owner *uint64 `json:"owner,omitempty"`
Expand All @@ -64,55 +64,55 @@ type AssetUsage struct {
}

func (a *AssetUsage) Equal(b Comparable) bool {
defer func() {
if r := recover(); r != nil {
fmt.Printf("Value of A: %+v, Value of B:%+v, Type Of A: %T, Type Of B: %T\n", a, b, a, b)
panic(r)
}
}()

bAssetUsage := *b.(*AssetUsage)
if a.Type != bAssetUsage.Type || !a.FieldNames.Equal(bAssetUsage.FieldNames) {
return false
}

return true
defer func() {
if r := recover(); r != nil {
fmt.Printf("Value of A: %+v, Value of B:%+v, Type Of A: %T, Type Of B: %T\n", a, b, a, b)
panic(r)
}
}()

bAssetUsage := *b.(*AssetUsage)
if a.Type != bAssetUsage.Type || !a.FieldNames.Equal(bAssetUsage.FieldNames) {
return false
}

return true
}

type AssetUsageList []AssetUsage

func (a *AssetUsageList) Equal(b Comparable) bool {
defer func() {
if r := recover(); r != nil {
fmt.Printf("Value of A: %+v, Value of B:%+v, Type Of A: %T, Type Of B: %T\n", a, b, a, b)
panic(r)
}
}()

if a == nil || b == nil {
return false
}

var (
u = []AssetUsage(*a)
s = []AssetUsage(*b.(*AssetUsageList))
)
if len(u) != len(s) {
return false
}

for i := 0; i < len(u); i++ {
var found bool
for j := 0; j < len(s); j++ {
if u[i].Equal(&s[j]) {
found = true
}
}
if !found {
return false
}
}
return true
defer func() {
if r := recover(); r != nil {
fmt.Printf("Value of A: %+v, Value of B:%+v, Type Of A: %T, Type Of B: %T\n", a, b, a, b)
panic(r)
}
}()

if a == nil || b == nil {
return false
}

var (
u = []AssetUsage(*a)
s = []AssetUsage(*b.(*AssetUsageList))
)
if len(u) != len(s) {
return false
}

for i := 0; i < len(u); i++ {
var found bool
for j := 0; j < len(s); j++ {
if u[i].Equal(&s[j]) {
found = true
}
}
if !found {
return false
}
}
return true
}

type TextValue string
Expand Down
4 changes: 2 additions & 2 deletions location_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type LocationEntity struct {
FolderId *string `json:"folderId,omitempty"`
LabelIds *UnorderedStrings `json:"labelIds,omitempty"`
CategoryIds *[]string `json:"categoryIds,omitempty"`
Closed *LocationClosed `json:"closed,omitempty"`
Closed *bool `json:"closed,omitempty"`
Keywords *[]string `json:"keywords,omitempty"`
Language *string `json:"language,omitempty"`

Expand Down Expand Up @@ -656,7 +656,7 @@ func (y LocationEntity) GetHolidayHours() []HolidayHours {
}

func (y LocationEntity) IsClosed() bool {
if y.Closed != nil && y.Closed.IsClosed {
if y.Closed != nil && *y.Closed {
return true
}
return false
Expand Down

0 comments on commit eaba26a

Please sign in to comment.