Skip to content

Commit

Permalink
Moving all int/uint to int64 for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Jun 6, 2018
1 parent 0af1351 commit eeafe40
Show file tree
Hide file tree
Showing 36 changed files with 112 additions and 168 deletions.
14 changes: 7 additions & 7 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ type AccountAddressParams struct {

// DOBParams represents a DOB during account creation/updates.
type DOBParams struct {
Day *int `form:"day"`
Month *int `form:"month"`
Year *int `form:"year"`
Day *int64 `form:"day"`
Month *int64 `form:"month"`
Year *int64 `form:"year"`
}

// TOSAcceptanceParams represents tos_acceptance during account creation/updates.
Expand Down Expand Up @@ -194,10 +194,10 @@ func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []st

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

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

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

Expand Down
6 changes: 3 additions & 3 deletions account/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func TestAccountNew(t *testing.T) {
{FirstName: stripe.String("Jane")},
},
DOB: &stripe.DOBParams{
Day: stripe.Int(1),
Month: stripe.Int(2),
Year: stripe.Int(1990),
Day: stripe.Int64(1),
Month: stripe.Int64(2),
Year: stripe.Int64(1990),
},
},
TOSAcceptance: &stripe.TOSAcceptanceParams{
Expand Down
10 changes: 5 additions & 5 deletions bitcoinreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type BitcoinReceiverListParams struct {
// For more details see https://stripe.com/docs/api/#create_bitcoin_receiver.
type BitcoinReceiverParams struct {
Params `form:"*"`
Amount *uint64 `form:"amount"`
Amount *int64 `form:"amount"`
Currency *string `form:"currency"`
Desc *string `form:"description"`
Email *string `form:"email"`
Expand All @@ -37,10 +37,10 @@ type BitcoinReceiverUpdateParams struct {
// For more details see https://stripe.com/docs/api/#bitcoin_receivers
type BitcoinReceiver struct {
Active bool `json:"active"`
Amount uint64 `json:"amount"`
AmountReceived uint64 `json:"amount_received"`
BitcoinAmount uint64 `json:"bitcoin_amount"`
BitcoinAmountReceived uint64 `json:"bitcoin_amount_received"`
Amount int64 `json:"amount"`
AmountReceived int64 `json:"amount_received"`
BitcoinAmount int64 `json:"bitcoin_amount"`
BitcoinAmountReceived int64 `json:"bitcoin_amount_received"`
BitcoinUri string `json:"bitcoin_uri"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Expand Down
4 changes: 2 additions & 2 deletions bitcointransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type BitcoinTransactionList struct {
// BitcoinTransaction is the resource representing a Stripe bitcoin transaction.
// For more details see https://stripe.com/docs/api/#bitcoin_receivers
type BitcoinTransaction struct {
Amount uint64 `json:"amount"`
BitcoinAmount uint64 `json:"bitcoin_amount"`
Amount int64 `json:"amount"`
BitcoinAmount int64 `json:"bitcoin_amount"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Customer string `json:"customer"`
Expand Down
14 changes: 7 additions & 7 deletions charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type FraudReport string
// For more details see https://stripe.com/docs/api#create_charge and https://stripe.com/docs/api#update_charge.
type ChargeParams struct {
Params `form:"*"`
Amount *uint64 `form:"amount"`
ApplicationFee *uint64 `form:"application_fee"`
Amount *int64 `form:"amount"`
ApplicationFee *int64 `form:"application_fee"`
Capture *bool `form:"capture"`
Currency *string `form:"currency"`
Customer *string `form:"customer"`
Expand Down Expand Up @@ -52,7 +52,7 @@ func (p *ChargeParams) SetSource(sp interface{}) error {

type DestinationParams struct {
Account *string `form:"account"`
Amount *uint64 `form:"amount"`
Amount *int64 `form:"amount"`
}

// FraudDetailsParams provides information on the fraud details for a charge.
Expand All @@ -74,8 +74,8 @@ type ChargeListParams struct {
// For more details see https://stripe.com/docs/api#charge_capture.
type CaptureParams struct {
Params `form:"*"`
Amount *uint64 `form:"amount"`
ApplicationFee *uint64 `form:"application_fee"`
Amount *int64 `form:"amount"`
ApplicationFee *int64 `form:"application_fee"`
ExchangeRate *float64 `form:"exchange_rate"`
ReceiptEmail *string `form:"receipt_email"`
StatementDescriptor *string `form:"statement_descriptor"`
Expand All @@ -84,8 +84,8 @@ type CaptureParams struct {
// Charge is the resource representing a Stripe charge.
// For more details see https://stripe.com/docs/api#charges.
type Charge struct {
Amount uint64 `json:"amount"`
AmountRefunded uint64 `json:"amount_refunded"`
Amount int64 `json:"amount"`
AmountRefunded int64 `json:"amount_refunded"`
Application *Application `json:"application"`
ApplicationFee *ApplicationFee `json:"application_fee"`
BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
Expand Down
4 changes: 2 additions & 2 deletions charge/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestChargeMarkFraudulent(t *testing.T) {

func TestChargeNew(t *testing.T) {
charge, err := New(&stripe.ChargeParams{
Amount: stripe.UInt64(123),
Amount: stripe.Int64(123),
Currency: stripe.String(string(currency.USD)),
Source: &stripe.SourceParams{Token: stripe.String("src_123")},
Shipping: &stripe.ShippingDetailsParams{
Expand All @@ -62,7 +62,7 @@ func TestChargeNew(t *testing.T) {

func TestChargeNew_WithSetSource(t *testing.T) {
params := stripe.ChargeParams{
Amount: stripe.UInt64(123),
Amount: stripe.Int64(123),
Currency: stripe.String(string(currency.USD)),
}
params.SetSource("tok_123")
Expand Down
2 changes: 1 addition & 1 deletion charge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestChargeParams_AppendTo(t *testing.T) {
{
params := &ChargeParams{Amount: UInt64(123)}
params := &ChargeParams{Amount: Int64(123)}
body := &form.Values{}
form.AppendTo(body, params)
t.Logf("body = %+v", body)
Expand Down
18 changes: 9 additions & 9 deletions coupon.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ type CouponDuration string
// For more details see https://stripe.com/docs/api#create_coupon.
type CouponParams struct {
Params `form:"*"`
AmountOff *uint64 `form:"amount_off"`
AmountOff *int64 `form:"amount_off"`
Currency *string `form:"currency"`
Duration *string `form:"duration"`
DurationInMonths *uint64 `form:"duration_in_months"`
DurationInMonths *int64 `form:"duration_in_months"`
ID *string `form:"id"`
MaxRedemptions *uint64 `form:"max_redemptions"`
PercentOff *uint64 `form:"percent_off"`
MaxRedemptions *int64 `form:"max_redemptions"`
PercentOff *int64 `form:"percent_off"`
RedeemBy *int64 `form:"redeem_by"`
}

Expand All @@ -31,19 +31,19 @@ type CouponListParams struct {
// Coupon is the resource representing a Stripe coupon.
// For more details see https://stripe.com/docs/api#coupons.
type Coupon struct {
AmountOff uint64 `json:"amount_off"`
AmountOff int64 `json:"amount_off"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Deleted bool `json:"deleted"`
Duration CouponDuration `json:"duration"`
DurationInMonths uint64 `json:"duration_in_months"`
DurationInMonths int64 `json:"duration_in_months"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
MaxRedemptions uint64 `json:"max_redemptions"`
MaxRedemptions int64 `json:"max_redemptions"`
Metadata map[string]string `json:"metadata"`
PercentOff uint64 `json:"percent_off"`
PercentOff int64 `json:"percent_off"`
RedeemBy int64 `json:"redeem_by"`
TimesRedeemed uint64 `json:"times_redeemed"`
TimesRedeemed int64 `json:"times_redeemed"`
Valid bool `json:"valid"`
}

Expand Down
4 changes: 2 additions & 2 deletions coupon/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func TestCouponNew(t *testing.T) {
coupon, err := New(&stripe.CouponParams{
Currency: stripe.String(string(currency.USD)),
Duration: stripe.String(string(Repeating)),
DurationInMonths: stripe.UInt64(3),
DurationInMonths: stripe.Int64(3),
ID: stripe.String("25OFF"),
PercentOff: stripe.UInt64(25),
PercentOff: stripe.Int64(25),
})
assert.Nil(t, err)
assert.NotNil(t, coupon)
Expand Down
2 changes: 1 addition & 1 deletion customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CustomerParams struct {
Description *string `form:"description"`
Email *string `form:"email"`
Plan *string `form:"plan"`
Quantity *uint64 `form:"quantity"`
Quantity *int64 `form:"quantity"`
Shipping *CustomerShippingDetailsParams `form:"shipping"`
Source *SourceParams `form:"*"` // SourceParams has custom encoding so brought to top level with "*"
TaxPercent *float64 `form:"tax_percent"`
Expand Down
2 changes: 1 addition & 1 deletion dispute.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type DisputeListParams struct {
// Dispute is the resource representing a Stripe dispute.
// For more details see https://stripe.com/docs/api#disputes.
type Dispute struct {
Amount uint64 `json:"amount"`
Amount int64 `json:"amount"`
BalanceTransactions []*BalanceTransaction `json:"balance_transactions"`
Charge *Charge `json:"charge"`
Created int64 `json:"created"`
Expand Down
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Event struct {
Data *EventData `json:"data"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
PendingWebhooks uint64 `json:"pending_webhooks"`
PendingWebhooks int64 `json:"pending_webhooks"`
Request *EventRequest `json:"request"`
Type string `json:"type"`
}
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func ExampleCharge_new() {
stripe.Key = "sk_key"

params := &stripe.ChargeParams{
Amount: stripe.UInt64(1000),
Amount: stripe.Int64(1000),
Currency: stripe.String(string(currency.USD)),
}
params.SetSource("tok_visa")
Expand Down
4 changes: 2 additions & 2 deletions fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type ApplicationFeeListParams struct {
// For more details see https://stripe.com/docs/api#application_fees.
type ApplicationFee struct {
Account *Account `json:"account"`
Amount uint64 `json:"amount"`
AmountRefunded uint64 `json:"amount_refunded"`
Amount int64 `json:"amount"`
AmountRefunded int64 `json:"amount_refunded"`
Application string `json:"application"`
BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
Charge *Charge `json:"charge"`
Expand Down
4 changes: 2 additions & 2 deletions feerefund.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// For more details see https://stripe.com/docs/api#fee_refund.
type ApplicationFeeRefundParams struct {
Params `form:"*"`
Amount *uint64 `form:"amount"`
Amount *int64 `form:"amount"`
ApplicationFee *string `form:"-"` // Included in the URL
}

Expand All @@ -22,7 +22,7 @@ type ApplicationFeeRefundListParams struct {
// ApplicationFeeRefund is the resource representing a Stripe application fee refund.
// For more details see https://stripe.com/docs/api#fee_refunds.
type ApplicationFeeRefund struct {
Amount uint64 `json:"amount"`
Amount int64 `json:"amount"`
BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Expand Down
10 changes: 5 additions & 5 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type InvoiceBilling string
// For more details see https://stripe.com/docs/api#create_invoice, https://stripe.com/docs/api#update_invoice.
type InvoiceParams struct {
Params `form:"*"`
ApplicationFee *uint64 `form:"application_fee"`
ApplicationFee *int64 `form:"application_fee"`
Billing *string `form:"billing"`
Closed *bool `form:"closed"`
Customer *string `form:"customer"`
DaysUntilDue *uint64 `form:"days_until_due"`
DaysUntilDue *int64 `form:"days_until_due"`
Description *string `form:"description"`
DueDate *int64 `form:"due_date"`
Forgiven *bool `form:"forgiven"`
Expand All @@ -33,7 +33,7 @@ type InvoiceParams struct {
SubscriptionPlan *string `form:"subscription_plan"`
SubscriptionProrate *bool `form:"subscription_prorate"`
SubscriptionProrationDate *int64 `form:"subscription_proration_date"`
SubscriptionQuantity *uint64 `form:"subscription_quantity"`
SubscriptionQuantity *int64 `form:"subscription_quantity"`
SubscriptionTrialEnd *int64 `form:"subscription_trial_end"`
}

Expand Down Expand Up @@ -66,8 +66,8 @@ type InvoiceLineListParams struct {
// For more details see https://stripe.com/docs/api#invoice_object.
type Invoice struct {
AmountDue int64 `json:"amount_due"`
ApplicationFee uint64 `json:"application_fee"`
AttemptCount uint64 `json:"attempt_count"`
ApplicationFee int64 `json:"application_fee"`
AttemptCount int64 `json:"attempt_count"`
Attempted bool `json:"attempted"`
Billing InvoiceBilling `json:"billing"`
Charge *Charge `json:"charge"`
Expand Down
24 changes: 12 additions & 12 deletions plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ const (
// Plan is the resource representing a Stripe plan.
// For more details see https://stripe.com/docs/api#plans.
type Plan struct {
Amount uint64 `json:"amount"`
Amount int64 `json:"amount"`
BillingScheme string `json:"billing_scheme"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Deleted bool `json:"deleted"`
ID string `json:"id"`
Interval PlanInterval `json:"interval"`
IntervalCount uint64 `json:"interval_count"`
IntervalCount int64 `json:"interval_count"`
Livemode bool `json:"livemode"`
Metadata map[string]string `json:"metadata"`
Nickname string `json:"nickname"`
Product string `json:"product"`
Tiers []*PlanTier `json:"tiers"`
TiersMode string `json:"tiers_mode"`
TransformUsage *PlanTransformUsage `json:"transform_usage"`
TrialPeriodDays uint64 `json:"trial_period_days"`
TrialPeriodDays int64 `json:"trial_period_days"`
UsageType string `json:"usage_type"`
}

Expand All @@ -77,26 +77,26 @@ type PlanListParams struct {
// For more details see https://stripe.com/docs/api#create_plan and https://stripe.com/docs/api#update_plan.
type PlanParams struct {
Params `form:"*"`
Amount *uint64 `form:"amount"`
Amount *int64 `form:"amount"`
BillingScheme *string `form:"billing_scheme"`
Currency *string `form:"currency"`
ID *string `form:"id"`
Interval *string `form:"interval"`
IntervalCount *uint64 `form:"interval_count"`
IntervalCount *int64 `form:"interval_count"`
Nickname *string `form:"nickname"`
Product *ProductParams `form:"product"`
ProductID *string `form:"product"`
Tiers []*PlanTierParams `form:"tiers,indexed"`
TiersMode *string `form:"tiers_mode"`
TransformUsage *PlanTransformUsageParams `form:"transform_usage"`
TrialPeriodDays *uint64 `form:"trial_period_days"`
TrialPeriodDays *int64 `form:"trial_period_days"`
UsageType *string `form:"usage_type"`
}

// PlanTier configures tiered pricing
type PlanTier struct {
Amount uint64 `json:"amount"`
UpTo uint64 `json:"up_to"`
Amount int64 `json:"amount"`
UpTo int64 `json:"up_to"`
}

// PlanTransformUsage represents the bucket billing configuration.
Expand All @@ -114,17 +114,17 @@ type PlanTransformUsageParams struct {
// PlanTierParams configures tiered pricing
type PlanTierParams struct {
Params `form:"*"`
Amount *uint64 `form:"amount"`
UpTo *uint64 `form:"-"` // handled in custom AppendTo
UpToInf *bool `form:"-"` // handled in custom AppendTo
Amount *int64 `form:"amount"`
UpTo *int64 `form:"-"` // handled in custom AppendTo
UpToInf *bool `form:"-"` // handled in custom AppendTo
}

// AppendTo implements custom up_to serialisation logic for tiers configuration
func (p *PlanTierParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.UpToInf) {
body.Add(form.FormatKey(append(keyParts, "up_to")), "inf")
} else {
body.Add(form.FormatKey(append(keyParts, "up_to")), strconv.FormatUint(UInt64Value(p.UpTo), 10))
body.Add(form.FormatKey(append(keyParts, "up_to")), strconv.FormatInt(Int64Value(p.UpTo), 10))
}
}

Expand Down
Loading

0 comments on commit eeafe40

Please sign in to comment.