Skip to content

Commit 4519038

Browse files
authored
Merge branch 'main' into v1.6629.0
2 parents f68127f + 7c8eeee commit 4519038

File tree

4 files changed

+87
-50
lines changed

4 files changed

+87
-50
lines changed

packages_generated/billing/src/v2beta1/api.gen.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import {
88
validatePathParam,
99
} from '@scaleway/sdk-client'
1010
import {
11+
unmarshalDiscount,
1112
unmarshalInvoice,
1213
unmarshalListConsumptionsResponse,
1314
unmarshalListDiscountsResponse,
1415
unmarshalListInvoicesResponse,
1516
unmarshalListTaxesResponse,
1617
} from './marshalling.gen'
1718
import type {
19+
Discount,
1820
DownloadInvoiceRequest,
1921
ExportInvoicesRequest,
2022
GetInvoiceRequest,
@@ -27,6 +29,7 @@ import type {
2729
ListInvoicesResponse,
2830
ListTaxesRequest,
2931
ListTaxesResponse,
32+
RedeemCouponRequest,
3033
} from './types.gen'
3134

3235
/**
@@ -227,4 +230,27 @@ export class API extends ParentAPI {
227230
*/
228231
listDiscounts = (request: Readonly<ListDiscountsRequest> = {}) =>
229232
enrichForPagination('discounts', this.pageOfListDiscounts, request)
233+
234+
/**
235+
* Redeem coupon. Redeem a coupon given the related code.
236+
*
237+
* @param request - The request {@link RedeemCouponRequest}
238+
* @returns A Promise of Discount
239+
*/
240+
redeemCoupon = (request: Readonly<RedeemCouponRequest>) =>
241+
this.client.fetch<Discount>(
242+
{
243+
method: 'POST',
244+
path: `/billing/v2beta1/redeem-coupon`,
245+
urlParams: urlParams(
246+
['code', request.code],
247+
[
248+
'organization_id',
249+
request.organizationId ??
250+
this.client.settings.defaultOrganizationId,
251+
],
252+
),
253+
},
254+
unmarshalDiscount,
255+
)
230256
}

packages_generated/billing/src/v2beta1/marshalling.gen.ts

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,55 @@ import type {
1919
ListTaxesResponseTax,
2020
} from './types.gen'
2121

22+
const unmarshalDiscountCoupon = (data: unknown): DiscountCoupon => {
23+
if (!isJSONObject(data)) {
24+
throw new TypeError(
25+
`Unmarshalling the type 'DiscountCoupon' failed as data isn't a dictionary.`,
26+
)
27+
}
28+
29+
return {
30+
description: data.description,
31+
} as DiscountCoupon
32+
}
33+
34+
const unmarshalDiscountFilter = (data: unknown): DiscountFilter => {
35+
if (!isJSONObject(data)) {
36+
throw new TypeError(
37+
`Unmarshalling the type 'DiscountFilter' failed as data isn't a dictionary.`,
38+
)
39+
}
40+
41+
return {
42+
exclude: data.exclude,
43+
type: data.type,
44+
value: data.value,
45+
} as DiscountFilter
46+
}
47+
48+
export const unmarshalDiscount = (data: unknown): Discount => {
49+
if (!isJSONObject(data)) {
50+
throw new TypeError(
51+
`Unmarshalling the type 'Discount' failed as data isn't a dictionary.`,
52+
)
53+
}
54+
55+
return {
56+
coupon: data.coupon ? unmarshalDiscountCoupon(data.coupon) : undefined,
57+
creationDate: unmarshalDate(data.creation_date),
58+
description: data.description,
59+
filters: unmarshalArrayOfObject(data.filters, unmarshalDiscountFilter),
60+
id: data.id,
61+
mode: data.mode,
62+
organizationId: data.organization_id,
63+
startDate: unmarshalDate(data.start_date),
64+
stopDate: unmarshalDate(data.stop_date),
65+
value: data.value,
66+
valueRemaining: data.value_remaining,
67+
valueUsed: data.value_used,
68+
} as Discount
69+
}
70+
2271
export const unmarshalInvoice = (data: unknown): Invoice => {
2372
if (!isJSONObject(data)) {
2473
throw new TypeError(
@@ -94,55 +143,6 @@ export const unmarshalListConsumptionsResponse = (
94143
} as ListConsumptionsResponse
95144
}
96145

97-
const unmarshalDiscountCoupon = (data: unknown): DiscountCoupon => {
98-
if (!isJSONObject(data)) {
99-
throw new TypeError(
100-
`Unmarshalling the type 'DiscountCoupon' failed as data isn't a dictionary.`,
101-
)
102-
}
103-
104-
return {
105-
description: data.description,
106-
} as DiscountCoupon
107-
}
108-
109-
const unmarshalDiscountFilter = (data: unknown): DiscountFilter => {
110-
if (!isJSONObject(data)) {
111-
throw new TypeError(
112-
`Unmarshalling the type 'DiscountFilter' failed as data isn't a dictionary.`,
113-
)
114-
}
115-
116-
return {
117-
exclude: data.exclude,
118-
type: data.type,
119-
value: data.value,
120-
} as DiscountFilter
121-
}
122-
123-
const unmarshalDiscount = (data: unknown): Discount => {
124-
if (!isJSONObject(data)) {
125-
throw new TypeError(
126-
`Unmarshalling the type 'Discount' failed as data isn't a dictionary.`,
127-
)
128-
}
129-
130-
return {
131-
coupon: data.coupon ? unmarshalDiscountCoupon(data.coupon) : undefined,
132-
creationDate: unmarshalDate(data.creation_date),
133-
description: data.description,
134-
filters: unmarshalArrayOfObject(data.filters, unmarshalDiscountFilter),
135-
id: data.id,
136-
mode: data.mode,
137-
organizationId: data.organization_id,
138-
startDate: unmarshalDate(data.start_date),
139-
stopDate: unmarshalDate(data.stop_date),
140-
value: data.value,
141-
valueRemaining: data.value_remaining,
142-
valueUsed: data.value_used,
143-
} as Discount
144-
}
145-
146146
export const unmarshalListDiscountsResponse = (
147147
data: unknown,
148148
): ListDiscountsResponse => {

packages_generated/billing/src/v2beta1/types.gen.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,3 +480,14 @@ export interface ListTaxesResponse {
480480
*/
481481
updatedAt?: Date
482482
}
483+
484+
export type RedeemCouponRequest = {
485+
/**
486+
* The Organization ID of the discount.
487+
*/
488+
organizationId?: string
489+
/**
490+
* The code of the coupon to redeem.
491+
*/
492+
code: string
493+
}

packages_generated/iam/src/v1alpha1/validation-rules.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export const ListUsersRequest = {
226226

227227
export const RuleSpecs = {
228228
condition: {
229-
maxLength: 1024,
229+
maxLength: 2048,
230230
},
231231
}
232232

0 commit comments

Comments
 (0)