Created
September 1, 2016 06:33
-
-
Save zeekay/62fd2a1829790d68ddd0290281886a24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 gochimp3 | |
import ( | |
"encoding/json" | |
"strings" | |
"time" | |
) | |
func (address *Address) MarshalJSON() ([]byte, error) { | |
tmp := struct { | |
Address | |
CountryCode string `json:"country_code"` | |
}{ | |
Address: *address, | |
CountryCode: strings.ToUpper(address.CountryCode), | |
} | |
return json.Marshal(tmp) | |
} | |
func (loc *MemberLocation) MarshalJSON() ([]byte, error) { | |
tmp := struct { | |
MemberLocation | |
CountryCode string `json:"country_code"` | |
}{ | |
MemberLocation: *loc, | |
CountryCode: strings.ToUpper(loc.CountryCode), | |
} | |
return json.Marshal(tmp) | |
} | |
func (store *Store) MarshalJSON() ([]byte, error) { | |
tmp := struct { | |
Store | |
CurrencyCode string `json:"currency_code"` | |
}{ | |
Store: *store, | |
CurrencyCode: strings.ToUpper(store.CurrencyCode), | |
} | |
return json.Marshal(tmp) | |
} | |
func (cart *Cart) MarshalJSON() ([]byte, error) { | |
tmp := struct { | |
Cart | |
CurrencyCode string `json:"currency_code"` | |
}{ | |
Cart: *cart, | |
CurrencyCode: strings.ToUpper(cart.CurrencyCode), | |
} | |
return json.Marshal(tmp) | |
} | |
func (order *Order) MarshalJSON() ([]byte, error) { | |
tmp := struct { | |
Order | |
CurrencyCode string `json:"currency_code"` | |
ProcessedAtForeign string `json:"processed_at_foreign"` | |
CancelledAtForeign string `json:"cancelled_at_foreign"` | |
UpdatedAtForeign string `json:"updated_at_foreign"` | |
}{ | |
Order: *order, | |
CurrencyCode: strings.ToUpper(order.CurrencyCode), | |
ProcessedAtForeign: order.ProcessedAtForeign.Format(time.RFC3339), | |
CancelledAtForeign: order.CancelledAtForeign.Format(time.RFC3339), | |
UpdatedAtForeign: order.UpdatedAtForeign.Format(time.RFC3339), | |
} | |
return json.Marshal(tmp) | |
} | |
func (product *Product) MarshalJSON() ([]byte, error) { | |
tmp := struct { | |
Product | |
PublishedAtForeign string `json:"published_at_foreign"` | |
}{ | |
Product: *product, | |
PublishedAtForeign: product.PublishedAtForeign.Format(time.RFC3339), | |
} | |
return json.Marshal(tmp) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment