Skip to content

Commit 98e3c64

Browse files
committed
some new endpoints (wip)
1 parent 264f73c commit 98e3c64

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

dimscord/restapi/guild.nim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ proc createScheduledEvent*(api: RestApi; guild_id: string;
813813
privacy_level: GuildScheduledEventPrivacyLevel;
814814
entity_type: EntityType;
815815
entity_metadata = none EntityMetadata;
816+
recurrence_rule = none RecurrenceRule;
816817
reason = ""
817818
): Future[GuildScheduledEvent] {.async.} =
818819
## Create a scheduled event in a guild.
@@ -831,6 +832,9 @@ proc createScheduledEvent*(api: RestApi; guild_id: string;
831832
payload["entity_metadata"] = %*{
832833
"location": entity_metadata.get.location.get
833834
}
835+
if recurrence_rule.isSome:
836+
payload["recurrence_rule"] = %recurrence_rule.get
837+
834838
result = (await api.request(
835839
"POST",
836840
endpointGuildScheduledEvents(guild_id),
@@ -845,6 +849,7 @@ proc editScheduledEvent*(api: RestApi; guild_id, event_id: string;
845849
entity_type = none EntityType;
846850
entity_metadata = none EntityMetadata;
847851
status = none GuildScheduledEventStatus;
852+
recurrence_rule = none RecurrenceRule;
848853
reason = ""
849854
): Future[GuildScheduledEvent] {.async.} =
850855
## Update a scheduled event in a guild.
@@ -855,7 +860,7 @@ proc editScheduledEvent*(api: RestApi; guild_id, event_id: string;
855860
let payload = newJObject()
856861
payload.loadNullableOptStr(channel_id, image)
857862
payload.loadOpt(scheduled_end_time, scheduled_start_time,
858-
description, entity_type, status, privacy_level)
863+
description, entity_type, status, privacy_level, recurrence_rule)
859864

860865
if entity_type.isSome and entity_type.get == etExternal:
861866
assert channel_id.get == ""

dimscord/restapi/user.nim

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,26 @@ proc listSKUs*(api:RestApi, application_id:string): Future[seq[Sku]] {.async.} =
589589
result = (await api.request(
590590
"GET",
591591
endpointListSkus(application_id)
592-
)).getElems.mapIt(it.`$`.fromJson(Sku))
592+
)).getElems.mapIt(it.`$`.fromJson(Sku))
593+
594+
proc listSkuSubscriptions*(api:RestApi, sku_id:string;
595+
before, after, user_id = none(string);
596+
limit = 50
597+
): Future[seq[Subscription]] {.async.} =
598+
## Lists out SKUs for a given application.
599+
var endpoint = endpointSkuSubscriptions(sku_id) & "?limit=" & $limit
600+
if before.isSome: endpoint &= "&before=" & before.get
601+
if after.isSome: endpoint &= "&after=" & after.get
602+
if user_id.isSome: endpoint &= "&user_id=" & user_id.get
603+
result = (await api.request(
604+
"GET",
605+
endpoint
606+
)).getElems.mapIt(it.`$`.fromJson(Subscription))
607+
608+
proc getSkuSubscription*(api:RestApi;
609+
sku_id, subscription_id: string): Future[Subscription] {.async.} =
610+
## Lists out SKUs for a given application.
611+
result = (await api.request(
612+
"GET",
613+
endpointSkuSubscriptions(sku_id, subscription_id)
614+
)).`$`.fromJson(Subscription)

0 commit comments

Comments
 (0)