-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from Sleitnick/feature/subscriptions
Subscriptions
- Loading branch information
Showing
26 changed files
with
276 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Subscription API | ||
|
||
## Getting Subscription Info | ||
``` | ||
Usage: rbxcloud.exe subscription get [OPTIONS] --universe-id <UNIVERSE_ID> --product <PRODUCT> --subscription <SUBSCRIPTION> --api-key <API_KEY> | ||
Options: | ||
-u, --universe-id <UNIVERSE_ID> Universe ID | ||
-S, --product <PRODUCT> Subscription product ID | ||
-s, --subscription <SUBSCRIPTION> Subscription ID | ||
-v, --view <VIEW> View type [possible values: basic, full] | ||
-p, --pretty Pretty-print the JSON response | ||
-a, --api-key <API_KEY> Roblox Open Cloud API Key [env: RBXCLOUD_API_KEY=] | ||
-h, --help Print help | ||
``` | ||
|
||
### Example | ||
``` | ||
$ rbxcloud subscription get -p -u 12345 -S 1234 -s 5678 -a MY_KEY | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use clap::{Args, Subcommand}; | ||
use rbxcloud::rbx::{ | ||
types::UniverseId, | ||
v2::{subscription::SubscriptionView, Client}, | ||
}; | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum SubscriptionCommands { | ||
/// Get information about a subscription | ||
Get { | ||
/// Universe ID | ||
#[clap(short, long, value_parser)] | ||
universe_id: u64, | ||
|
||
/// Subscription product ID | ||
#[clap(short = 'S', long, value_parser)] | ||
product: String, | ||
|
||
/// Subscription ID | ||
#[clap(short, long, value_parser)] | ||
subscription: String, | ||
|
||
/// View type | ||
#[clap(short, long, value_enum)] | ||
view: Option<SubscriptionView>, | ||
|
||
/// Pretty-print the JSON response | ||
#[clap(short, long, value_parser, default_value_t = false)] | ||
pretty: bool, | ||
|
||
/// Roblox Open Cloud API Key | ||
#[clap(short, long, value_parser, env = "RBXCLOUD_API_KEY")] | ||
api_key: String, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Subscription { | ||
#[clap(subcommand)] | ||
command: SubscriptionCommands, | ||
} | ||
|
||
impl Subscription { | ||
pub async fn run(self) -> anyhow::Result<Option<String>> { | ||
match self.command { | ||
SubscriptionCommands::Get { | ||
universe_id, | ||
product, | ||
subscription, | ||
view, | ||
pretty, | ||
api_key, | ||
} => { | ||
let client = Client::new(&api_key); | ||
let subscription_client = client.subscription(); | ||
let res = subscription_client | ||
.get(UniverseId(universe_id), product, subscription, view) | ||
.await; | ||
match res { | ||
Ok(subscription_info) => { | ||
let r = if pretty { | ||
serde_json::to_string_pretty(&subscription_info)? | ||
} else { | ||
serde_json::to_string(&subscription_info)? | ||
}; | ||
Ok(Some(r)) | ||
} | ||
Err(err) => Err(anyhow::anyhow!(err)), | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// Represents the UniverseId of a Roblox experience. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct UniverseId(pub u64); | ||
|
||
/// Represents the PlaceId of a specific place within a Roblox experience. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct PlaceId(pub u64); | ||
|
||
// Number of items to return. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct ReturnLimit(pub u64); | ||
|
||
/// Represents a Roblox user's ID. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct RobloxUserId(pub u64); | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct PageSize(pub u64); | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct GroupId(pub u64); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.