-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathtypes.go
2516 lines (2077 loc) · 62.6 KB
/
types.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
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package butlerd
import (
"time"
validation "github.com/go-ozzo/ozzo-validation"
itchio "github.com/itchio/go-itchio"
"github.com/itchio/ox"
)
// When using TCP transport, must be the first message sent
//
// @name Meta.Authenticate
// @category Utilities
// @caller client
type MetaAuthenticateParams struct {
Secret string `json:"secret"`
}
func (p MetaAuthenticateParams) Validate() error {
return nil
}
type MetaAuthenticateResult struct {
OK bool `json:"ok"`
}
// When called, defines the entire duration of the daemon's life.
//
// Cancelling that conversation (or closing the TCP connection) will
// shut down the daemon after all other requests have finished. This
// allows gracefully switching to another daemon.
//
// This conversation is also used to send all global notifications,
// regarding data that's fetched, network state, etc.
//
// Note that this call never returns - you have to cancel it when you're
// done with the daemon.
//
// @name Meta.Flow
// @category Utilities
// @caller client
type MetaFlowParams struct {
}
func (p MetaFlowParams) Validate() error {
return nil
}
type MetaFlowResult struct {
}
// When called, gracefully shutdown the butler daemon.
// @name Meta.Shutdown
// @category Utilities
// @caller client
type MetaShutdownParams struct {
}
func (p MetaShutdownParams) Validate() error {
return nil
}
type MetaShutdownResult struct {
}
// The first notification sent when @@MetaFlowParams is called.
//
// @category Utilities
type MetaFlowEstablishedNotification struct {
// The identifier of the daemon process for which the flow was established
PID int64 `json:"pid"`
}
//----------------------------------------------------------------------
// Version
//----------------------------------------------------------------------
// Retrieves the version of the butler instance the client
// is connected to.
//
// This endpoint is meant to gather information when reporting
// issues, rather than feature sniffing. Conforming clients should
// automatically download new versions of butler, see the **Updating** section.
//
// @name Version.Get
// @category Utilities
// @tags Offline
// @caller client
type VersionGetParams struct{}
type VersionGetResult struct {
// Something short, like `v8.0.0`
Version string `json:"version"`
// Something long, like `v8.0.0, built on Aug 27 2017 @ 01:13:55, ref d833cc0aeea81c236c81dffb27bc18b2b8d8b290`
VersionString string `json:"versionString"`
}
func (p VersionGetParams) Validate() error {
return nil
}
// @name Network.SetSimulateOffline
// @category Utilities
// @caller client
type NetworkSetSimulateOfflineParams struct {
// If true, all operations after this point will behave
// as if there were no network connections
Enabled bool `json:"enabled"`
}
func (p NetworkSetSimulateOfflineParams) Validate() error {
return nil
}
type NetworkSetSimulateOfflineResult struct{}
// @name Network.SetBandwidthThrottle
// @category Utilities
// @caller client
type NetworkSetBandwidthThrottleParams struct {
// If true, will limit. If false, will clear any bandwidth throttles in place
Enabled bool `json:"enabled"`
// The target bandwidth, in kbps
Rate int64 `json:"rate"`
}
func (p NetworkSetBandwidthThrottleParams) Validate() error {
return nil
}
type NetworkSetBandwidthThrottleResult struct{}
//----------------------------------------------------------------------
// Profile
//----------------------------------------------------------------------
// Lists remembered profiles
//
// @name Profile.List
// @category Profile
// @caller client
type ProfileListParams struct {
}
func (p ProfileListParams) Validate() error {
return nil
}
type ProfileListResult struct {
// A list of remembered profiles
Profiles []*Profile `json:"profiles"`
}
// Represents a user for which we have profile information,
// ie. that we can connect as, etc.
type Profile struct {
// itch.io user ID, doubling as profile ID
ID int64 `json:"id"`
// Timestamp the user last connected at (to the client)
LastConnected time.Time `json:"lastConnected"`
// User information
User *itchio.User `json:"user"`
}
// Add a new profile by password login
//
// @name Profile.LoginWithPassword
// @category Profile
// @caller client
type ProfileLoginWithPasswordParams struct {
// The username (or e-mail) to use for login
Username string `json:"username"`
// The password to use
Password string `json:"password"`
}
func (p ProfileLoginWithPasswordParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.Username, validation.Required),
validation.Field(&p.Password, validation.Required),
)
}
type ProfileLoginWithPasswordResult struct {
// Information for the new profile, now remembered
Profile *Profile `json:"profile"`
// Profile cookie for website
Cookie map[string]string `json:"cookie"`
}
// Add a new profile by API key login. This can be used
// for integration tests, for example. Note that no cookies
// are returned for this kind of login.
//
// @name Profile.LoginWithAPIKey
// @category Profile
// @caller client
type ProfileLoginWithAPIKeyParams struct {
// The API token to use
APIKey string `json:"apiKey"`
}
func (p ProfileLoginWithAPIKeyParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.APIKey, validation.Required),
)
}
type ProfileLoginWithAPIKeyResult struct {
// Information for the new profile, now remembered
Profile *Profile `json:"profile"`
}
// Ask the user to solve a captcha challenge
// Sent during @@ProfileLoginWithPasswordParams if certain
// conditions are met.
//
// @name Profile.RequestCaptcha
// @category Profile
// @caller server
type ProfileRequestCaptchaParams struct {
// Address of page containing a recaptcha widget
RecaptchaURL string `json:"recaptchaUrl"`
}
func (p ProfileRequestCaptchaParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.RecaptchaURL, validation.Required),
)
}
type ProfileRequestCaptchaResult struct {
// The response given by recaptcha after it's been filled
RecaptchaResponse string `json:"recaptchaResponse"`
}
// Ask the user to provide a TOTP token.
// Sent during @@ProfileLoginWithPasswordParams if the user has
// two-factor authentication enabled.
//
// @name Profile.RequestTOTP
// @category Profile
// @caller server
type ProfileRequestTOTPParams struct {
}
func (p ProfileRequestTOTPParams) Validate() error {
return nil
}
type ProfileRequestTOTPResult struct {
// The TOTP code entered by the user
Code string `json:"code"`
}
// Use saved login credentials to validate a profile.
//
// @name Profile.UseSavedLogin
// @category Profile
// @caller client
type ProfileUseSavedLoginParams struct {
ProfileID int64 `json:"profileId"`
}
func (p ProfileUseSavedLoginParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
)
}
type ProfileUseSavedLoginResult struct {
// Information for the now validated profile
Profile *Profile `json:"profile"`
}
// Forgets a remembered profile - it won't appear in the
// @@ProfileListParams results anymore.
//
// @name Profile.Forget
// @category Profile
// @caller client
type ProfileForgetParams struct {
ProfileID int64 `json:"profileId"`
}
func (p ProfileForgetParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
)
}
type ProfileForgetResult struct {
// True if the profile did exist (and was successfully forgotten)
Success bool `json:"success"`
}
// Stores some data associated to a profile, by key.
//
// @name Profile.Data.Put
// @category Profile
// @caller client
type ProfileDataPutParams struct {
ProfileID int64 `json:"profileId"`
Key string `json:"key"`
Value string `json:"value"`
}
func (p ProfileDataPutParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.Key, validation.Required),
validation.Field(&p.Value, validation.Required),
)
}
type ProfileDataPutResult struct {
}
// Retrieves some data associated to a profile, by key.
//
// @name Profile.Data.Get
// @category Profile
// @caller client
type ProfileDataGetParams struct {
ProfileID int64 `json:"profileId"`
Key string `json:"key"`
}
func (p ProfileDataGetParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.Key, validation.Required),
)
}
type ProfileDataGetResult struct {
// True if the value existed
OK bool `json:"ok"`
Value string `json:"value"`
}
//----------------------------------------------------------------------
// Search
//----------------------------------------------------------------------
// Searches for games.
//
// @name Search.Games
// @category Search
// @caller client
type SearchGamesParams struct {
ProfileID int64 `json:"profileId"`
Query string `json:"query"`
}
func (p SearchGamesParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.Query, validation.Required),
)
}
type SearchGamesResult struct {
Games []*itchio.Game `json:"games"`
}
// Searches for users.
//
// @name Search.Users
// @category Search
// @caller client
type SearchUsersParams struct {
ProfileID int64 `json:"profileId"`
Query string `json:"query"`
}
func (p SearchUsersParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.Query, validation.Required),
)
}
type SearchUsersResult struct {
Users []*itchio.User `json:"users"`
}
//----------------------------------------------------------------------
// Fetch
//----------------------------------------------------------------------
// Fetches information for an itch.io game.
//
// @name Fetch.Game
// @category Fetch
// @caller client
type FetchGameParams struct {
// Identifier of game to look for
GameID int64 `json:"gameId"`
// Force an API request
// @optional
Fresh bool `json:"fresh"`
}
func (p FetchGameParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.GameID, validation.Required),
)
}
func (p FetchGameParams) IsFresh() bool {
return p.Fresh
}
type FetchGameResult struct {
// Game info
Game *itchio.Game `json:"game"`
// Marks that a request should be issued afterwards with 'Fresh' set
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchGameResult) SetStale(stale bool) {
r.Stale = stale
}
// Fetches a download key
//
// @name Fetch.DownloadKey
// @category Fetch
// @caller client
type FetchDownloadKeyParams struct {
DownloadKeyID int64 `json:"downloadKeyId"`
ProfileID int64 `json:"profileId"`
// Force an API request
// @optional
Fresh bool `json:"fresh"`
}
func (p FetchDownloadKeyParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.DownloadKeyID, validation.Required),
validation.Field(&p.ProfileID, validation.Required),
)
}
func (p FetchDownloadKeyParams) IsFresh() bool {
return p.Fresh
}
type FetchDownloadKeyResult struct {
DownloadKey *itchio.DownloadKey `json:"downloadKey"`
// Marks that a request should be issued afterwards with 'Fresh' set
// @optional
Stale bool `json:"stale,omitempty"`
}
// Fetches uploads for an itch.io game
//
// @name Fetch.GameUploads
// @category Fetch
// @caller client
type FetchGameUploadsParams struct {
// Identifier of the game whose uploads we should look for
GameID int64 `json:"gameId"`
// Only returns compatible uploads
OnlyCompatible bool `json:"compatible"`
// Force an API request
// @optional
Fresh bool `json:"fresh"`
}
func (p FetchGameUploadsParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.GameID, validation.Required),
)
}
func (p FetchGameUploadsParams) IsFresh() bool {
return p.Fresh
}
type FetchGameUploadsResult struct {
// List of uploads
Uploads []*itchio.Upload `json:"uploads"`
// Marks that a request should be issued
// afterwards with 'Fresh' set
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchGameUploadsResult) SetStale(stale bool) {
r.Stale = stale
}
// Fetches information for an itch.io user.
//
// @name Fetch.User
// @category Fetch
// @caller client
type FetchUserParams struct {
// Identifier of the user to look for
UserID int64 `json:"userId"`
// Profile to use to look upser
ProfileID int64 `json:"profileId"`
// Force an API request
// @optional
Fresh bool `json:"fresh"`
}
func (p FetchUserParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.UserID, validation.Required),
validation.Field(&p.ProfileID, validation.Required),
)
}
func (p FetchUserParams) IsFresh() bool {
return p.Fresh
}
type FetchUserResult struct {
// User info
User *itchio.User `json:"user"`
// Marks that a request should be issued
// afterwards with 'Fresh' set
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchUserResult) SetStale(stale bool) {
r.Stale = stale
}
// Fetches the best current *locally cached* sale for a given
// game.
//
// @name Fetch.Sale
// @category Fetch
// @caller client
type FetchSaleParams struct {
// Identifier of the game for which to look for a sale
GameID int64 `json:"gameId"`
}
func (p FetchSaleParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.GameID, validation.Required),
)
}
type FetchSaleResult struct {
// @optional
Sale *itchio.Sale `json:"sale"`
}
// Fetch a collection's title, gamesCount, etc.
// but not its games.
//
// @name Fetch.Collection
// @category Fetch
// @caller client
type FetchCollectionParams struct {
// Profile to use to fetch collection
ProfileID int64 `json:"profileId"`
// Collection to fetch
CollectionID int64 `json:"collectionId"`
// Force an API request before replying.
// Usually set after getting 'stale' in the response.
// @optional
Fresh bool `json:"fresh"`
}
func (p FetchCollectionParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.CollectionID, validation.Required),
)
}
func (p FetchCollectionParams) IsFresh() bool {
return p.Fresh
}
type FetchCollectionResult struct {
// Collection info
Collection *itchio.Collection `json:"collection"`
// True if the info was from local DB and
// it should be re-queried using "Fresh"
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchCollectionResult) SetStale(stale bool) {
r.Stale = stale
}
// Fetches information about a collection and the games it
// contains.
//
// @name Fetch.Collection.Games
// @category Fetch
// @caller client
type FetchCollectionGamesParams struct {
// Profile to use to fetch collection
ProfileID int64 `json:"profileId"`
// Identifier of the collection to look for
CollectionID int64 `json:"collectionId"`
// Maximum number of games to return at a time.
// @optional
Limit int64 `json:"limit"`
// When specified only shows game titles that contain this string
// @optional
Search string `json:"search"`
// Criterion to sort by
// @optional
SortBy string `json:"sortBy"`
// Filters
// @optional
Filters CollectionGamesFilters `json:"filters"`
// @optional
Reverse bool `json:"reverse"`
// Used for pagination, if specified
// @optional
Cursor Cursor `json:"cursor"`
// If set, will force fresh data
// @optional
Fresh bool `json:"fresh"`
}
type CollectionGamesFilters struct {
Installed bool `json:"installed"`
Classification itchio.GameClassification `json:"classification"`
}
func (p CollectionGamesFilters) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.Classification, validation.In(GameClassificationList...)),
)
}
func (p FetchCollectionGamesParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.CollectionID, validation.Required),
validation.Field(&p.Filters),
validation.Field(&p.SortBy, validation.In("default", "title")),
)
}
func (p FetchCollectionGamesParams) GetLimit() int64 {
return p.Limit
}
func (p FetchCollectionGamesParams) GetCursor() Cursor {
return p.Cursor
}
func (p FetchCollectionGamesParams) IsFresh() bool {
return p.Fresh
}
type FetchCollectionGamesResult struct {
// Requested games for this collection
Items []*itchio.CollectionGame `json:"items"`
// Use to fetch the next 'page' of results
// @optional
NextCursor Cursor `json:"nextCursor,omitempty"`
// If true, re-issue request with 'Fresh'
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchCollectionGamesResult) SetStale(stale bool) {
r.Stale = stale
}
// Lists collections for a profile. Does not contain
// games.
//
// @name Fetch.ProfileCollections
// @category Fetch
// @caller client
type FetchProfileCollectionsParams struct {
// Profile for which to fetch collections
ProfileID int64 `json:"profileId"`
// Maximum number of collections to return at a time.
// @optional
Limit int64 `json:"limit"`
// When specified only shows collection titles that contain this string
// @optional
Search string `json:"search"`
// Criterion to sort by
// @optional
SortBy string `json:"sortBy"`
// @optional
Reverse bool `json:"reverse"`
// Used for pagination, if specified
// @optional
Cursor Cursor `json:"cursor"`
// If set, will force fresh data
// @optional
Fresh bool `json:"fresh"`
}
func (p FetchProfileCollectionsParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.SortBy, validation.In("updatedAt", "title")),
)
}
func (p FetchProfileCollectionsParams) GetCursor() Cursor {
return p.Cursor
}
func (p FetchProfileCollectionsParams) GetLimit() int64 {
return p.Limit
}
func (p FetchProfileCollectionsParams) IsFresh() bool {
return p.Fresh
}
type FetchProfileCollectionsResult struct {
// Collections belonging to the profile
Items []*itchio.Collection `json:"items"`
// Used to fetch the next page
// @optional
NextCursor Cursor `json:"nextCursor,omitempty"`
// If true, re-issue request with "Fresh"
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchProfileCollectionsResult) SetStale(stale bool) {
r.Stale = stale
}
// @name Fetch.ProfileGames
// @category Fetch
// @caller client
type FetchProfileGamesParams struct {
// Profile for which to fetch games
ProfileID int64 `json:"profileId"`
// Maximum number of items to return at a time.
// @optional
Limit int64 `json:"limit"`
// When specified only shows game titles that contain this string
// @optional
Search string `json:"search"`
// Criterion to sort by
// @optional
SortBy string `json:"sortBy"`
// Filters
// @optional
Filters ProfileGameFilters `json:"filters"`
// @optional
Reverse bool `json:"reverse"`
// Used for pagination, if specified
// @optional
Cursor Cursor `json:"cursor"`
// If set, will force fresh data
// @optional
Fresh bool `json:"fresh"`
}
type ProfileGameFilters struct {
Visibility string `json:"visibility"`
PaidStatus string `json:"paidStatus"`
}
func (p ProfileGameFilters) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.Visibility, validation.In("draft", "published")),
validation.Field(&p.PaidStatus, validation.In("paid", "free")),
)
}
func (p FetchProfileGamesParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.SortBy, validation.In("default", "title", "views", "downloads", "purchases")),
validation.Field(&p.Filters),
)
}
func (p FetchProfileGamesParams) GetCursor() Cursor {
return p.Cursor
}
func (p FetchProfileGamesParams) GetLimit() int64 {
return p.Limit
}
func (p FetchProfileGamesParams) IsFresh() bool {
return p.Fresh
}
type ProfileGame struct {
Game *itchio.Game `json:"game"`
ViewsCount int64 `json:"viewsCount"`
DownloadsCount int64 `json:"downloadsCount"`
PurchasesCount int64 `json:"purchasesCount"`
Published bool `json:"published"`
}
type FetchProfileGamesResult struct {
// Profile games
Items []*ProfileGame `json:"items"`
// Used to fetch the next page
// @optional
NextCursor Cursor `json:"nextCursor,omitempty"`
// If true, re-issue request with "Fresh"
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchProfileGamesResult) SetStale(stale bool) {
r.Stale = stale
}
// @name Fetch.ProfileOwnedKeys
// @category Fetch
// @caller client
type FetchProfileOwnedKeysParams struct {
// Profile to use to fetch game
ProfileID int64 `json:"profileId"`
// Maximum number of collections to return at a time.
// @optional
Limit int64 `json:"limit"`
// When specified only shows game titles that contain this string
// @optional
Search string `json:"search"`
// Criterion to sort by
// @optional
SortBy string `json:"sortBy"`
// Filters
// @optional
Filters ProfileOwnedKeysFilters `json:"filters"`
// @optional
Reverse bool `json:"reverse"`
// Used for pagination, if specified
// @optional
Cursor Cursor `json:"cursor"`
// If set, will force fresh data
// @optional
Fresh bool `json:"fresh"`
}
type ProfileOwnedKeysFilters struct {
Installed bool `json:"installed"`
Classification itchio.GameClassification `json:"classification"`
}
func (p ProfileOwnedKeysFilters) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.Classification, validation.In(GameClassificationList...)),
)
}
func (p FetchProfileOwnedKeysParams) Validate() error {
return validation.ValidateStruct(&p,
validation.Field(&p.ProfileID, validation.Required),
validation.Field(&p.Filters),
validation.Field(&p.SortBy, validation.In("acquiredAt", "title")),
)
}
func (p FetchProfileOwnedKeysParams) IsFresh() bool {
return p.Fresh
}
func (p FetchProfileOwnedKeysParams) GetCursor() Cursor {
return p.Cursor
}
func (p FetchProfileOwnedKeysParams) GetLimit() int64 {
return p.Limit
}
type FetchProfileOwnedKeysResult struct {
// Download keys fetched for profile
Items []*itchio.DownloadKey `json:"items"`
// Used to fetch the next page
// @optional
NextCursor Cursor `json:"nextCursor,omitempty"`
// If true, re-issue request with "Fresh"
// @optional
Stale bool `json:"stale,omitempty"`
}
func (r *FetchProfileOwnedKeysResult) SetStale(stale bool) {
r.Stale = stale
}
// @name Fetch.Commons
// @category Fetch
// @caller client
type FetchCommonsParams struct{}
func (p FetchCommonsParams) Validate() error {
return nil
}
type FetchCommonsResult struct {
DownloadKeys []*DownloadKeySummary `json:"downloadKeys"`
Caves []*CaveSummary `json:"caves"`
InstallLocations []*InstallLocationSummary `json:"installLocations"`
}
type DownloadKeySummary struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Identifier of the game to which this download key grants access
GameID int64 `json:"gameId"`
// Date this key was created at (often coincides with purchase time)
CreatedAt *time.Time `json:"createdAt"`
}
type CaveSummary struct {
ID string `json:"id"`
GameID int64 `json:"gameId"`
LastTouchedAt *time.Time `json:"lastTouchedAt"`
SecondsRun int64 `json:"secondsRun"`
InstalledSize int64 `json:"installedSize"`
}
type Cave struct {
ID string `json:"id"`
Game *itchio.Game `json:"game"`
Upload *itchio.Upload `json:"upload"`
Build *itchio.Build `json:"build"`
Stats *CaveStats `json:"stats"`