• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-go / 11296113556

11 Oct 2024 04:42PM UTC coverage: 62.991% (-0.02%) from 63.015%
11296113556

Pull #1934

github

stripe-openapi[bot]
Update generated code for v1291
Pull Request #1934: Update generated code for beta

0 of 8 new or added lines in 2 files covered. (0.0%)

469 existing lines in 20 files now uncovered.

6209 of 9857 relevant lines covered (62.99%)

15.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/billing_creditgrant.go
1
//
2
//
3
// File generated from our OpenAPI spec
4
//
5
//
6

7
package stripe
8

9
import "encoding/json"
10

11
// The type of this amount. We currently only support `monetary` billing credits.
12
type BillingCreditGrantAmountType string
13

14
// List of values that BillingCreditGrantAmountType can take
15
const (
16
        BillingCreditGrantAmountTypeMonetary BillingCreditGrantAmountType = "monetary"
17
)
18

19
// The price type to which credit grants can apply to. We currently only support `metered` price type.
20
type BillingCreditGrantApplicabilityConfigScopePriceType string
21

22
// List of values that BillingCreditGrantApplicabilityConfigScopePriceType can take
23
const (
24
        BillingCreditGrantApplicabilityConfigScopePriceTypeMetered BillingCreditGrantApplicabilityConfigScopePriceType = "metered"
25
)
26

27
// The category of this credit grant.
28
type BillingCreditGrantCategory string
29

30
// List of values that BillingCreditGrantCategory can take
31
const (
32
        BillingCreditGrantCategoryPaid        BillingCreditGrantCategory = "paid"
33
        BillingCreditGrantCategoryPromotional BillingCreditGrantCategory = "promotional"
34
)
35

36
// Retrieve a list of credit grants
37
type BillingCreditGrantListParams struct {
38
        ListParams `form:"*"`
39
        // Only return credit grants for this customer.
40
        Customer *string `form:"customer"`
41
        // Specifies which fields in the response should be expanded.
42
        Expand []*string `form:"expand"`
43
}
44

45
// AddExpand appends a new field to expand.
46
func (p *BillingCreditGrantListParams) AddExpand(f string) {
×
47
        p.Expand = append(p.Expand, &f)
×
48
}
×
49

50
// The monetary amount.
51
type BillingCreditGrantAmountMonetaryParams struct {
52
        // Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the `value` parameter.
53
        Currency *string `form:"currency"`
54
        // A positive integer representing the amount of the credit grant.
55
        Value *int64 `form:"value"`
56
}
57

58
// Amount of this credit grant.
59
type BillingCreditGrantAmountParams struct {
60
        // The monetary amount.
61
        Monetary *BillingCreditGrantAmountMonetaryParams `form:"monetary"`
62
        // Specify the type of this amount. We currently only support `monetary` billing credits.
63
        Type *string `form:"type"`
64
}
65

66
// Specify the scope of this applicability config.
67
type BillingCreditGrantApplicabilityConfigScopeParams struct {
68
        // The price type to which credit grants can apply to. We currently only support `metered` price type.
69
        PriceType *string `form:"price_type"`
70
}
71

72
// Configuration specifying what this credit grant applies to.
73
type BillingCreditGrantApplicabilityConfigParams struct {
74
        // Specify the scope of this applicability config.
75
        Scope *BillingCreditGrantApplicabilityConfigScopeParams `form:"scope"`
76
}
77

78
// Creates a credit grant
79
type BillingCreditGrantParams struct {
80
        Params `form:"*"`
81
        // Amount of this credit grant.
82
        Amount *BillingCreditGrantAmountParams `form:"amount"`
83
        // Configuration specifying what this credit grant applies to.
84
        ApplicabilityConfig *BillingCreditGrantApplicabilityConfigParams `form:"applicability_config"`
85
        // The category of this credit grant.
86
        Category *string `form:"category"`
87
        // ID of the customer to whom the billing credits should be granted.
88
        Customer *string `form:"customer"`
89
        // The time when the billing credits become effective i.e when they are eligible to be used. Defaults to the current timestamp if not specified.
90
        EffectiveAt *int64 `form:"effective_at"`
91
        // Specifies which fields in the response should be expanded.
92
        Expand []*string `form:"expand"`
93
        // The time when the billing credits created by this credit grant will expire. If set to empty, the billing credits will never expire.
94
        ExpiresAt *int64 `form:"expires_at"`
95
        // Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object (ex: cost basis) in a structured format.
96
        Metadata map[string]string `form:"metadata"`
97
        // A descriptive name shown in dashboard.
98
        Name *string `form:"name"`
99
}
100

101
// AddExpand appends a new field to expand.
102
func (p *BillingCreditGrantParams) AddExpand(f string) {
×
103
        p.Expand = append(p.Expand, &f)
×
104
}
×
105

106
// AddMetadata adds a new key-value pair to the Metadata.
107
func (p *BillingCreditGrantParams) AddMetadata(key string, value string) {
×
108
        if p.Metadata == nil {
×
109
                p.Metadata = make(map[string]string)
×
110
        }
×
111

112
        p.Metadata[key] = value
×
113
}
114

115
// Expires a credit grant
116
type BillingCreditGrantExpireParams struct {
117
        Params `form:"*"`
118
        // Specifies which fields in the response should be expanded.
119
        Expand []*string `form:"expand"`
120
}
121

122
// AddExpand appends a new field to expand.
123
func (p *BillingCreditGrantExpireParams) AddExpand(f string) {
×
124
        p.Expand = append(p.Expand, &f)
×
125
}
×
126

127
// Voids a credit grant
128
type BillingCreditGrantVoidGrantParams struct {
129
        Params `form:"*"`
130
        // Specifies which fields in the response should be expanded.
131
        Expand []*string `form:"expand"`
132
}
133

134
// AddExpand appends a new field to expand.
135
func (p *BillingCreditGrantVoidGrantParams) AddExpand(f string) {
×
136
        p.Expand = append(p.Expand, &f)
×
137
}
×
138

139
// The monetary amount.
140
type BillingCreditGrantAmountMonetary struct {
141
        // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
142
        Currency Currency `json:"currency"`
143
        // A positive integer representing the amount.
144
        Value int64 `json:"value"`
145
}
146
type BillingCreditGrantAmount struct {
147
        // The monetary amount.
148
        Monetary *BillingCreditGrantAmountMonetary `json:"monetary"`
149
        // The type of this amount. We currently only support `monetary` billing credits.
150
        Type BillingCreditGrantAmountType `json:"type"`
151
}
152
type BillingCreditGrantApplicabilityConfigScope struct {
153
        // The price type to which credit grants can apply to. We currently only support `metered` price type.
154
        PriceType BillingCreditGrantApplicabilityConfigScopePriceType `json:"price_type"`
155
}
156
type BillingCreditGrantApplicabilityConfig struct {
157
        Scope *BillingCreditGrantApplicabilityConfigScope `json:"scope"`
158
}
159

160
// A credit grant is a resource that records a grant of billing credits to a customer.
161
type BillingCreditGrant struct {
162
        APIResource
163
        Amount              *BillingCreditGrantAmount              `json:"amount"`
164
        ApplicabilityConfig *BillingCreditGrantApplicabilityConfig `json:"applicability_config"`
165
        // The category of this credit grant.
166
        Category BillingCreditGrantCategory `json:"category"`
167
        // Time at which the object was created. Measured in seconds since the Unix epoch.
168
        Created int64 `json:"created"`
169
        // ID of the customer to whom the billing credits are granted.
170
        Customer *Customer `json:"customer"`
171
        // The time when the billing credits become effective i.e when they are eligible to be used.
172
        EffectiveAt int64 `json:"effective_at"`
173
        // The time when the billing credits will expire. If not present, the billing credits will never expire.
174
        ExpiresAt int64 `json:"expires_at"`
175
        // Unique identifier for the object.
176
        ID string `json:"id"`
177
        // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
178
        Livemode bool `json:"livemode"`
179
        // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
180
        Metadata map[string]string `json:"metadata"`
181
        // A descriptive name shown in dashboard.
182
        Name string `json:"name"`
183
        // String representing the object's type. Objects of the same type share the same value.
184
        Object string `json:"object"`
185
        // ID of the test clock this credit grant belongs to.
186
        TestClock *TestHelpersTestClock `json:"test_clock"`
187
        // Time at which the object was last updated. Measured in seconds since the Unix epoch.
188
        Updated int64 `json:"updated"`
189
        // The time when this credit grant was voided. If not present, the credit grant hasn't been voided.
190
        VoidedAt int64 `json:"voided_at"`
191
}
192

193
// BillingCreditGrantList is a list of CreditGrants as retrieved from a list endpoint.
194
type BillingCreditGrantList struct {
195
        APIResource
196
        ListMeta
197
        Data []*BillingCreditGrant `json:"data"`
198
}
199

200
// UnmarshalJSON handles deserialization of a BillingCreditGrant.
201
// This custom unmarshaling is needed because the resulting
202
// property may be an id or the full struct if it was expanded.
UNCOV
203
func (b *BillingCreditGrant) UnmarshalJSON(data []byte) error {
×
UNCOV
204
        if id, ok := ParseID(data); ok {
×
UNCOV
205
                b.ID = id
×
206
                return nil
×
207
        }
×
208

209
        type billingCreditGrant BillingCreditGrant
×
210
        var v billingCreditGrant
×
UNCOV
211
        if err := json.Unmarshal(data, &v); err != nil {
×
212
                return err
×
213
        }
×
214

215
        *b = BillingCreditGrant(v)
×
216
        return nil
×
217
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc