Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming all properties, structs and methods to match the API naming #459

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ i := event.List(nil)
for i.Next() {
e := i.Event()

// access event data via e.GetObjValue("resource_name_based_on_type", "resource_property_name")
// alternatively you can access values via e.Data.Obj["resource_name_based_on_type"].(map[string]interface{})["resource_property_name"]
// access event data via e.GetObjectValue("resource_name_based_on_type", "resource_property_name")
// alternatively you can access values via e.Data.Object["resource_name_based_on_type"].(map[string]interface{})["resource_property_name"]

// access previous attributes via e.GetPrevValue("resource_name_based_on_type", "resource_property_name")
// alternatively you can access values via e.Data.Prev["resource_name_based_on_type"].(map[string]interface{})["resource_property_name"]
// access previous attributes via e.GetPreviousValue("resource_name_based_on_type", "resource_property_name")
// alternatively you can access values via e.Data.PrevPreviousAttributes["resource_name_based_on_type"].(map[string]interface{})["resource_property_name"]
}
```

Expand Down
98 changes: 49 additions & 49 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,33 @@ const (
// Manual is a constant value representing a manual payout interval.
Manual Interval = "manual"

// Month is a constant value representing a monthly payout interval.
Month Interval = "monthly"
// Monthly is a constant value representing a monthly payout interval.
Monthly Interval = "monthly"

// Week is a constant value representing a weekly payout interval.
Week Interval = "weekly"
// Weekly is a constant value representing a weekly payout interval.
Weekly Interval = "weekly"
)

// AccountParams are the parameters allowed during account creation/updates.
type AccountParams struct {
Params `form:"*"`
BusinessName string `form:"business_name"`
BusinessPrimaryColor string `form:"business_primary_color"`
BusinessUrl string `form:"business_url"`
BusinessURL string `form:"business_url"`
Country string `form:"country"`
DebitNegativeBal bool `form:"debit_negative_balances"`
DebitNegativeBalances *bool `form:"debit_negative_balances"`
DefaultCurrency string `form:"default_currency"`
Email string `form:"email"`
ExternalAccount *AccountExternalAccountParams `form:"external_account"`
FromRecipient string `form:"from_recipient"`
LegalEntity *LegalEntity `form:"legal_entity"`
NoDebitNegativeBal bool `form:"debit_negative_balances,invert"`
PayoutSchedule *PayoutScheduleParams `form:"payout_schedule"`
PayoutStatement string `form:"payout_statement_descriptor"`
Statement string `form:"statement_descriptor"`
PayoutStatementDescriptor string `form:"payout_statement_descriptor"`
ProductDescription string `form:"product_description"`
StatementDescriptor string `form:"statement_descriptor"`
SupportEmail string `form:"support_email"`
SupportPhone string `form:"support_phone"`
SupportUrl string `form:"support_url"`
SupportURL string `form:"support_url"`
TOSAcceptance *TOSAcceptanceParams `form:"tos_acceptance"`
Type AccountType `form:"type"`
}
Expand All @@ -93,12 +93,12 @@ type AccountListParams struct {
// or everything else.
type AccountExternalAccountParams struct {
Params `form:"*"`
Account string `form:"account_number"`
AccountNumber string `form:"account_number"`
AccountHolderName string `form:"account_holder_name"`
AccountHolderType string `form:"account_holder_type"`
Country string `form:"country"`
Currency string `form:"currency"`
Routing string `form:"routing_number"`
RoutingNumber string `form:"routing_number"`
Token string `form:"token"`
}

Expand All @@ -115,15 +115,15 @@ func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []st

// PayoutScheduleParams are the parameters allowed for payout schedules.
type PayoutScheduleParams struct {
Delay uint64 `form:"delay_days"`
DelayDays uint64 `form:"delay_days"`
DelayDaysMinimum *bool `form:"-"` // See custom AppendTo
Interval Interval `form:"interval"`
MinimumDelay bool `form:"-"` // See custom AppendTo
MonthAnchor uint64 `form:"monthly_anchor"`
WeekAnchor string `form:"weekly_anchor"`
MonthlyAnchor uint64 `form:"monthly_anchor"`
WeeklyAnchor string `form:"weekly_anchor"`
}

func (p *PayoutScheduleParams) AppendTo(body *form.Values, keyParts []string) {
if p.MinimumDelay {
if BoolValue(p.DelayDaysMinimum) {
body.Add(form.FormatKey(append(keyParts, "delay_days")), "minimum")
}
}
Expand All @@ -134,10 +134,10 @@ type Account struct {
BusinessLogo string `json:"business_logo"`
BusinessName string `json:"business_name"`
BusinessPrimaryColor string `json:"business_primary_color"`
BusinessUrl string `json:"business_url"`
BusinessURL string `json:"business_url"`
ChargesEnabled bool `json:"charges_enabled"`
Country string `json:"country"`
DebitNegativeBal bool `json:"debit_negative_balances"`
DebitNegativeBalances bool `json:"debit_negative_balances"`
DefaultCurrency string `json:"default_currency"`
Deleted bool `json:"deleted"`
DetailsSubmitted bool `json:"details_submitted"`
Expand All @@ -151,17 +151,17 @@ type Account struct {
} `json:"keys"`

LegalEntity *LegalEntity `json:"legal_entity"`
Meta map[string]string `json:"metadata"`
Name string `json:"display_name"`
Metadata map[string]string `json:"metadata"`
DisplayName string `json:"display_name"`
PayoutSchedule *PayoutSchedule `json:"payout_schedule"`
PayoutStatement string `json:"payout_statement_descriptor"`
PayoutStatementDescriptor string `json:"payout_statement_descriptor"`
PayoutsEnabled bool `json:"payouts_enabled"`
ProductDesc string `json:"product_description"`
Statement string `json:"statement_descriptor"`
ProductDescription string `json:"product_description"`
StatementDescriptor string `json:"statement_descriptor"`
SupportAddress *Address `json:"support_address"`
SupportEmail string `json:"support_email"`
SupportPhone string `json:"support_phone"`
SupportUrl string `json:"support_url"`
SupportURL string `json:"support_url"`
Timezone string `json:"timezone"`

TOSAcceptance *struct {
Expand All @@ -174,8 +174,8 @@ type Account struct {

Verification *struct {
DisabledReason string `json:"disabled_reason"`
Due *int64 `json:"due_by"`
Fields []string `json:"fields_needed"`
DueBy *int64 `json:"due_by"`
FieldsNeeded []string `json:"fields_needed"`
} `json:"verification"`
}

Expand Down Expand Up @@ -225,7 +225,7 @@ const (
// AccountList is a list of accounts as returned from a list endpoint.
type AccountList struct {
ListMeta
Values []*Account `json:"data"`
Data []*Account `json:"data"`
}

// ExternalAccountList is a list of external accounts that may be either bank
Expand All @@ -235,7 +235,7 @@ type ExternalAccountList struct {

// Values contains any external accounts (bank accounts and/or cards)
// currently attached to this account.
Values []*ExternalAccount `json:"data"`
Data []*ExternalAccount `json:"data"`
}

// ExternalAccount is an external account (a bank account or card) that's
Expand Down Expand Up @@ -277,7 +277,7 @@ func (ea *ExternalAccount) UnmarshalJSON(b []byte) error {

// LegalEntity is the structure for properties related to an account's legal state.
type LegalEntity struct {
AdditionalOwners []Owner `json:"additional_owners" form:"additional_owners,indexed"`
AdditionalOwners []AdditionalOwner `json:"additional_owners" form:"additional_owners,indexed"`

// AdditionalOwnersEmpty can be set to clear a legal entity's additional
// owners.
Expand All @@ -294,22 +294,22 @@ type LegalEntity struct {
BusinessVatID string `json:"-" form:"business_vat_id"`
BusinessVatIDProvided bool `json:"business_vat_id_provided" form:"-"`
DOB DOB `json:"dob" form:"dob"`
First string `json:"first_name" form:"first_name"`
FirstKana string `json:"first_name_kana" form:"first_name_kana"`
FirstKanji string `json:"first_name_kanji" form:"first_name_kanji"`
FirstName string `json:"first_name" form:"first_name"`
FirstNameKana string `json:"first_name_kana" form:"first_name_kana"`
FirstNameKanji string `json:"first_name_kanji" form:"first_name_kanji"`
Gender Gender `json:"gender" form:"gender"`
Last string `json:"last_name" form:"last_name"`
LastKana string `json:"last_name_kana" form:"last_name_kana"`
LastKanji string `json:"last_name_kanji" form:"last_name_kanji"`
LastName string `json:"last_name" form:"last_name"`
LastNameKana string `json:"last_name_kana" form:"last_name_kana"`
LastNameKanji string `json:"last_name_kanji" form:"last_name_kanji"`
MaidenName string `json:"maiden_name" form:"maiden_name"`
PersonalAddress Address `json:"personal_address" form:"personal_address"`
PersonalAddressKana Address `json:"personal_address_kana" form:"personal_address_kana"`
PersonalAddressKanji Address `json:"personal_address_kanji" form:"personal_address_kanji"`
PersonalID string `json:"-" form:"personal_id_number"`
PersonalIDProvided bool `json:"personal_id_number_provided" form:"-"`
PersonalIDNumber string `json:"-" form:"personal_id_number"`
PersonalIDNumberProvided bool `json:"personal_id_number_provided" form:"-"`
PhoneNumber string `json:"phone_number" form:"phone_number"`
SSN string `json:"-" form:"ssn_last_4"`
SSNProvided bool `json:"ssn_last_4_provided" form:"-"`
SSNLast4 string `json:"-" form:"ssn_last_4"`
SSNLast4Provided bool `json:"ssn_last_4_provided" form:"-"`
Type LegalEntityType `json:"type" form:"type"`
Verification IdentityVerification `json:"verification" form:"verification"`
}
Expand All @@ -320,13 +320,12 @@ type Address struct {
Country string `json:"country" form:"country"`
Line1 string `json:"line1" form:"line1"`
Line2 string `json:"line2" form:"line2"`
PostalCode string `json:"postal_code" form:"postal_code"`
State string `json:"state" form:"state"`

// Town/cho-me. Note that this is only used for Kana/Kanji representations
// of an address.
Town string `json:"town" form:"town"`

Zip string `json:"postal_code" form:"postal_code"`
}

// DOB is a structure for an account owner's date of birth.
Expand All @@ -340,12 +339,13 @@ type DOB struct {
// either “male” or “female”.
type Gender string

// Owner is the structure for an account owner.
type Owner struct {
// AdditionalOwner is the structure for an account owner.
type AdditionalOwner struct {
Address Address `json:"address" form:"address"`
DOB DOB `json:"dob" form:"dob"`
First string `json:"first_name" form:"first_name"`
Last string `json:"last_name" form:"last_name"`
FirstName string `json:"first_name" form:"first_name"`
LastName string `json:"last_name" form:"last_name"`
MaidenName string `json:"maiden_name" form:"maiden_name"`
Verification IdentityVerification `json:"verification" form:"verification"`
}

Expand Down Expand Up @@ -383,10 +383,10 @@ func (d *IdentityDocument) AppendTo(body *form.Values, keyParts []string) {

// PayoutSchedule is the structure for an account's payout schedule.
type PayoutSchedule struct {
Delay uint64 `json:"delay_days" form:"delay_days"`
DelayDays uint64 `json:"delay_days" form:"delay_days"`
Interval Interval `json:"interval" form:"interval"`
MonthAnchor uint64 `json:"monthly_anchor" form:"monthly_anchor"`
WeekAnchor string `json:"weekly_anchor" form:"weekly_anchor"`
MonthlyAnchor uint64 `json:"monthly_anchor" form:"monthly_anchor"`
WeeklyAnchor string `json:"weekly_anchor" form:"weekly_anchor"`
}

// TOSAcceptanceParams is the structure for TOS acceptance.
Expand Down
4 changes: 2 additions & 2 deletions account/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ func (c Client) List(params *stripe.AccountListParams) *Iter {
list := &stripe.AccountList{}
err := c.B.Call("GET", "/accounts", c.Key, b, p, list)

ret := make([]interface{}, len(list.Values))
for i, v := range list.Values {
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}

Expand Down
12 changes: 6 additions & 6 deletions account/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ func TestAccountNew(t *testing.T) {
account, err := New(&stripe.AccountParams{
Type: stripe.AccountTypeCustom,
Country: "CA",
BusinessUrl: "www.stripe.com",
BusinessURL: "www.stripe.com",
BusinessName: "Stripe",
BusinessPrimaryColor: "#ffffff",
DebitNegativeBal: true,
DebitNegativeBalances: stripe.Bool(true),
SupportEmail: "[email protected]",
SupportUrl: "www.stripe.com",
SupportURL: "www.stripe.com",
SupportPhone: "4151234567",
LegalEntity: &stripe.LegalEntity{
Type: stripe.Individual,
BusinessName: "Stripe Go",
AdditionalOwners: []stripe.Owner{
{First: "Jane"},
AdditionalOwners: []stripe.AdditionalOwner{
{FirstName: "Jane"},
},
DOB: stripe.DOB{
Day: 1,
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestAccountUpdate(t *testing.T) {
Address: stripe.Address{
Country: "CA",
City: "Montreal",
Zip: "H2Y 1C6",
PostalCode: "H2Y 1C6",
Line1: "275, rue Notre-Dame Est",
State: "QC",
},
Expand Down
10 changes: 5 additions & 5 deletions account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func TestAccountUnmarshal(t *testing.T) {
assert.NoError(t, err)

assert.Equal(t, "acct_123", account.ID)
assert.Equal(t, true, account.ExternalAccounts.More)
assert.Equal(t, true, account.ExternalAccounts.HasMore)

assert.Equal(t, 2, len(account.ExternalAccounts.Values))
assert.Equal(t, "ba_123", account.ExternalAccounts.Values[0].ID)
assert.Equal(t, "card_123", account.ExternalAccounts.Values[1].ID)
assert.Equal(t, 2, len(account.ExternalAccounts.Data))
assert.Equal(t, "ba_123", account.ExternalAccounts.Data[0].ID)
assert.Equal(t, "card_123", account.ExternalAccounts.Data[1].ID)
}

func TestIdentityDocument_Appendto(t *testing.T) {
Expand All @@ -80,7 +80,7 @@ func TestIdentityDocument_Appendto(t *testing.T) {

func TestPayoutScheduleParams_AppendTo(t *testing.T) {
{
params := &PayoutScheduleParams{MinimumDelay: true}
params := &PayoutScheduleParams{DelayDaysMinimum: Bool(true)}
body := &form.Values{}
form.AppendTo(body, params)
t.Logf("body = %+v", body)
Expand Down
4 changes: 2 additions & 2 deletions applepaydomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ApplePayDomain struct {
Deleted bool `json:"deleted"`
DomainName string `json:"domain_name"`
ID string `json:"id"`
Live bool `json:"livemode"`
Livemode bool `json:"livemode"`
}

// ApplePayDomainListParams are the parameters allowed during ApplePayDomain listing.
Expand All @@ -23,5 +23,5 @@ type ApplePayDomainListParams struct {
// ApplePayDomainList is a list of ApplePayDomains as returned from a list endpoint.
type ApplePayDomainList struct {
ListMeta
Values []*ApplePayDomain `json:"data"`
Data []*ApplePayDomain `json:"data"`
}
4 changes: 2 additions & 2 deletions applepaydomain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func (c Client) List(params *stripe.ApplePayDomainListParams) *Iter {
list := &stripe.ApplePayDomainList{}
err := c.B.Call("GET", "/apple_pay/domains", c.Key, b, p, list)

ret := make([]interface{}, len(list.Values))
for i, v := range list.Values {
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}

Expand Down
Loading