-
Notifications
You must be signed in to change notification settings - Fork 0
/
article.go
executable file
·656 lines (573 loc) · 25 KB
/
article.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package polar
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"time"
"github.com/polarsource/polar-go/internal/apijson"
"github.com/polarsource/polar-go/internal/apiquery"
"github.com/polarsource/polar-go/internal/param"
"github.com/polarsource/polar-go/internal/requestconfig"
"github.com/polarsource/polar-go/option"
)
// ArticleService contains methods and other services that help with interacting
// with the polar API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewArticleService] method instead.
type ArticleService struct {
Options []option.RequestOption
Receivers *ArticleReceiverService
}
// NewArticleService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewArticleService(opts ...option.RequestOption) (r *ArticleService) {
r = &ArticleService{}
r.Options = opts
r.Receivers = NewArticleReceiverService(opts...)
return
}
// Create an article.
func (r *ArticleService) New(ctx context.Context, body ArticleNewParams, opts ...option.RequestOption) (res *Article, err error) {
opts = append(r.Options[:], opts...)
path := "v1/articles/"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get an article by ID.
func (r *ArticleService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *Article, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/articles/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Update an article.
func (r *ArticleService) Update(ctx context.Context, id string, body ArticleUpdateParams, opts ...option.RequestOption) (res *Article, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/articles/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
// List articles.
func (r *ArticleService) List(ctx context.Context, query ArticleListParams, opts ...option.RequestOption) (res *ListResourceArticle, err error) {
opts = append(r.Options[:], opts...)
path := "v1/articles/"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
// Delete an article.
func (r *ArticleService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/articles/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return
}
// Send an article preview by email.
func (r *ArticleService) Preview(ctx context.Context, id string, body ArticlePreviewParams, opts ...option.RequestOption) (res *ArticlePreviewResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/articles/%s/preview", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Send an article by email to all subscribers.
func (r *ArticleService) Send(ctx context.Context, id string, opts ...option.RequestOption) (res *ArticleSendResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/articles/%s/send", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return
}
type Article struct {
ID string `json:"id,required" format:"uuid4"`
Body string `json:"body,required"`
Byline ArticleByline `json:"byline,required"`
IsPinned bool `json:"is_pinned,required"`
IsPreview bool `json:"is_preview,required"`
Organization ArticleOrganization `json:"organization,required"`
OrganizationID string `json:"organization_id,required" format:"uuid4"`
Slug string `json:"slug,required"`
Title string `json:"title,required"`
Visibility ArticleVisibility `json:"visibility,required"`
EmailSentToCount int64 `json:"email_sent_to_count,nullable"`
NotificationsSentAt time.Time `json:"notifications_sent_at,nullable" format:"date-time"`
NotifySubscribers bool `json:"notify_subscribers,nullable"`
OgDescription string `json:"og_description,nullable"`
OgImageURL string `json:"og_image_url,nullable"`
PaidSubscribersOnly bool `json:"paid_subscribers_only,nullable"`
PaidSubscribersOnlyEndsAt time.Time `json:"paid_subscribers_only_ends_at,nullable" format:"date-time"`
PublishedAt time.Time `json:"published_at,nullable" format:"date-time"`
UserID string `json:"user_id,nullable" format:"uuid4"`
JSON articleJSON `json:"-"`
}
// articleJSON contains the JSON metadata for the struct [Article]
type articleJSON struct {
ID apijson.Field
Body apijson.Field
Byline apijson.Field
IsPinned apijson.Field
IsPreview apijson.Field
Organization apijson.Field
OrganizationID apijson.Field
Slug apijson.Field
Title apijson.Field
Visibility apijson.Field
EmailSentToCount apijson.Field
NotificationsSentAt apijson.Field
NotifySubscribers apijson.Field
OgDescription apijson.Field
OgImageURL apijson.Field
PaidSubscribersOnly apijson.Field
PaidSubscribersOnlyEndsAt apijson.Field
PublishedAt apijson.Field
UserID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Article) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleJSON) RawJSON() string {
return r.raw
}
type ArticleByline struct {
Name string `json:"name,required"`
AvatarURL string `json:"avatar_url,nullable"`
JSON articleBylineJSON `json:"-"`
}
// articleBylineJSON contains the JSON metadata for the struct [ArticleByline]
type articleBylineJSON struct {
Name apijson.Field
AvatarURL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ArticleByline) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleBylineJSON) RawJSON() string {
return r.raw
}
type ArticleOrganization struct {
// The organization ID.
ID string `json:"id,required" format:"uuid4"`
// Creation timestamp of the object.
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
// If this organizations accepts donations
DonationsEnabled bool `json:"donations_enabled,required"`
// Settings for the organization features
FeatureSettings ArticleOrganizationFeatureSettings `json:"feature_settings,required,nullable"`
Name string `json:"name,required"`
PledgeBadgeShowAmount bool `json:"pledge_badge_show_amount,required"`
PledgeMinimumAmount int64 `json:"pledge_minimum_amount,required"`
// Settings for the organization profile
ProfileSettings ArticleOrganizationProfileSettings `json:"profile_settings,required,nullable"`
Slug string `json:"slug,required"`
AvatarURL string `json:"avatar_url,nullable"`
Bio string `json:"bio,nullable"`
Blog string `json:"blog,nullable"`
Company string `json:"company,nullable"`
DefaultUpfrontSplitToContributors int64 `json:"default_upfront_split_to_contributors,nullable"`
Email string `json:"email,nullable"`
Location string `json:"location,nullable"`
// Last modification timestamp of the object.
ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"`
TwitterUsername string `json:"twitter_username,nullable"`
JSON articleOrganizationJSON `json:"-"`
}
// articleOrganizationJSON contains the JSON metadata for the struct
// [ArticleOrganization]
type articleOrganizationJSON struct {
ID apijson.Field
CreatedAt apijson.Field
DonationsEnabled apijson.Field
FeatureSettings apijson.Field
Name apijson.Field
PledgeBadgeShowAmount apijson.Field
PledgeMinimumAmount apijson.Field
ProfileSettings apijson.Field
Slug apijson.Field
AvatarURL apijson.Field
Bio apijson.Field
Blog apijson.Field
Company apijson.Field
DefaultUpfrontSplitToContributors apijson.Field
Email apijson.Field
Location apijson.Field
ModifiedAt apijson.Field
TwitterUsername apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ArticleOrganization) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleOrganizationJSON) RawJSON() string {
return r.raw
}
// Settings for the organization features
type ArticleOrganizationFeatureSettings struct {
// If this organization has articles enabled
ArticlesEnabled bool `json:"articles_enabled"`
// If this organization has issue funding enabled
IssueFundingEnabled bool `json:"issue_funding_enabled"`
// If this organization has subscriptions enabled
SubscriptionsEnabled bool `json:"subscriptions_enabled"`
JSON articleOrganizationFeatureSettingsJSON `json:"-"`
}
// articleOrganizationFeatureSettingsJSON contains the JSON metadata for the struct
// [ArticleOrganizationFeatureSettings]
type articleOrganizationFeatureSettingsJSON struct {
ArticlesEnabled apijson.Field
IssueFundingEnabled apijson.Field
SubscriptionsEnabled apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ArticleOrganizationFeatureSettings) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleOrganizationFeatureSettingsJSON) RawJSON() string {
return r.raw
}
// Settings for the organization profile
type ArticleOrganizationProfileSettings struct {
// A description of the organization
Description string `json:"description,nullable"`
// A list of featured organizations
FeaturedOrganizations []string `json:"featured_organizations,nullable" format:"uuid4"`
// A list of featured projects
FeaturedProjects []string `json:"featured_projects,nullable" format:"uuid4"`
// A list of links associated with the organization
Links []string `json:"links,nullable" format:"uri"`
// Subscription promotion settings
Subscribe ArticleOrganizationProfileSettingsSubscribe `json:"subscribe,nullable"`
JSON articleOrganizationProfileSettingsJSON `json:"-"`
}
// articleOrganizationProfileSettingsJSON contains the JSON metadata for the struct
// [ArticleOrganizationProfileSettings]
type articleOrganizationProfileSettingsJSON struct {
Description apijson.Field
FeaturedOrganizations apijson.Field
FeaturedProjects apijson.Field
Links apijson.Field
Subscribe apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ArticleOrganizationProfileSettings) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleOrganizationProfileSettingsJSON) RawJSON() string {
return r.raw
}
// Subscription promotion settings
type ArticleOrganizationProfileSettingsSubscribe struct {
// Include free subscribers in total count
CountFree bool `json:"count_free"`
// Promote email subscription (free)
Promote bool `json:"promote"`
// Show subscription count publicly
ShowCount bool `json:"show_count"`
JSON articleOrganizationProfileSettingsSubscribeJSON `json:"-"`
}
// articleOrganizationProfileSettingsSubscribeJSON contains the JSON metadata for
// the struct [ArticleOrganizationProfileSettingsSubscribe]
type articleOrganizationProfileSettingsSubscribeJSON struct {
CountFree apijson.Field
Promote apijson.Field
ShowCount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ArticleOrganizationProfileSettingsSubscribe) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleOrganizationProfileSettingsSubscribeJSON) RawJSON() string {
return r.raw
}
type ArticleVisibility string
const (
ArticleVisibilityPublic ArticleVisibility = "public"
ArticleVisibilityHidden ArticleVisibility = "hidden"
ArticleVisibilityPrivate ArticleVisibility = "private"
)
func (r ArticleVisibility) IsKnown() bool {
switch r {
case ArticleVisibilityPublic, ArticleVisibilityHidden, ArticleVisibilityPrivate:
return true
}
return false
}
type ArticleReceivers struct {
FreeSubscribers int64 `json:"free_subscribers,required"`
OrganizationMembers int64 `json:"organization_members,required"`
PremiumSubscribers int64 `json:"premium_subscribers,required"`
JSON articleReceiversJSON `json:"-"`
}
// articleReceiversJSON contains the JSON metadata for the struct
// [ArticleReceivers]
type articleReceiversJSON struct {
FreeSubscribers apijson.Field
OrganizationMembers apijson.Field
PremiumSubscribers apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ArticleReceivers) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r articleReceiversJSON) RawJSON() string {
return r.raw
}
type ListResourceArticle struct {
Pagination ListResourceArticlePagination `json:"pagination,required"`
Items []Article `json:"items"`
JSON listResourceArticleJSON `json:"-"`
}
// listResourceArticleJSON contains the JSON metadata for the struct
// [ListResourceArticle]
type listResourceArticleJSON struct {
Pagination apijson.Field
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ListResourceArticle) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r listResourceArticleJSON) RawJSON() string {
return r.raw
}
type ListResourceArticlePagination struct {
MaxPage int64 `json:"max_page,required"`
TotalCount int64 `json:"total_count,required"`
JSON listResourceArticlePaginationJSON `json:"-"`
}
// listResourceArticlePaginationJSON contains the JSON metadata for the struct
// [ListResourceArticlePagination]
type listResourceArticlePaginationJSON struct {
MaxPage apijson.Field
TotalCount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ListResourceArticlePagination) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r listResourceArticlePaginationJSON) RawJSON() string {
return r.raw
}
type ArticlePreviewResponse = interface{}
type ArticleSendResponse = interface{}
type ArticleNewParams struct {
// Title of the article.
Title param.Field[string] `json:"title,required"`
// Body in string format. Either one of body or body_base64 is required.
Body param.Field[string] `json:"body"`
// Body in base64-encoded format. Can be helpful to bypass Web Application
// Firewalls (WAF). Either one of body or body_base64 is required.
BodyBase64 param.Field[string] `json:"body_base64"`
// If the user or organization should be credited in the byline.
Byline param.Field[ArticleNewParamsByline] `json:"byline"`
// If the article should be pinned
IsPinned param.Field[bool] `json:"is_pinned"`
// Set to true to deliver this article via email and/or notifications to
// subscribers.
NotifySubscribers param.Field[bool] `json:"notify_subscribers"`
// Custom og:description value
OgDescription param.Field[string] `json:"og_description"`
// Custom og:image URL value
OgImageURL param.Field[string] `json:"og_image_url" format:"uri"`
// The organization ID.
OrganizationID param.Field[string] `json:"organization_id" format:"uuid4"`
// Set to true to only make this article available for subscribers to a paid
// subscription tier in the organization.
PaidSubscribersOnly param.Field[bool] `json:"paid_subscribers_only"`
// If specified, time at which the article should no longer be restricted to paid
// subscribers. Only relevant if `paid_subscribers_only` is true.
PaidSubscribersOnlyEndsAt param.Field[time.Time] `json:"paid_subscribers_only_ends_at" format:"date-time"`
// Time of publishing. If this date is in the future, the post will be scheduled to
// publish at this time. If visibility is 'public', published_at will default to
// the current time.
PublishedAt param.Field[time.Time] `json:"published_at" format:"date-time"`
// Slug of the article to be used in URLs. If no slug is provided one will be
// generated from the title.
Slug param.Field[string] `json:"slug"`
Visibility param.Field[ArticleNewParamsVisibility] `json:"visibility"`
}
func (r ArticleNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// If the user or organization should be credited in the byline.
type ArticleNewParamsByline string
const (
ArticleNewParamsBylineUser ArticleNewParamsByline = "user"
ArticleNewParamsBylineOrganization ArticleNewParamsByline = "organization"
)
func (r ArticleNewParamsByline) IsKnown() bool {
switch r {
case ArticleNewParamsBylineUser, ArticleNewParamsBylineOrganization:
return true
}
return false
}
type ArticleNewParamsVisibility string
const (
ArticleNewParamsVisibilityPublic ArticleNewParamsVisibility = "public"
ArticleNewParamsVisibilityHidden ArticleNewParamsVisibility = "hidden"
ArticleNewParamsVisibilityPrivate ArticleNewParamsVisibility = "private"
)
func (r ArticleNewParamsVisibility) IsKnown() bool {
switch r {
case ArticleNewParamsVisibilityPublic, ArticleNewParamsVisibilityHidden, ArticleNewParamsVisibilityPrivate:
return true
}
return false
}
type ArticleUpdateParams struct {
// Body in string format. body and body_base64 are mutually exclusive.
Body param.Field[string] `json:"body"`
// Body in base64-encoded format. Can be helpful to bypass Web Application
// Firewalls (WAF). body and body_base64 are mutually exclusive.
BodyBase64 param.Field[string] `json:"body_base64"`
// If the user or organization should be credited in the byline.
Byline param.Field[ArticleUpdateParamsByline] `json:"byline"`
// If the article should be pinned
IsPinned param.Field[bool] `json:"is_pinned"`
// Set to true to deliver this article via email and/or notifications to
// subscribers.
NotifySubscribers param.Field[bool] `json:"notify_subscribers"`
// Custom og:description value
OgDescription param.Field[string] `json:"og_description"`
// Custom og:image URL value
OgImageURL param.Field[string] `json:"og_image_url" format:"uri"`
// Set to true to only make this article available for subscribers to a paid
// subscription tier in the organization.
PaidSubscribersOnly param.Field[bool] `json:"paid_subscribers_only"`
// If specified, time at which the article should no longer be restricted to paid
// subscribers. Only relevant if `paid_subscribers_only` is true.
PaidSubscribersOnlyEndsAt param.Field[time.Time] `json:"paid_subscribers_only_ends_at" format:"date-time"`
// Time of publishing. If this date is in the future, the post will be scheduled to
// publish at this time.
PublishedAt param.Field[time.Time] `json:"published_at" format:"date-time"`
Slug param.Field[string] `json:"slug"`
Title param.Field[string] `json:"title"`
Visibility param.Field[ArticleUpdateParamsVisibility] `json:"visibility"`
}
func (r ArticleUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// If the user or organization should be credited in the byline.
type ArticleUpdateParamsByline string
const (
ArticleUpdateParamsBylineUser ArticleUpdateParamsByline = "user"
ArticleUpdateParamsBylineOrganization ArticleUpdateParamsByline = "organization"
)
func (r ArticleUpdateParamsByline) IsKnown() bool {
switch r {
case ArticleUpdateParamsBylineUser, ArticleUpdateParamsBylineOrganization:
return true
}
return false
}
type ArticleUpdateParamsVisibility string
const (
ArticleUpdateParamsVisibilityPublic ArticleUpdateParamsVisibility = "public"
ArticleUpdateParamsVisibilityHidden ArticleUpdateParamsVisibility = "hidden"
ArticleUpdateParamsVisibilityPrivate ArticleUpdateParamsVisibility = "private"
)
func (r ArticleUpdateParamsVisibility) IsKnown() bool {
switch r {
case ArticleUpdateParamsVisibilityPublic, ArticleUpdateParamsVisibilityHidden, ArticleUpdateParamsVisibilityPrivate:
return true
}
return false
}
type ArticleListParams struct {
// Filter by pinned status.
IsPinned param.Field[bool] `query:"is_pinned"`
// Filter by published status.
IsPublished param.Field[bool] `query:"is_published"`
// Filter by subscription status.
IsSubscribed param.Field[bool] `query:"is_subscribed"`
// Size of a page, defaults to 10. Maximum is 100.
Limit param.Field[int64] `query:"limit"`
// Filter by organization ID.
OrganizationID param.Field[ArticleListParamsOrganizationIDUnion] `query:"organization_id" format:"uuid4"`
// Page number, defaults to 1.
Page param.Field[int64] `query:"page"`
// Filter by slug.
Slug param.Field[string] `query:"slug"`
// Filter by visibility.
Visibility param.Field[ArticleListParamsVisibilityUnion] `query:"visibility"`
}
// URLQuery serializes [ArticleListParams]'s query parameters as `url.Values`.
func (r ArticleListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Filter by organization ID.
//
// Satisfied by [shared.UnionString], [ArticleListParamsOrganizationIDArray].
type ArticleListParamsOrganizationIDUnion interface {
ImplementsArticleListParamsOrganizationIDUnion()
}
type ArticleListParamsOrganizationIDArray []string
func (r ArticleListParamsOrganizationIDArray) ImplementsArticleListParamsOrganizationIDUnion() {}
// Filter by visibility.
//
// Satisfied by [ArticleListParamsVisibilityArticleVisibility],
// [ArticleListParamsVisibilityArray].
type ArticleListParamsVisibilityUnion interface {
implementsArticleListParamsVisibilityUnion()
}
type ArticleListParamsVisibilityArticleVisibility string
const (
ArticleListParamsVisibilityArticleVisibilityPublic ArticleListParamsVisibilityArticleVisibility = "public"
ArticleListParamsVisibilityArticleVisibilityHidden ArticleListParamsVisibilityArticleVisibility = "hidden"
ArticleListParamsVisibilityArticleVisibilityPrivate ArticleListParamsVisibilityArticleVisibility = "private"
)
func (r ArticleListParamsVisibilityArticleVisibility) IsKnown() bool {
switch r {
case ArticleListParamsVisibilityArticleVisibilityPublic, ArticleListParamsVisibilityArticleVisibilityHidden, ArticleListParamsVisibilityArticleVisibilityPrivate:
return true
}
return false
}
func (r ArticleListParamsVisibilityArticleVisibility) implementsArticleListParamsVisibilityUnion() {}
type ArticleListParamsVisibilityArray []ArticleListParamsVisibilityArray
func (r ArticleListParamsVisibilityArray) implementsArticleListParamsVisibilityUnion() {}
type ArticlePreviewParams struct {
// Email address to send the preview to. The user must be registered on Polar.
Email param.Field[string] `json:"email,required" format:"email"`
}
func (r ArticlePreviewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}