GS2-Exchange SDK API Reference
Model
Namespace
Namespace
A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.
Therefore, you must create a namespace before you can start using each service.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceId | string | * | ~ 1024 chars | Namespace GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| enableDirectExchange | bool | true | Allow direct exchange API calls When enabled, clients can call the exchange API directly to perform resource exchanges. When disabled, exchanges can only be triggered via transaction actions (transactions), providing tighter server-side control over when exchanges occur. | |||
| enableAwaitExchange | bool | false | Whether to enable exchanges that require a waiting time before receiving results When enabled, exchange rate models with await timing type can be used. These exchanges require real-time to elapse before rewards can be claimed, enabling crafting or production mechanics where players must wait for the result. | |||
| transactionSetting | TransactionSetting | ✓ | Transaction Setting Configuration for controlling how distributed transactions are executed when processing exchange operations. Supports auto-run, atomic commit, and async processing options. | |||
| exchangeScript | ScriptSetting | Script to run when an attempt is made to perform an exchange Script Trigger Reference - exchange | ||||
| incrementalExchangeScript | ScriptSetting | Script to run when an attempt is made to perform an incremental exchange Script Trigger Reference - incrementalExchange | ||||
| acquireAwaitScript | ScriptSetting | Script setting executed when the waiting period completes and the reward is about to be acquired in an await-type exchange Script Trigger Reference - acquireAwait | ||||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of exchange operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for exchange, incremental exchange, and await operations can be collected. | ||||
| createdAt | long | * | Now | Datetime of creation Unix time, milliseconds * Set automatically by the server | ||
| updatedAt | long | * | Now | Datetime of last update Unix time, milliseconds * Set automatically by the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
TransactionSetting
Transaction Setting
Transaction Setting controls how transactions are executed, including their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | false | Whether to automatically execute issued transactions on the server side | |||
| enableAtomicCommit | bool | {enableAutoRun} == true | false | Whether to commit the execution of transactions atomically * Applicable only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Applicable only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Applicable only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Applicable only if enableAtomicCommit is true | ||
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| queueNamespaceId | string | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | GS2-JobQueue Namespace GRN used to execute transactions |
ScriptSetting
Script Setting
In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.
There are two main ways to execute a script: synchronous execution and asynchronous execution. Because synchronous execution blocks processing until the script finishes executing, you can use the script result to stop the API execution or control the API response.
In contrast, asynchronous execution does not block processing until the script has finished executing. However, because the script result cannot be used to stop the API execution or modify the API response, Because asynchronous execution does not affect the API response flow, it is generally recommended.
There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| triggerScriptId | string | ~ 1024 chars | GS2-Script script GRN
executed synchronously when the API is executed Must be specified in GRN format starting with “grn:gs2:”. | |||||||||||
| doneTriggerTargetType | String Enum enum { “none”, “gs2_script”, “aws” } | “none” | How to execute asynchronous scripts Specifies the type of script to use for asynchronous execution. You can choose from “Do not use asynchronous execution (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
| |||||||||||
| doneTriggerScriptId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-Script script GRN
for asynchronous execution Must be specified in GRN format starting with “grn:gs2:”. * Applicable only if doneTriggerTargetType is “gs2_script” | ||||||||||
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-JobQueue namespace GRN
to execute asynchronous execution scripts If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue namespace GRN. There are not many cases where GS2-JobQueue is required, so you generally do not need to specify it unless you have a specific reason. * Applicable only if doneTriggerTargetType is “gs2_script” |
LogSetting
Log Output Setting
Log Output Setting defines how log data is exported. This type holds the GS2-Log namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log namespace GRN
to output logs Must be specified in GRN format starting with “grn:gs2:”. |
GitHubCheckoutSetting
Setup to check out master data from GitHub
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| apiKeyId | string | ✓ | ~ 1024 chars | GitHub API Key GRN | ||||||||||
| repositoryName | string | ✓ | ~ 1024 chars | Repository Name | ||||||||||
| sourcePath | string | ✓ | ~ 1024 chars | Master data (JSON) file path | ||||||||||
| referenceType | String Enum enum { “commit_hash”, “branch”, “tag” } | ✓ | Source of code
| |||||||||||
| commitHash | string | {referenceType} == “commit_hash” | ✓* | ~ 1024 chars | Commit hash * Required if referenceType is “commit_hash” | |||||||||
| branchName | string | {referenceType} == “branch” | ✓* | ~ 1024 chars | Branch Name * Required if referenceType is “branch” | |||||||||
| tagName | string | {referenceType} == “tag” | ✓* | ~ 1024 chars | Tag Name * Required if referenceType is “tag” |
Await
Exchange Await
Represents the execution state of an exchange that requires real-time to elapse before rewards can be claimed. Created when a player initiates an exchange with await timing type, and tracks the waiting period until the rewards become available. Supports skip functionality to shorten or eliminate the waiting time, and stores default configuration values for reward acquisition.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| awaitId | string | * | ~ 1024 chars | Exchange Await GRN * Set automatically by the server | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| name | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |
| count | int | 1 | 1 ~ 10000 | Number of exchanges The number of times this exchange should be performed. Multiple exchanges can be batched into a single await, multiplying both the cost consumed and the rewards received. | ||
| skipSeconds | int | 0 | 0 ~ 2147483646 | Skip seconds The number of seconds to subtract from the waiting time. When skip seconds are applied, the acquirableAt timestamp is moved earlier by this amount. Used to implement mechanics where players can pay resources to speed up the waiting process. | ||
| config | List<Config> | [] | 0 ~ 32 items | Default configuration values applied when obtaining rewards Key-value pairs used as transaction placeholder variables when the await completes and rewards are distributed. These values are set at the time of exchange initiation and applied to the acquire actions’ transaction parameters. | ||
| acquirableAt | long | Time when rewards can be received The timestamp at which the waiting period expires and rewards become claimable. Calculated as exchangedAt + lockTime - skipSeconds. The player can call the acquire API once the current time has passed this timestamp. | ||||
| exchangedAt | long | Exchange time The timestamp when the exchange was initiated and the await was created. Used as the base time for calculating when rewards become available (acquirableAt = exchangedAt + lockTime - skipSeconds). | ||||
| createdAt | long | * | Now | Datetime of creation Unix time, milliseconds * Set automatically by the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
RateModel
Exchange Rate Model
Exchange Rate Model is an entity that defines the rate used to exchange one resource for another.
In addition to the rate at which a resource can be exchanged immediately, a rate can also be set at which a resource can be exchanged after a certain amount of time in real time has elapsed. Exchange rates that after a certain period of real time has elapsed can further define the resources required to perform an immediate exchange.
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| rateModelId | string | * | ~ 1024 chars | Exchange Rate Model GRN * Set automatically by the server | ||||||||
| name | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||
| verifyActions | List<VerifyAction> | [] | 0 ~ 10 items | List of Verify Actions Precondition checks that must all pass before the exchange is executed. If any verify action fails, the exchange is aborted without consuming resources. Used to enforce conditions such as level requirements or inventory capacity. | ||||||||
| consumeActions | List<ConsumeAction> | [] | 0 ~ 10 items | List of Consume Actions Defines the resources (cost) that the player must pay to perform this exchange. Multiple consume actions can be specified, allowing complex exchange costs such as requiring both gold and items. These actions are executed as consume actions within a distributed transaction. | ||||||||
| timingType | String Enum enum { “immediate”, “await” } | “immediate” | Type of exchange Determines when rewards are delivered after performing the exchange. immediate delivers rewards instantly upon exchange execution. await requires real-time to elapse before rewards can be claimed, creating a waiting period (e.g., crafting time).
| |||||||||
| lockTime | int | {timingType} == “await” | ✓* | 0 ~ 538214400 | Waiting time (minutes) from the execution of the exchange until the reward is actually received Only applicable when timingType is await. Specifies the number of minutes that must elapse in real time after the exchange is initiated before the player can claim the rewards. The waiting time can be shortened by using the skip mechanism.* Required if timingType is “await” | |||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the exchange. Multiple acquire actions can be specified to grant various resource types simultaneously. These actions are executed as acquire actions within a distributed transaction. |
IncrementalRateModel
Incremental Cost Exchange Rate Model
Normal exchange rates always provide exchanges at a constant rate. With incremental exchange rates, you can define a rate that increases in cost as the number of exchanges increases. For example, the first exchange is performed at a rate of 1:1, but the second exchange is performed at a rate of 2:1. By defining such a rate, you can increase the value of the resources obtained by the player as the game progresses.
The number of exchanges can be reset after a certain period of real time has elapsed. This is useful for resetting the number of exchanges on a daily or weekly basis.
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| incrementalRateModelId | string | * | ~ 1024 chars | Incremental Cost Exchange Rate Model GRN * Set automatically by the server | ||||||||||
| name | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||||
| consumeAction | ConsumeAction | ✓ | Consume Action (Quantity and Value are overwritten automatically) Defines the type of resource consumed as cost for the exchange. The actual quantity is calculated dynamically based on the exchange count and the calculation type (linear, power, or script). Only the action type and target resource need to be specified; the quantity field is overwritten automatically. | |||||||||||
| calculateType | String Enum enum { “linear”, “power”, “gs2_script” } | ✓ | Calculation method for cost increase amount Determines how the exchange cost escalates with each exchange. linear calculates cost as baseValue + (coefficientValue * exchangeCount). power calculates cost as coefficientValue * (exchangeCount + 1)^2. gs2_script delegates the calculation to a custom GS2-Script for arbitrary logic.
| |||||||||||
| baseValue | long | {calculateType} == “linear” | ✓* | 0 ~ 9223372036854775805 | Base Value The initial cost for the first exchange when using the linear calculation type. The total cost is calculated as: baseValue + (coefficientValue * exchangeCount).* Required if calculateType is “linear” | |||||||||
| coefficientValue | long | {calculateType} in [“linear”, “power”] | ✓* | 0 ~ 9223372036854775805 | Coefficient Value The multiplier that controls how quickly costs escalate with each exchange. In linear mode, each exchange adds this value to the cost. In power mode, the cost is calculated as: coefficientValue * (exchangeCount + 1)^2.* Required if calculateType is “linear”,“power” | |||||||||
| calculateScriptId | string | {calculateType} == “gs2_script” | ✓* | ~ 1024 chars | GRN
of cost calculation script Script Trigger Reference - calculateCost* Required if calculateType is “gs2_script” | |||||||||
| exchangeCountId | string | ✓ | ~ 1024 chars | GS2-Limit Usage Limit Model GRN
for managing exchange execution counts References a GS2-Limit limit model that tracks how many times each user has performed this incremental exchange. The count is used to calculate the escalating cost and can be reset periodically (e.g., daily or weekly) using GS2-Limit’s reset timing. | ||||||||||
| maximumExchangeCount | int | 2147483646 | 0 ~ 2147483646 | Maximum number of exchanges The maximum number of times this incremental exchange can be performed by a user. Once the exchange count reaches this limit, further exchanges are denied until the count is reset via GS2-Limit. | ||||||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the incremental exchange. The rewards remain constant regardless of the exchange count; only the cost increases with each exchange. |
LogCost
Cost Calculation Result Using Logarithm
Represents a cost value computed using logarithmic arithmetic. The final cost is calculated by summing logarithmic values in the adds list and subtracting those in the subs list, then converting back from logarithmic form using the specified base. Used for precise large-number cost calculations that avoid overflow.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| base | double | ✓ | 0 ~ 10 | Base The logarithmic base used for the cost calculation. All logarithmic values in the adds and subs lists use this base. Common values include 2, e (approximately 2.718), or 10. | ||
| adds | List<double> | ✓ | 1 ~ 10000 items | List of logs to be added Logarithmic values that contribute positively to the final cost. These values are summed in logarithmic form before being converted back to the actual cost value. Equivalent to multiplying the corresponding real values together. | ||
| subs | List<double> | 0 ~ 10000 items | List of logs to be subtracted Logarithmic values that reduce the final cost. These values are subtracted in logarithmic form, which is equivalent to dividing the corresponding real values from the product of the adds list. |
LogRate
Logarithmic Acquisition Correction
Represents a reward quantity correction computed using logarithmic arithmetic. The correction factor is calculated by summing the logarithmic values in the logs list and converting back using the specified base. Used to apply multipliers to acquisition amounts using precise large-number arithmetic.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| base | double | ✓ | 0 ~ 10 | Base The logarithmic base used for the acquisition correction calculation. All logarithmic values in the logs list use this base. | ||
| logs | List<double> | ✓ | 1 ~ 10000 items | List of logs Logarithmic values that are summed to compute the acquisition correction factor. The sum is converted back from logarithmic form to produce the final multiplier applied to the reward quantity. |
AcquireAction
Acquire Action
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| action | String Enum enum { } | ✓ | Type of action to be executed in the Acquire Action | |||
| request | string | ✓ | ~ 524288 chars | JSON string of the request used when executing the action |
ConsumeAction
Consume Action
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| action | String Enum enum { } | ✓ | Type of action to be executed in the Consume Action | |||
| request | string | ✓ | ~ 524288 chars | JSON string of the request used when executing the action |
VerifyAction
Verify Action
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| action | String Enum enum { } | ✓ | Type of action to be executed in the Verify Action | |||
| request | string | ✓ | ~ 524288 chars | JSON string of the request used when executing the action |
Config
Configuration
Set values to be applied to transaction variables
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| key | string | ✓ | ~ 64 chars | Name | ||
| value | string | ~ 51200 chars | Value |
VerifyActionResult
Verify Action execution result
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| action | String Enum enum { } | ✓ | Type of action to be executed in the Verify Action | |||
| verifyRequest | string | ✓ | ~ 524288 chars | JSON string of the request used when executing the action | ||
| statusCode | int | 0 ~ 999 | Status code | |||
| verifyResult | string | ~ 1048576 chars | Result payload |
ConsumeActionResult
Consume Action execution result
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| action | String Enum enum { } | ✓ | Type of action to be executed in the Consume Action | |||
| consumeRequest | string | ✓ | ~ 524288 chars | JSON string of the request used when executing the action | ||
| statusCode | int | 0 ~ 999 | Status code | |||
| consumeResult | string | ~ 1048576 chars | Result payload |
AcquireActionResult
Acquire Action execution result
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| action | String Enum enum { } | ✓ | Type of action to be executed in the Acquire Action | |||
| acquireRequest | string | ✓ | ~ 524288 chars | JSON string of the request used when executing the action | ||
| statusCode | int | 0 ~ 999 | Status code | |||
| acquireResult | string | ~ 1048576 chars | Result payload |
TransactionResult
Transaction execution results
Result of a transaction executed using the server-side automatic transaction execution feature
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| transactionId | string | ✓ | 36 ~ 36 chars | Transaction ID | ||
| verifyResults | List<VerifyActionResult> | 0 ~ 10 items | List of verify action execution results | |||
| consumeResults | List<ConsumeActionResult> | [] | 0 ~ 10 items | List of Consume Action execution results | ||
| acquireResults | List<AcquireActionResult> | [] | 0 ~ 100 items | List of Acquire Action execution results | ||
| hasError | bool | false | Whether an error occurred during transaction execution |
CurrentRateMaster
Currently active Rate Model master data
This master data describes the definitions of Rate Models currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data settings are updated on the server.
To create JSON files, GS2 provides a master data editor within the management console. Additionally, you can create tools better suited for game operations and export JSON files in the appropriate format.
Note
Please refer to GS2-Exchange Master Data Reference for the JSON file format.Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceId | string | * | ~ 1024 chars | Namespace GRN * Set automatically by the server | ||
| settings | string | ✓ | ~ 5242880 bytes (5MB) | Master Data |
RateModelMaster
Exchange Rate Model Master
Exchange Rate Model Master is data used to edit and manage exchange rate model within the game. It is temporarily stored in the Management Console’s Master Data Editor. By performing import and update processes, it is reflected as exchange rate model actually referenced by the game.
Exchange Rate Model is an entity that defines the rate used to exchange one resource for another.
In addition to rates that can be exchanged immediately, rates can also be set that can be exchanged after a certain amount of time in real time. Exchange rates that after a certain period of real time has elapsed can further define the resources required to perform an immediate exchange.
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| rateModelId | string | * | ~ 1024 chars | Exchange Rate Model Master GRN * Set automatically by the server | ||||||||
| name | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| description | string | ~ 1024 chars | Description | |||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||
| verifyActions | List<VerifyAction> | [] | 0 ~ 10 items | List of Verify Actions Precondition checks that must all pass before the exchange is executed. If any verify action fails, the exchange is aborted without consuming resources. Used to enforce conditions such as level requirements or inventory capacity. | ||||||||
| consumeActions | List<ConsumeAction> | [] | 0 ~ 10 items | List of Consume Actions Defines the resources (cost) that the player must pay to perform this exchange. Multiple consume actions can be specified, allowing complex exchange costs such as requiring both gold and items. These actions are executed as consume actions within a distributed transaction. | ||||||||
| timingType | String Enum enum { “immediate”, “await” } | “immediate” | Type of exchange Determines when rewards are delivered after performing the exchange. immediate delivers rewards instantly upon exchange execution. await requires real-time to elapse before rewards can be claimed, creating a waiting period (e.g., crafting time).
| |||||||||
| lockTime | int | {timingType} == “await” | ✓* | 0 ~ 538214400 | Waiting time (minutes) from the execution of the exchange until the reward is actually received Only applicable when timingType is await. Specifies the number of minutes that must elapse in real time after the exchange is initiated before the player can claim the rewards. The waiting time can be shortened by using the skip mechanism.* Required if timingType is “await” | |||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the exchange. Multiple acquire actions can be specified to grant various resource types simultaneously. These actions are executed as acquire actions within a distributed transaction. | ||||||||
| createdAt | long | * | Now | Datetime of creation Unix time, milliseconds * Set automatically by the server | ||||||||
| updatedAt | long | * | Now | Datetime of last update Unix time, milliseconds * Set automatically by the server | ||||||||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
IncrementalRateModelMaster
Incremental Cost Exchange Rate Model Master
Incremental Cost Exchange Rate Model Master is data used to edit and manage Incremental Cost Exchange Rate Model within the game. It is temporarily stored in the Management Console’s Master Data Editor. By performing import and update processes, it is reflected as Incremental Cost Exchange Rate Model actually referenced by the game.
Normal exchange rates always provide exchanges at a constant rate. With incremental exchange rates, you can define a rate that increases in cost as the number of exchanges increases. For example, the first exchange is performed at a rate of 1:1, but the second exchange is performed at a rate of 2:1. By defining such a rate, you can increase the value of the resources obtained by the player as the game progresses.
The number of exchanges can be reset after a certain period of real time has elapsed. This is useful for resetting the number of exchanges on a daily or weekly basis.
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| incrementalRateModelId | string | * | ~ 1024 chars | Incremental Cost Exchange Rate Model Master GRN * Set automatically by the server | ||||||||||
| name | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||||||||||
| description | string | ~ 1024 chars | Description | |||||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||||
| consumeAction | ConsumeAction | ✓ | Consume Action (Quantity and Value are overwritten automatically) Defines the type of resource consumed as cost for the exchange. The actual quantity is calculated dynamically based on the exchange count and the calculation type (linear, power, or script). Only the action type and target resource need to be specified; the quantity field is overwritten automatically. | |||||||||||
| calculateType | String Enum enum { “linear”, “power”, “gs2_script” } | ✓ | Calculation method for cost increase amount Determines how the exchange cost escalates with each exchange. linear calculates cost as baseValue + (coefficientValue * exchangeCount). power calculates cost as coefficientValue * (exchangeCount + 1)^2. gs2_script delegates the calculation to a custom GS2-Script for arbitrary logic.
| |||||||||||
| baseValue | long | {calculateType} == “linear” | ✓* | 0 ~ 9223372036854775805 | Base Value The initial cost for the first exchange when using the linear calculation type. The total cost is calculated as: baseValue + (coefficientValue * exchangeCount).* Required if calculateType is “linear” | |||||||||
| coefficientValue | long | {calculateType} in [“linear”, “power”] | ✓* | 0 ~ 9223372036854775805 | Coefficient Value The multiplier that controls how quickly costs escalate with each exchange. In linear mode, each exchange adds this value to the cost. In power mode, the cost is calculated as: coefficientValue * (exchangeCount + 1)^2.* Required if calculateType is “linear”,“power” | |||||||||
| calculateScriptId | string | {calculateType} == “gs2_script” | ✓* | ~ 1024 chars | GRN
of cost calculation script Script Trigger Reference - calculateCost* Required if calculateType is “gs2_script” | |||||||||
| exchangeCountId | string | ✓ | ~ 1024 chars | GS2-Limit Usage Limit Model GRN
for managing exchange execution counts References a GS2-Limit limit model that tracks how many times each user has performed this incremental exchange. The count is used to calculate the escalating cost and can be reset periodically (e.g., daily or weekly) using GS2-Limit’s reset timing. | ||||||||||
| maximumExchangeCount | int | 2147483646 | 0 ~ 2147483646 | Maximum number of exchanges The maximum number of times this incremental exchange can be performed by a user. Once the exchange count reaches this limit, further exchanges are denied until the count is reset via GS2-Limit. | ||||||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the incremental exchange. The rewards remain constant regardless of the exchange count; only the cost increases with each exchange. | ||||||||||
| createdAt | long | * | Now | Datetime of creation Unix time, milliseconds * Set automatically by the server | ||||||||||
| updatedAt | long | * | Now | Datetime of last update Unix time, milliseconds * Set automatically by the server | ||||||||||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
Methods
describeNamespaces
Get a list of Namespaces
Retrieves a list of namespaces that have been created on a per-service basis within the project. You can use the optional page token to start acquiring data from a specific location in the list. You can also limit the number of namespaces to be acquired.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namePrefix | string | ~ 64 chars | Filter by Namespace name prefix | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<Namespace> | List of Namespaces |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeNamespaces(
&exchange.DescribeNamespacesRequest {
NamePrefix: nil,
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeNamespacesRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeNamespaces(
(new DescribeNamespacesRequest())
->withNamePrefix(null)
->withPageToken(null)
->withLimit(null)
);
$items = $result->getItems();
$nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeNamespacesRequest;
import io.gs2.exchange.result.DescribeNamespacesResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeNamespacesResult result = client.describeNamespaces(
new DescribeNamespacesRequest()
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
List<Namespace> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
new Gs2.Gs2Exchange.Request.DescribeNamespacesRequest()
.WithNamePrefix(null)
.WithPageToken(null)
.WithLimit(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeNamespaces(
new Gs2Exchange.DescribeNamespacesRequest()
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
const items = result.getItems();
const nextPageToken = result.getNextPageToken();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_namespaces(
exchange.DescribeNamespacesRequest()
.with_name_prefix(None)
.with_page_token(None)
.with_limit(None)
)
items = result.items
next_page_token = result.next_page_token
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_namespaces({
namePrefix=nil,
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('exchange')
api_result_handler = client.describe_namespaces_async({
namePrefix=nil,
pageToken=nil,
limit=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;createNamespace
Create a new Namespace
You must specify detailed information including the name, description, and various settings of the namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| enableAwaitExchange | bool | false | Whether to enable exchanges that require a waiting time before receiving results When enabled, exchange rate models with await timing type can be used. These exchanges require real-time to elapse before rewards can be claimed, enabling crafting or production mechanics where players must wait for the result. | |||
| enableDirectExchange | bool | true | Allow direct exchange API calls When enabled, clients can call the exchange API directly to perform resource exchanges. When disabled, exchanges can only be triggered via transaction actions (transactions), providing tighter server-side control over when exchanges occur. | |||
| transactionSetting | TransactionSetting | ✓ | Transaction Setting Configuration for controlling how distributed transactions are executed when processing exchange operations. Supports auto-run, atomic commit, and async processing options. | |||
| exchangeScript | ScriptSetting | Script to run when an attempt is made to perform an exchange Script Trigger Reference - exchange | ||||
| incrementalExchangeScript | ScriptSetting | Script to run when an attempt is made to perform an incremental exchange Script Trigger Reference - incrementalExchange | ||||
| acquireAwaitScript | ScriptSetting | Script setting executed when the waiting period completes and the reward is about to be acquired in an await-type exchange Script Trigger Reference - acquireAwait | ||||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of exchange operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for exchange, incremental exchange, and await operations can be collected. |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace created |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CreateNamespace(
&exchange.CreateNamespaceRequest {
Name: pointy.String("namespace-0001"),
Description: nil,
EnableAwaitExchange: nil,
EnableDirectExchange: nil,
TransactionSetting: &exchange.TransactionSetting{
EnableAutoRun: pointy.Bool(false),
QueueNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"),
},
ExchangeScript: nil,
IncrementalExchangeScript: nil,
AcquireAwaitScript: nil,
LogSetting: &exchange.LogSetting{
LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CreateNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->createNamespace(
(new CreateNamespaceRequest())
->withName("namespace-0001")
->withDescription(null)
->withEnableAwaitExchange(null)
->withEnableDirectExchange(null)
->withTransactionSetting((new \Gs2\Exchange\Model\TransactionSetting())
->withEnableAutoRun(false)
->withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"))
->withExchangeScript(null)
->withIncrementalExchangeScript(null)
->withAcquireAwaitScript(null)
->withLogSetting((new \Gs2\Exchange\Model\LogSetting())
->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CreateNamespaceRequest;
import io.gs2.exchange.result.CreateNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CreateNamespaceResult result = client.createNamespace(
new CreateNamespaceRequest()
.withName("namespace-0001")
.withDescription(null)
.withEnableAwaitExchange(null)
.withEnableDirectExchange(null)
.withTransactionSetting(new io.gs2.exchange.model.TransactionSetting()
.withEnableAutoRun(false)
.withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"))
.withExchangeScript(null)
.withIncrementalExchangeScript(null)
.withAcquireAwaitScript(null)
.withLogSetting(new io.gs2.exchange.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
new Gs2.Gs2Exchange.Request.CreateNamespaceRequest()
.WithName("namespace-0001")
.WithDescription(null)
.WithEnableAwaitExchange(null)
.WithEnableDirectExchange(null)
.WithTransactionSetting(new Gs2.Gs2Exchange.Model.TransactionSetting()
.WithEnableAutoRun(false)
.WithQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"))
.WithExchangeScript(null)
.WithIncrementalExchangeScript(null)
.WithAcquireAwaitScript(null)
.WithLogSetting(new Gs2.Gs2Exchange.Model.LogSetting()
.WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.createNamespace(
new Gs2Exchange.CreateNamespaceRequest()
.withName("namespace-0001")
.withDescription(null)
.withEnableAwaitExchange(null)
.withEnableDirectExchange(null)
.withTransactionSetting(new Gs2Exchange.model.TransactionSetting()
.withEnableAutoRun(false)
.withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"))
.withExchangeScript(null)
.withIncrementalExchangeScript(null)
.withAcquireAwaitScript(null)
.withLogSetting(new Gs2Exchange.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.create_namespace(
exchange.CreateNamespaceRequest()
.with_name('namespace-0001')
.with_description(None)
.with_enable_await_exchange(None)
.with_enable_direct_exchange(None)
.with_transaction_setting(
exchange.TransactionSetting()
.with_enable_auto_run(False)
.with_queue_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001'))
.with_exchange_script(None)
.with_incremental_exchange_script(None)
.with_acquire_await_script(None)
.with_log_setting(
exchange.LogSetting()
.with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.create_namespace({
name="namespace-0001",
description=nil,
enableAwaitExchange=nil,
enableDirectExchange=nil,
transactionSetting={
enableAutoRun=false,
queueNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
},
exchangeScript=nil,
incrementalExchangeScript=nil,
acquireAwaitScript=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.create_namespace_async({
name="namespace-0001",
description=nil,
enableAwaitExchange=nil,
enableDirectExchange=nil,
transactionSetting={
enableAutoRun=false,
queueNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
},
exchangeScript=nil,
incrementalExchangeScript=nil,
acquireAwaitScript=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getNamespaceStatus
Get Namespace status
Get the current status of the specified namespace. This includes whether the Namespace is active, pending, or in some other state.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| status | string |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetNamespaceStatus(
&exchange.GetNamespaceStatusRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
status := result.Statususe Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetNamespaceStatusRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getNamespaceStatus(
(new GetNamespaceStatusRequest())
->withNamespaceName("namespace-0001")
);
$status = $result->getStatus();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetNamespaceStatusRequest;
import io.gs2.exchange.result.GetNamespaceStatusResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetNamespaceStatusResult result = client.getNamespaceStatus(
new GetNamespaceStatusRequest()
.withNamespaceName("namespace-0001")
);
String status = result.getStatus();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
new Gs2.Gs2Exchange.Request.GetNamespaceStatusRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getNamespaceStatus(
new Gs2Exchange.GetNamespaceStatusRequest()
.withNamespaceName("namespace-0001")
);
const status = result.getStatus();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_namespace_status(
exchange.GetNamespaceStatusRequest()
.with_namespace_name('namespace-0001')
)
status = result.status
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_namespace_status({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
status = result.status;client = gs2('exchange')
api_result_handler = client.get_namespace_status_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
status = result.status;getNamespace
Get namespace
Get detailed information about the specified namespace. This includes the name, description, and other settings of the namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetNamespace(
&exchange.GetNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getNamespace(
(new GetNamespaceRequest())
->withNamespaceName("namespace-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetNamespaceRequest;
import io.gs2.exchange.result.GetNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetNamespaceResult result = client.getNamespace(
new GetNamespaceRequest()
.withNamespaceName("namespace-0001")
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
new Gs2.Gs2Exchange.Request.GetNamespaceRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getNamespace(
new Gs2Exchange.GetNamespaceRequest()
.withNamespaceName("namespace-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_namespace(
exchange.GetNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_namespace({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_namespace_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;updateNamespace
Update Namespace
Update the settings of the specified namespace. You can change the description of the Namespace and specific settings.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| enableAwaitExchange | bool | false | Whether to enable exchanges that require a waiting time before receiving results When enabled, exchange rate models with await timing type can be used. These exchanges require real-time to elapse before rewards can be claimed, enabling crafting or production mechanics where players must wait for the result. | |||
| enableDirectExchange | bool | true | Allow direct exchange API calls When enabled, clients can call the exchange API directly to perform resource exchanges. When disabled, exchanges can only be triggered via transaction actions (transactions), providing tighter server-side control over when exchanges occur. | |||
| transactionSetting | TransactionSetting | ✓ | Transaction Setting Configuration for controlling how distributed transactions are executed when processing exchange operations. Supports auto-run, atomic commit, and async processing options. | |||
| exchangeScript | ScriptSetting | Script to run when an attempt is made to perform an exchange Script Trigger Reference - exchange | ||||
| incrementalExchangeScript | ScriptSetting | Script to run when an attempt is made to perform an incremental exchange Script Trigger Reference - incrementalExchange | ||||
| acquireAwaitScript | ScriptSetting | Script setting executed when the waiting period completes and the reward is about to be acquired in an await-type exchange Script Trigger Reference - acquireAwait | ||||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of exchange operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for exchange, incremental exchange, and await operations can be collected. |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace updated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.UpdateNamespace(
&exchange.UpdateNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
Description: pointy.String("description1"),
EnableAwaitExchange: pointy.Bool(true),
EnableDirectExchange: nil,
TransactionSetting: &exchange.TransactionSetting{
EnableAutoRun: pointy.Bool(false),
QueueNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002"),
},
ExchangeScript: nil,
IncrementalExchangeScript: nil,
AcquireAwaitScript: nil,
LogSetting: &exchange.LogSetting{
LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\UpdateNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->updateNamespace(
(new UpdateNamespaceRequest())
->withNamespaceName("namespace-0001")
->withDescription("description1")
->withEnableAwaitExchange(true)
->withEnableDirectExchange(null)
->withTransactionSetting((new \Gs2\Exchange\Model\TransactionSetting())
->withEnableAutoRun(false)
->withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002"))
->withExchangeScript(null)
->withIncrementalExchangeScript(null)
->withAcquireAwaitScript(null)
->withLogSetting((new \Gs2\Exchange\Model\LogSetting())
->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.UpdateNamespaceRequest;
import io.gs2.exchange.result.UpdateNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
UpdateNamespaceResult result = client.updateNamespace(
new UpdateNamespaceRequest()
.withNamespaceName("namespace-0001")
.withDescription("description1")
.withEnableAwaitExchange(true)
.withEnableDirectExchange(null)
.withTransactionSetting(new io.gs2.exchange.model.TransactionSetting()
.withEnableAutoRun(false)
.withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002"))
.withExchangeScript(null)
.withIncrementalExchangeScript(null)
.withAcquireAwaitScript(null)
.withLogSetting(new io.gs2.exchange.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
new Gs2.Gs2Exchange.Request.UpdateNamespaceRequest()
.WithNamespaceName("namespace-0001")
.WithDescription("description1")
.WithEnableAwaitExchange(true)
.WithEnableDirectExchange(null)
.WithTransactionSetting(new Gs2.Gs2Exchange.Model.TransactionSetting()
.WithEnableAutoRun(false)
.WithQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002"))
.WithExchangeScript(null)
.WithIncrementalExchangeScript(null)
.WithAcquireAwaitScript(null)
.WithLogSetting(new Gs2.Gs2Exchange.Model.LogSetting()
.WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.updateNamespace(
new Gs2Exchange.UpdateNamespaceRequest()
.withNamespaceName("namespace-0001")
.withDescription("description1")
.withEnableAwaitExchange(true)
.withEnableDirectExchange(null)
.withTransactionSetting(new Gs2Exchange.model.TransactionSetting()
.withEnableAutoRun(false)
.withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002"))
.withExchangeScript(null)
.withIncrementalExchangeScript(null)
.withAcquireAwaitScript(null)
.withLogSetting(new Gs2Exchange.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.update_namespace(
exchange.UpdateNamespaceRequest()
.with_namespace_name('namespace-0001')
.with_description('description1')
.with_enable_await_exchange(True)
.with_enable_direct_exchange(None)
.with_transaction_setting(
exchange.TransactionSetting()
.with_enable_auto_run(False)
.with_queue_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002'))
.with_exchange_script(None)
.with_incremental_exchange_script(None)
.with_acquire_await_script(None)
.with_log_setting(
exchange.LogSetting()
.with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.update_namespace({
namespaceName="namespace-0001",
description="description1",
enableAwaitExchange=true,
enableDirectExchange=nil,
transactionSetting={
enableAutoRun=false,
queueNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002",
},
exchangeScript=nil,
incrementalExchangeScript=nil,
acquireAwaitScript=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.update_namespace_async({
namespaceName="namespace-0001",
description="description1",
enableAwaitExchange=true,
enableDirectExchange=nil,
transactionSetting={
enableAutoRun=false,
queueNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0002",
},
exchangeScript=nil,
incrementalExchangeScript=nil,
acquireAwaitScript=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteNamespace
Delete Namespace
Delete the specified namespace. This operation is irreversible and all data associated with the deleted Namespace will be lost.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | The deleted Namespace |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DeleteNamespace(
&exchange.DeleteNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DeleteNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->deleteNamespace(
(new DeleteNamespaceRequest())
->withNamespaceName("namespace-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DeleteNamespaceRequest;
import io.gs2.exchange.result.DeleteNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DeleteNamespaceResult result = client.deleteNamespace(
new DeleteNamespaceRequest()
.withNamespaceName("namespace-0001")
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
new Gs2.Gs2Exchange.Request.DeleteNamespaceRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.deleteNamespace(
new Gs2Exchange.DeleteNamespaceRequest()
.withNamespaceName("namespace-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.delete_namespace(
exchange.DeleteNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.delete_namespace({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.delete_namespace_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getServiceVersion
Get the microservice version
Details
Request
Request parameters: None
Result
| Type | Description | |
|---|---|---|
| item | string | Version |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetServiceVersion(
&exchange.GetServiceVersionRequest {
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetServiceVersionRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getServiceVersion(
(new GetServiceVersionRequest())
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetServiceVersionRequest;
import io.gs2.exchange.result.GetServiceVersionResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetServiceVersionResult result = client.getServiceVersion(
new GetServiceVersionRequest()
);
String item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
new Gs2.Gs2Exchange.Request.GetServiceVersionRequest(),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getServiceVersion(
new Gs2Exchange.GetServiceVersionRequest()
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_service_version(
exchange.GetServiceVersionRequest()
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_service_version({
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_service_version_async({
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;dumpUserDataByUserId
Dump data associated with the specified user ID
Can be used to meet legal requirements for the protection of personal information, or to back up or migrate data.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description |
|---|
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DumpUserDataByUserId(
&exchange.DumpUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DumpUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->dumpUserDataByUserId(
(new DumpUserDataByUserIdRequest())
->withUserId("user-0001")
->withTimeOffsetToken(null)
);
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DumpUserDataByUserIdRequest;
import io.gs2.exchange.result.DumpUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DumpUserDataByUserIdResult result = client.dumpUserDataByUserId(
new DumpUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DumpUserDataByUserIdResult> asyncResult = null;
yield return client.DumpUserDataByUserId(
new Gs2.Gs2Exchange.Request.DumpUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.dumpUserDataByUserId(
new Gs2Exchange.DumpUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.dump_user_data_by_user_id(
exchange.DumpUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.dump_user_data_by_user_id({
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultclient = gs2('exchange')
api_result_handler = client.dump_user_data_by_user_id_async({
userId="user-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultcheckDumpUserDataByUserId
Check if the dump of the data associated with the specified user ID is complete
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| url | string | URL of output data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CheckDumpUserDataByUserId(
&exchange.CheckDumpUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
url := result.Urluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CheckDumpUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->checkDumpUserDataByUserId(
(new CheckDumpUserDataByUserIdRequest())
->withUserId("user-0001")
->withTimeOffsetToken(null)
);
$url = $result->getUrl();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CheckDumpUserDataByUserIdRequest;
import io.gs2.exchange.result.CheckDumpUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CheckDumpUserDataByUserIdResult result = client.checkDumpUserDataByUserId(
new CheckDumpUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
String url = result.getUrl();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CheckDumpUserDataByUserIdResult> asyncResult = null;
yield return client.CheckDumpUserDataByUserId(
new Gs2.Gs2Exchange.Request.CheckDumpUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.checkDumpUserDataByUserId(
new Gs2Exchange.CheckDumpUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
const url = result.getUrl();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.check_dump_user_data_by_user_id(
exchange.CheckDumpUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
url = result.url
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.check_dump_user_data_by_user_id({
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
url = result.url;client = gs2('exchange')
api_result_handler = client.check_dump_user_data_by_user_id_async({
userId="user-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
url = result.url;cleanUserDataByUserId
Delete user data
Execute cleaning of data associated with the specified user ID This allows you to safely delete specific user data from the project.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description |
|---|
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CleanUserDataByUserId(
&exchange.CleanUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CleanUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->cleanUserDataByUserId(
(new CleanUserDataByUserIdRequest())
->withUserId("user-0001")
->withTimeOffsetToken(null)
);
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CleanUserDataByUserIdRequest;
import io.gs2.exchange.result.CleanUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CleanUserDataByUserIdResult result = client.cleanUserDataByUserId(
new CleanUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CleanUserDataByUserIdResult> asyncResult = null;
yield return client.CleanUserDataByUserId(
new Gs2.Gs2Exchange.Request.CleanUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.cleanUserDataByUserId(
new Gs2Exchange.CleanUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.clean_user_data_by_user_id(
exchange.CleanUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.clean_user_data_by_user_id({
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultclient = gs2('exchange')
api_result_handler = client.clean_user_data_by_user_id_async({
userId="user-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultcheckCleanUserDataByUserId
Check if the cleaning of the data associated with the specified user ID is complete
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description |
|---|
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CheckCleanUserDataByUserId(
&exchange.CheckCleanUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CheckCleanUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->checkCleanUserDataByUserId(
(new CheckCleanUserDataByUserIdRequest())
->withUserId("user-0001")
->withTimeOffsetToken(null)
);
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CheckCleanUserDataByUserIdRequest;
import io.gs2.exchange.result.CheckCleanUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CheckCleanUserDataByUserIdResult result = client.checkCleanUserDataByUserId(
new CheckCleanUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CheckCleanUserDataByUserIdResult> asyncResult = null;
yield return client.CheckCleanUserDataByUserId(
new Gs2.Gs2Exchange.Request.CheckCleanUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.checkCleanUserDataByUserId(
new Gs2Exchange.CheckCleanUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.check_clean_user_data_by_user_id(
exchange.CheckCleanUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.check_clean_user_data_by_user_id({
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultclient = gs2('exchange')
api_result_handler = client.check_clean_user_data_by_user_id_async({
userId="user-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultprepareImportUserDataByUserId
Execute import of data associated with the specified user ID
The data that can be used for import is limited to the data exported by GS2, and old data may fail to import. You can import data with a user ID different from the one you exported, but if the user ID is included in the payload of the user data, this may not be the case.
You can start the actual import process by uploading the exported zip file to the URL returned in the return value of this API and calling importUserDataByUserId.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| uploadToken | string | Token used to reflect results after upload |
| uploadUrl | string | URL used to upload user data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.PrepareImportUserDataByUserId(
&exchange.PrepareImportUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\PrepareImportUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->prepareImportUserDataByUserId(
(new PrepareImportUserDataByUserIdRequest())
->withUserId("user-0001")
->withTimeOffsetToken(null)
);
$uploadToken = $result->getUploadToken();
$uploadUrl = $result->getUploadUrl();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.PrepareImportUserDataByUserIdRequest;
import io.gs2.exchange.result.PrepareImportUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
PrepareImportUserDataByUserIdResult result = client.prepareImportUserDataByUserId(
new PrepareImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
String uploadToken = result.getUploadToken();
String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.PrepareImportUserDataByUserIdResult> asyncResult = null;
yield return client.PrepareImportUserDataByUserId(
new Gs2.Gs2Exchange.Request.PrepareImportUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.prepareImportUserDataByUserId(
new Gs2Exchange.PrepareImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
const uploadToken = result.getUploadToken();
const uploadUrl = result.getUploadUrl();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.prepare_import_user_data_by_user_id(
exchange.PrepareImportUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
upload_token = result.upload_token
upload_url = result.upload_url
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.prepare_import_user_data_by_user_id({
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;client = gs2('exchange')
api_result_handler = client.prepare_import_user_data_by_user_id_async({
userId="user-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;importUserDataByUserId
Execute import of data associated with the specified user ID
The data that can be used for import is limited to the data exported by GS2, and old data may fail to import. You can import data with a user ID different from the one you exported, but if the user ID is included in the payload of the user data, this may not be the case.
Before calling this API, you must call prepareImportUserDataByUserId to complete the upload preparation.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| uploadToken | string | ✓ | ~ 1024 chars | Token received in preparation for upload | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description |
|---|
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.ImportUserDataByUserId(
&exchange.ImportUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
UploadToken: pointy.String("upload-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\ImportUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->importUserDataByUserId(
(new ImportUserDataByUserIdRequest())
->withUserId("user-0001")
->withUploadToken("upload-0001")
->withTimeOffsetToken(null)
);
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.ImportUserDataByUserIdRequest;
import io.gs2.exchange.result.ImportUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
ImportUserDataByUserIdResult result = client.importUserDataByUserId(
new ImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withUploadToken("upload-0001")
.withTimeOffsetToken(null)
);
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.ImportUserDataByUserIdResult> asyncResult = null;
yield return client.ImportUserDataByUserId(
new Gs2.Gs2Exchange.Request.ImportUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithUploadToken("upload-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.importUserDataByUserId(
new Gs2Exchange.ImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withUploadToken("upload-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.import_user_data_by_user_id(
exchange.ImportUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_upload_token('upload-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.import_user_data_by_user_id({
userId="user-0001",
uploadToken="upload-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultclient = gs2('exchange')
api_result_handler = client.import_user_data_by_user_id_async({
userId="user-0001",
uploadToken="upload-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultcheckImportUserDataByUserId
Check if the import of the data associated with the specified user ID is complete
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| uploadToken | string | ✓ | ~ 1024 chars | Token received in preparation for upload | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| url | string | URL of log data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CheckImportUserDataByUserId(
&exchange.CheckImportUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
UploadToken: pointy.String("upload-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
url := result.Urluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CheckImportUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->checkImportUserDataByUserId(
(new CheckImportUserDataByUserIdRequest())
->withUserId("user-0001")
->withUploadToken("upload-0001")
->withTimeOffsetToken(null)
);
$url = $result->getUrl();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CheckImportUserDataByUserIdRequest;
import io.gs2.exchange.result.CheckImportUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CheckImportUserDataByUserIdResult result = client.checkImportUserDataByUserId(
new CheckImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withUploadToken("upload-0001")
.withTimeOffsetToken(null)
);
String url = result.getUrl();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CheckImportUserDataByUserIdResult> asyncResult = null;
yield return client.CheckImportUserDataByUserId(
new Gs2.Gs2Exchange.Request.CheckImportUserDataByUserIdRequest()
.WithUserId("user-0001")
.WithUploadToken("upload-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.checkImportUserDataByUserId(
new Gs2Exchange.CheckImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withUploadToken("upload-0001")
.withTimeOffsetToken(null)
);
const url = result.getUrl();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.check_import_user_data_by_user_id(
exchange.CheckImportUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_upload_token('upload-0001')
.with_time_offset_token(None)
)
url = result.url
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.check_import_user_data_by_user_id({
userId="user-0001",
uploadToken="upload-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
url = result.url;client = gs2('exchange')
api_result_handler = client.check_import_user_data_by_user_id_async({
userId="user-0001",
uploadToken="upload-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
url = result.url;exchange
Perform exchange
Executes a resource exchange based on the specified Exchange Rate Model. Validates the rate model’s timing type: for ‘immediate’ timing, the namespace must have direct exchange enabled; for ‘await’ timing, the namespace must have await exchange enabled. A transaction (transaction) is issued to execute the consume/verify/acquire actions defined in the rate model, multiplied by the specified count.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| count | int | ✓ | 1 ~ 1073741821 | Number of exchanges | ||
| config | List<Config> | [] | 0 ~ 32 items | Set values to be applied to transaction variables |
Result
| Type | Description | |
|---|---|---|
| item | RateModel | Exchange Rate Model |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the exchange process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.Exchange(
&exchange.ExchangeRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
AccessToken: pointy.String("accessToken-0001"),
Count: pointy.Int32(1),
Config: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\ExchangeRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->exchange(
(new ExchangeRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
->withAccessToken("accessToken-0001")
->withCount(1)
->withConfig(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.ExchangeRequest;
import io.gs2.exchange.result.ExchangeResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
ExchangeResult result = client.exchange(
new ExchangeRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withAccessToken("accessToken-0001")
.withCount(1)
.withConfig(null)
);
RateModel item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.ExchangeResult> asyncResult = null;
yield return client.Exchange(
new Gs2.Gs2Exchange.Request.ExchangeRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001")
.WithAccessToken("accessToken-0001")
.WithCount(1)
.WithConfig(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.exchange(
new Gs2Exchange.ExchangeRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withAccessToken("accessToken-0001")
.withCount(1)
.withConfig(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.exchange(
exchange.ExchangeRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
.with_access_token('accessToken-0001')
.with_count(1)
.with_config(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.exchange({
namespaceName="namespace-0001",
rateName="rate-0001",
accessToken="accessToken-0001",
count=1,
config=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.exchange_async({
namespaceName="namespace-0001",
rateName="rate-0001",
accessToken="accessToken-0001",
count=1,
config=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;exchangeByUserId
Perform exchange by specifying a user ID
Executes a resource exchange based on the specified Exchange Rate Model for the specified user. Validates the rate model’s timing type: for ‘immediate’ timing, the namespace must have direct exchange enabled; for ‘await’ timing, the namespace must have await exchange enabled. A transaction (transaction) is issued to execute the consume/verify/acquire actions defined in the rate model, multiplied by the specified count.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| count | int | ✓ | 1 ~ 1073741821 | Number of exchanges | ||
| config | List<Config> | [] | 0 ~ 32 items | Set values to be applied to transaction variables | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | RateModel | Exchange Rate Model |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the exchange process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.ExchangeByUserId(
&exchange.ExchangeByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
UserId: pointy.String("user-0001"),
Count: pointy.Int32(1),
Config: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\ExchangeByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->exchangeByUserId(
(new ExchangeByUserIdRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
->withUserId("user-0001")
->withCount(1)
->withConfig(null)
->withTimeOffsetToken(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.ExchangeByUserIdRequest;
import io.gs2.exchange.result.ExchangeByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
ExchangeByUserIdResult result = client.exchangeByUserId(
new ExchangeByUserIdRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withUserId("user-0001")
.withCount(1)
.withConfig(null)
.withTimeOffsetToken(null)
);
RateModel item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.ExchangeByUserIdResult> asyncResult = null;
yield return client.ExchangeByUserId(
new Gs2.Gs2Exchange.Request.ExchangeByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001")
.WithUserId("user-0001")
.WithCount(1)
.WithConfig(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.exchangeByUserId(
new Gs2Exchange.ExchangeByUserIdRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withUserId("user-0001")
.withCount(1)
.withConfig(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.exchange_by_user_id(
exchange.ExchangeByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
.with_user_id('user-0001')
.with_count(1)
.with_config(None)
.with_time_offset_token(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.exchange_by_user_id({
namespaceName="namespace-0001",
rateName="rate-0001",
userId="user-0001",
count=1,
config=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.exchange_by_user_id_async({
namespaceName="namespace-0001",
rateName="rate-0001",
userId="user-0001",
count=1,
config=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;incrementalExchange
Perform incremental cost exchange
Executes a resource exchange where the cost increases progressively with each execution, based on the specified Incremental Cost Exchange Rate Model. The consume cost is calculated according to the model’s calculation type (linear formula or GS2-Script) and the current exchange count. A transaction (transaction) is issued to execute the consume and acquire actions.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| count | int | ✓ | 1 ~ 1073741821 | Number of exchanges | ||
| config | List<Config> | [] | 0 ~ 32 items | Set values to be applied to transaction variables |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModel | Incremental Cost Exchange Rate Model |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the exchange process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.IncrementalExchange(
&exchange.IncrementalExchangeRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
AccessToken: pointy.String("accessToken-0001"),
Count: pointy.Int32(1),
Config: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\IncrementalExchangeRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->incrementalExchange(
(new IncrementalExchangeRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
->withAccessToken("accessToken-0001")
->withCount(1)
->withConfig(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.IncrementalExchangeRequest;
import io.gs2.exchange.result.IncrementalExchangeResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
IncrementalExchangeResult result = client.incrementalExchange(
new IncrementalExchangeRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withAccessToken("accessToken-0001")
.withCount(1)
.withConfig(null)
);
IncrementalRateModel item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.IncrementalExchangeResult> asyncResult = null;
yield return client.IncrementalExchange(
new Gs2.Gs2Exchange.Request.IncrementalExchangeRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001")
.WithAccessToken("accessToken-0001")
.WithCount(1)
.WithConfig(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.incrementalExchange(
new Gs2Exchange.IncrementalExchangeRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withAccessToken("accessToken-0001")
.withCount(1)
.withConfig(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.incremental_exchange(
exchange.IncrementalExchangeRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
.with_access_token('accessToken-0001')
.with_count(1)
.with_config(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.incremental_exchange({
namespaceName="namespace-0001",
rateName="rate-0001",
accessToken="accessToken-0001",
count=1,
config=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.incremental_exchange_async({
namespaceName="namespace-0001",
rateName="rate-0001",
accessToken="accessToken-0001",
count=1,
config=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;incrementalExchangeByUserId
Perform incremental cost exchange by specifying a user ID
Executes a resource exchange where the cost increases progressively with each execution, based on the specified Incremental Cost Exchange Rate Model for the specified user. The consume cost is calculated according to the model’s calculation type (linear formula or GS2-Script) and the current exchange count. A transaction (transaction) is issued to execute the consume and acquire actions.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| count | int | ✓ | 1 ~ 1073741821 | Number of exchanges | ||
| config | List<Config> | [] | 0 ~ 32 items | Set values to be applied to transaction variables | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModel | Incremental Cost Exchange Rate Model |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the exchange process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.IncrementalExchangeByUserId(
&exchange.IncrementalExchangeByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
UserId: pointy.String("user-0001"),
Count: pointy.Int32(1),
Config: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\IncrementalExchangeByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->incrementalExchangeByUserId(
(new IncrementalExchangeByUserIdRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
->withUserId("user-0001")
->withCount(1)
->withConfig(null)
->withTimeOffsetToken(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.IncrementalExchangeByUserIdRequest;
import io.gs2.exchange.result.IncrementalExchangeByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
IncrementalExchangeByUserIdResult result = client.incrementalExchangeByUserId(
new IncrementalExchangeByUserIdRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withUserId("user-0001")
.withCount(1)
.withConfig(null)
.withTimeOffsetToken(null)
);
IncrementalRateModel item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.IncrementalExchangeByUserIdResult> asyncResult = null;
yield return client.IncrementalExchangeByUserId(
new Gs2.Gs2Exchange.Request.IncrementalExchangeByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001")
.WithUserId("user-0001")
.WithCount(1)
.WithConfig(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.incrementalExchangeByUserId(
new Gs2Exchange.IncrementalExchangeByUserIdRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withUserId("user-0001")
.withCount(1)
.withConfig(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.incremental_exchange_by_user_id(
exchange.IncrementalExchangeByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
.with_user_id('user-0001')
.with_count(1)
.with_config(None)
.with_time_offset_token(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.incremental_exchange_by_user_id({
namespaceName="namespace-0001",
rateName="rate-0001",
userId="user-0001",
count=1,
config=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.incremental_exchange_by_user_id_async({
namespaceName="namespace-0001",
rateName="rate-0001",
userId="user-0001",
count=1,
config=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;createAwaitByUserId
Create Exchange Await by specifying a user ID
Creates a new exchange await record for a time-delayed exchange. The specified rate model must have its timing type set to ‘await’; otherwise the request is rejected. The await starts with zero skip seconds, and the lock time defined in the rate model determines how long the user must wait before acquiring the rewards. Default configuration values can be set at creation time and will be merged with any config provided at acquisition time.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| count | int | 1 | 1 ~ 10000 | Number of exchanges The number of times this exchange should be performed. Multiple exchanges can be batched into a single await, multiplying both the cost consumed and the rewards received. | ||
| config | List<Config> | [] | 0 ~ 32 items | Default configuration values applied when obtaining rewards | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CreateAwaitByUserId(
&exchange.CreateAwaitByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
RateName: pointy.String("material_n_to_r"),
Count: nil,
Config: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CreateAwaitByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->createAwaitByUserId(
(new CreateAwaitByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withRateName("material_n_to_r")
->withCount(null)
->withConfig(null)
->withTimeOffsetToken(null)
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CreateAwaitByUserIdRequest;
import io.gs2.exchange.result.CreateAwaitByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CreateAwaitByUserIdResult result = client.createAwaitByUserId(
new CreateAwaitByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withRateName("material_n_to_r")
.withCount(null)
.withConfig(null)
.withTimeOffsetToken(null)
);
Await item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CreateAwaitByUserIdResult> asyncResult = null;
yield return client.CreateAwaitByUserId(
new Gs2.Gs2Exchange.Request.CreateAwaitByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithRateName("material_n_to_r")
.WithCount(null)
.WithConfig(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.createAwaitByUserId(
new Gs2Exchange.CreateAwaitByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withRateName("material_n_to_r")
.withCount(null)
.withConfig(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.create_await_by_user_id(
exchange.CreateAwaitByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_rate_name('material_n_to_r')
.with_count(None)
.with_config(None)
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.create_await_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
rateName="material_n_to_r",
count=nil,
config=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.create_await_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
rateName="material_n_to_r",
count=nil,
config=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;describeAwaits
Get a list of Exchange Awaits
Retrieves a paginated list of exchange await records for the authenticated user. Optionally filter by rate name to retrieve only awaits for a specific exchange rate. Each await record includes the rate name, exchange count, skip seconds, and timing information.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| rateName | string | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<Await> | List of Exchange Awaits |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeAwaits(
&exchange.DescribeAwaitsRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
RateName: pointy.String("material_n_to_r"),
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeAwaitsRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeAwaits(
(new DescribeAwaitsRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-0001")
->withRateName("material_n_to_r")
->withPageToken(null)
->withLimit(null)
);
$items = $result->getItems();
$nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeAwaitsRequest;
import io.gs2.exchange.result.DescribeAwaitsResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeAwaitsResult result = client.describeAwaits(
new DescribeAwaitsRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withRateName("material_n_to_r")
.withPageToken(null)
.withLimit(null)
);
List<Await> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeAwaitsResult> asyncResult = null;
yield return client.DescribeAwaits(
new Gs2.Gs2Exchange.Request.DescribeAwaitsRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-0001")
.WithRateName("material_n_to_r")
.WithPageToken(null)
.WithLimit(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeAwaits(
new Gs2Exchange.DescribeAwaitsRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withRateName("material_n_to_r")
.withPageToken(null)
.withLimit(null)
);
const items = result.getItems();
const nextPageToken = result.getNextPageToken();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_awaits(
exchange.DescribeAwaitsRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
.with_rate_name('material_n_to_r')
.with_page_token(None)
.with_limit(None)
)
items = result.items
next_page_token = result.next_page_token
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_awaits({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
rateName="material_n_to_r",
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('exchange')
api_result_handler = client.describe_awaits_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
rateName="material_n_to_r",
pageToken=nil,
limit=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;describeAwaitsByUserId
Get a list of Exchange Awaits by specifying a user ID
Retrieves a paginated list of exchange await records for the specified user. Optionally filter by rate name to retrieve only awaits for a specific exchange rate. Each await record includes the rate name, exchange count, skip seconds, and timing information.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| rateName | string | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| items | List<Await> | List of Exchange Awaits |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeAwaitsByUserId(
&exchange.DescribeAwaitsByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
RateName: pointy.String("material_n_to_r"),
PageToken: nil,
Limit: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeAwaitsByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeAwaitsByUserId(
(new DescribeAwaitsByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withRateName("material_n_to_r")
->withPageToken(null)
->withLimit(null)
->withTimeOffsetToken(null)
);
$items = $result->getItems();
$nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeAwaitsByUserIdRequest;
import io.gs2.exchange.result.DescribeAwaitsByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeAwaitsByUserIdResult result = client.describeAwaitsByUserId(
new DescribeAwaitsByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withRateName("material_n_to_r")
.withPageToken(null)
.withLimit(null)
.withTimeOffsetToken(null)
);
List<Await> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeAwaitsByUserIdResult> asyncResult = null;
yield return client.DescribeAwaitsByUserId(
new Gs2.Gs2Exchange.Request.DescribeAwaitsByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithRateName("material_n_to_r")
.WithPageToken(null)
.WithLimit(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeAwaitsByUserId(
new Gs2Exchange.DescribeAwaitsByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withRateName("material_n_to_r")
.withPageToken(null)
.withLimit(null)
.withTimeOffsetToken(null)
);
const items = result.getItems();
const nextPageToken = result.getNextPageToken();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_awaits_by_user_id(
exchange.DescribeAwaitsByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_rate_name('material_n_to_r')
.with_page_token(None)
.with_limit(None)
.with_time_offset_token(None)
)
items = result.items
next_page_token = result.next_page_token
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_awaits_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
rateName="material_n_to_r",
pageToken=nil,
limit=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('exchange')
api_result_handler = client.describe_awaits_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
rateName="material_n_to_r",
pageToken=nil,
limit=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;getAwait
Get Exchange Await
Retrieves the detailed information of a specific exchange await record for the authenticated user. The returned await includes the rate name, exchange count, current skip seconds, and creation/acquisition timing.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetAwait(
&exchange.GetAwaitRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
AwaitName: pointy.String("await-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetAwaitRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getAwait(
(new GetAwaitRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-0001")
->withAwaitName("await-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetAwaitRequest;
import io.gs2.exchange.result.GetAwaitResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetAwaitResult result = client.getAwait(
new GetAwaitRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withAwaitName("await-0001")
);
Await item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetAwaitResult> asyncResult = null;
yield return client.GetAwait(
new Gs2.Gs2Exchange.Request.GetAwaitRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-0001")
.WithAwaitName("await-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getAwait(
new Gs2Exchange.GetAwaitRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withAwaitName("await-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_await(
exchange.GetAwaitRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
.with_await_name('await-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_await({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
awaitName="await-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_await_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
awaitName="await-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getAwaitByUserId
Get Exchange Await by specifying a user ID
Retrieves the detailed information of a specific exchange await record for the specified user. The returned await includes the rate name, exchange count, current skip seconds, and creation/acquisition timing.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetAwaitByUserId(
&exchange.GetAwaitByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
AwaitName: pointy.String("await-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetAwaitByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getAwaitByUserId(
(new GetAwaitByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withAwaitName("await-0001")
->withTimeOffsetToken(null)
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetAwaitByUserIdRequest;
import io.gs2.exchange.result.GetAwaitByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetAwaitByUserIdResult result = client.getAwaitByUserId(
new GetAwaitByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withTimeOffsetToken(null)
);
Await item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetAwaitByUserIdResult> asyncResult = null;
yield return client.GetAwaitByUserId(
new Gs2.Gs2Exchange.Request.GetAwaitByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithAwaitName("await-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getAwaitByUserId(
new Gs2Exchange.GetAwaitByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_await_by_user_id(
exchange.GetAwaitByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_await_name('await-0001')
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_await_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_await_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;acquire
Receive rewards for Exchange Await
Acquires the rewards for a completed exchange await. The await must have passed its lock time (adjusted by any skip seconds) before rewards can be claimed. The provided config values are merged with the default config set at await creation time. A transaction (transaction) is issued to execute the acquire actions defined in the rate model.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |
| config | List<Config> | [] | 0 ~ 32 items | Configuration values applied to transaction variables |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the reward acquisition process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.Acquire(
&exchange.AcquireRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
AwaitName: pointy.String("await-0001"),
Config: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\AcquireRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->acquire(
(new AcquireRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-0001")
->withAwaitName("await-0001")
->withConfig(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.AcquireRequest;
import io.gs2.exchange.result.AcquireResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
AcquireResult result = client.acquire(
new AcquireRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withAwaitName("await-0001")
.withConfig(null)
);
Await item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.AcquireResult> asyncResult = null;
yield return client.Acquire(
new Gs2.Gs2Exchange.Request.AcquireRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-0001")
.WithAwaitName("await-0001")
.WithConfig(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.acquire(
new Gs2Exchange.AcquireRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withAwaitName("await-0001")
.withConfig(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.acquire(
exchange.AcquireRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
.with_await_name('await-0001')
.with_config(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.acquire({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
awaitName="await-0001",
config=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.acquire_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
awaitName="await-0001",
config=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;acquireByUserId
Receive rewards for Exchange Await by specifying a user ID
Acquires the rewards for a completed exchange await for the specified user. The await must have passed its lock time (adjusted by any skip seconds) before rewards can be claimed. The provided config values are merged with the default config set at await creation time. A transaction (transaction) is issued to execute the acquire actions defined in the rate model.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |
| config | List<Config> | [] | 0 ~ 32 items | Configuration values applied to transaction variables | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the reward acquisition process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.AcquireByUserId(
&exchange.AcquireByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
AwaitName: pointy.String("await-0001"),
Config: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\AcquireByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->acquireByUserId(
(new AcquireByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withAwaitName("await-0001")
->withConfig(null)
->withTimeOffsetToken(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.AcquireByUserIdRequest;
import io.gs2.exchange.result.AcquireByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
AcquireByUserIdResult result = client.acquireByUserId(
new AcquireByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withConfig(null)
.withTimeOffsetToken(null)
);
Await item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.AcquireByUserIdResult> asyncResult = null;
yield return client.AcquireByUserId(
new Gs2.Gs2Exchange.Request.AcquireByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithAwaitName("await-0001")
.WithConfig(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.acquireByUserId(
new Gs2Exchange.AcquireByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withConfig(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.acquire_by_user_id(
exchange.AcquireByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_await_name('await-0001')
.with_config(None)
.with_time_offset_token(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.acquire_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
config=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.acquire_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
config=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;acquireForceByUserId
Receive rewards for Exchange Await without waiting for the lock time
Force-acquires the rewards for an exchange await regardless of whether the lock time has elapsed. This bypasses the normal wait time check, allowing immediate reward acquisition. The provided config values are merged with the default config set at await creation time. A transaction (transaction) is issued to execute the acquire actions defined in the rate model.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |
| config | List<Config> | [] | 0 ~ 32 items | Configuration values applied to transaction variables | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
| transactionId | string | Issued transaction ID |
| stampSheet | string | Stamp sheet used to execute the reward acquisition process |
| stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
| autoRunStampSheet | bool? | Whether automatic transaction execution is enabled |
| atomicCommit | bool? | Whether to commit the transaction atomically |
| transaction | string | Issued transaction |
| transactionResult | TransactionResult | Transaction execution result |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.AcquireForceByUserId(
&exchange.AcquireForceByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
AwaitName: pointy.String("await-0001"),
Config: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Item
transactionId := result.TransactionId
stampSheet := result.StampSheet
stampSheetEncryptionKeyId := result.StampSheetEncryptionKeyId
autoRunStampSheet := result.AutoRunStampSheet
atomicCommit := result.AtomicCommit
transaction := result.Transaction
transactionResult := result.TransactionResultuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\AcquireForceByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->acquireForceByUserId(
(new AcquireForceByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withAwaitName("await-0001")
->withConfig(null)
->withTimeOffsetToken(null)
);
$item = $result->getItem();
$transactionId = $result->getTransactionId();
$stampSheet = $result->getStampSheet();
$stampSheetEncryptionKeyId = $result->getStampSheetEncryptionKeyId();
$autoRunStampSheet = $result->getAutoRunStampSheet();
$atomicCommit = $result->getAtomicCommit();
$transaction = $result->getTransaction();
$transactionResult = $result->getTransactionResult();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.AcquireForceByUserIdRequest;
import io.gs2.exchange.result.AcquireForceByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
AcquireForceByUserIdResult result = client.acquireForceByUserId(
new AcquireForceByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withConfig(null)
.withTimeOffsetToken(null)
);
Await item = result.getItem();
String transactionId = result.getTransactionId();
String stampSheet = result.getStampSheet();
String stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
boolean autoRunStampSheet = result.getAutoRunStampSheet();
boolean atomicCommit = result.getAtomicCommit();
String transaction = result.getTransaction();
TransactionResult transactionResult = result.getTransactionResult();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.AcquireForceByUserIdResult> asyncResult = null;
yield return client.AcquireForceByUserId(
new Gs2.Gs2Exchange.Request.AcquireForceByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithAwaitName("await-0001")
.WithConfig(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
var atomicCommit = result.AtomicCommit;
var transaction = result.Transaction;
var transactionResult = result.TransactionResult;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.acquireForceByUserId(
new Gs2Exchange.AcquireForceByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withConfig(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
const transactionId = result.getTransactionId();
const stampSheet = result.getStampSheet();
const stampSheetEncryptionKeyId = result.getStampSheetEncryptionKeyId();
const autoRunStampSheet = result.getAutoRunStampSheet();
const atomicCommit = result.getAtomicCommit();
const transaction = result.getTransaction();
const transactionResult = result.getTransactionResult();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.acquire_force_by_user_id(
exchange.AcquireForceByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_await_name('await-0001')
.with_config(None)
.with_time_offset_token(None)
)
item = result.item
transaction_id = result.transaction_id
stamp_sheet = result.stamp_sheet
stamp_sheet_encryption_key_id = result.stamp_sheet_encryption_key_id
auto_run_stamp_sheet = result.auto_run_stamp_sheet
atomic_commit = result.atomic_commit
transaction = result.transaction
transaction_result = result.transaction_result
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.acquire_force_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
config=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;client = gs2('exchange')
api_result_handler = client.acquire_force_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
config=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;
transactionId = result.transactionId;
stampSheet = result.stampSheet;
stampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
autoRunStampSheet = result.autoRunStampSheet;
atomicCommit = result.atomicCommit;
transaction = result.transaction;
transactionResult = result.transactionResult;skipByUserId
Skip Exchange Await by specifying a user ID
Accelerates or skips the waiting time of an exchange await. Supports four skip types: ‘complete’ skips the entire remaining wait, ‘minutes’ adds the specified minutes to skip seconds, ’totalRate’ skips a percentage of the total lock time, and ‘remainRate’ skips a percentage of the remaining wait time. The skip seconds are capped at the total lock time and cannot exceed it.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||||
| userId | string | ✓ | ~ 128 chars | User ID | ||||||||||||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |||||||||||
| skipType | String Enum enum { “complete”, “minutes”, “totalRate”, “remainRate” } | “complete” | Skip type
| |||||||||||||
| minutes | int | {skipType} == “minutes” | 0 ~ 2147483646 | Minutes to skip * Applicable only if skipType is “minutes” | ||||||||||||
| rate | float | {skipType} == “totalRate” or {skipType} == “remainRate” | 0 ~ 1 | Percentage of time to skip | ||||||||||||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.SkipByUserId(
&exchange.SkipByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
AwaitName: pointy.String("await-0001"),
SkipType: nil,
Minutes: nil,
Rate: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\SkipByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->skipByUserId(
(new SkipByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withAwaitName("await-0001")
->withSkipType(null)
->withMinutes(null)
->withRate(null)
->withTimeOffsetToken(null)
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.SkipByUserIdRequest;
import io.gs2.exchange.result.SkipByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
SkipByUserIdResult result = client.skipByUserId(
new SkipByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withSkipType(null)
.withMinutes(null)
.withRate(null)
.withTimeOffsetToken(null)
);
Await item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.SkipByUserIdResult> asyncResult = null;
yield return client.SkipByUserId(
new Gs2.Gs2Exchange.Request.SkipByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithAwaitName("await-0001")
.WithSkipType(null)
.WithMinutes(null)
.WithRate(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.skipByUserId(
new Gs2Exchange.SkipByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withSkipType(null)
.withMinutes(null)
.withRate(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.skip_by_user_id(
exchange.SkipByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_await_name('await-0001')
.with_skip_type(None)
.with_minutes(None)
.with_rate(None)
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.skip_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
skipType=nil,
minutes=nil,
rate=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.skip_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
skipType=nil,
minutes=nil,
rate=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteAwait
Delete Exchange Await
Deletes an exchange await record for the authenticated user. This cancels the pending exchange, and any rewards that have not yet been acquired are forfeited.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DeleteAwait(
&exchange.DeleteAwaitRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
AwaitName: pointy.String("await-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DeleteAwaitRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->deleteAwait(
(new DeleteAwaitRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-0001")
->withAwaitName("await-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DeleteAwaitRequest;
import io.gs2.exchange.result.DeleteAwaitResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DeleteAwaitResult result = client.deleteAwait(
new DeleteAwaitRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withAwaitName("await-0001")
);
Await item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DeleteAwaitResult> asyncResult = null;
yield return client.DeleteAwait(
new Gs2.Gs2Exchange.Request.DeleteAwaitRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-0001")
.WithAwaitName("await-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.deleteAwait(
new Gs2Exchange.DeleteAwaitRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withAwaitName("await-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.delete_await(
exchange.DeleteAwaitRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
.with_await_name('await-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.delete_await({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
awaitName="await-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.delete_await_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
awaitName="await-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteAwaitByUserId
Delete Exchange Await by specifying a user ID
Deletes an exchange await record for the specified user. This cancels the pending exchange, and any rewards that have not yet been acquired are forfeited.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| awaitName | string | ✓ | UUID | ~ 36 chars | Exchange Await name Maintains a unique name for each Exchange Await. The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each Exchange Await. | |
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Await | Exchange Await |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DeleteAwaitByUserId(
&exchange.DeleteAwaitByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
AwaitName: pointy.String("await-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DeleteAwaitByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->deleteAwaitByUserId(
(new DeleteAwaitByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withAwaitName("await-0001")
->withTimeOffsetToken(null)
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DeleteAwaitByUserIdRequest;
import io.gs2.exchange.result.DeleteAwaitByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DeleteAwaitByUserIdResult result = client.deleteAwaitByUserId(
new DeleteAwaitByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withTimeOffsetToken(null)
);
Await item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DeleteAwaitByUserIdResult> asyncResult = null;
yield return client.DeleteAwaitByUserId(
new Gs2.Gs2Exchange.Request.DeleteAwaitByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithAwaitName("await-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.deleteAwaitByUserId(
new Gs2Exchange.DeleteAwaitByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAwaitName("await-0001")
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.delete_await_by_user_id(
exchange.DeleteAwaitByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_await_name('await-0001')
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.delete_await_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.delete_await_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
awaitName="await-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;describeRateModels
Get a list of Exchange Rate Models
Retrieves the list of currently active (published) Exchange Rate Models in the specified namespace. Each Rate Model defines the exchange configuration including timing type (immediate or await), lock time for await exchanges, and the consume/verify/acquire actions that are executed during the exchange. Only models that have been activated via the CurrentRateMaster are returned.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| items | List<RateModel> | List of Exchange Rate Models |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeRateModels(
&exchange.DescribeRateModelsRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
items := result.Itemsuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeRateModelsRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeRateModels(
(new DescribeRateModelsRequest())
->withNamespaceName("namespace-0001")
);
$items = $result->getItems();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeRateModelsRequest;
import io.gs2.exchange.result.DescribeRateModelsResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeRateModelsResult result = client.describeRateModels(
new DescribeRateModelsRequest()
.withNamespaceName("namespace-0001")
);
List<RateModel> items = result.getItems();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeRateModelsResult> asyncResult = null;
yield return client.DescribeRateModels(
new Gs2.Gs2Exchange.Request.DescribeRateModelsRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeRateModels(
new Gs2Exchange.DescribeRateModelsRequest()
.withNamespaceName("namespace-0001")
);
const items = result.getItems();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_rate_models(
exchange.DescribeRateModelsRequest()
.with_namespace_name('namespace-0001')
)
items = result.items
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_rate_models({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;client = gs2('exchange')
api_result_handler = client.describe_rate_models_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;getRateModel
Get Exchange Rate Model
Retrieves the detailed information of a specific currently active Exchange Rate Model by name. The returned model includes the timing type, lock time, and the consume/verify/acquire actions that define the exchange behavior.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | RateModel | Exchange Rate Model |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetRateModel(
&exchange.GetRateModelRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("character-level"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetRateModelRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getRateModel(
(new GetRateModelRequest())
->withNamespaceName("namespace-0001")
->withRateName("character-level")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetRateModelRequest;
import io.gs2.exchange.result.GetRateModelResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetRateModelResult result = client.getRateModel(
new GetRateModelRequest()
.withNamespaceName("namespace-0001")
.withRateName("character-level")
);
RateModel item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetRateModelResult> asyncResult = null;
yield return client.GetRateModel(
new Gs2.Gs2Exchange.Request.GetRateModelRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("character-level"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getRateModel(
new Gs2Exchange.GetRateModelRequest()
.withNamespaceName("namespace-0001")
.withRateName("character-level")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_rate_model(
exchange.GetRateModelRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('character-level')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_rate_model({
namespaceName="namespace-0001",
rateName="character-level",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_rate_model_async({
namespaceName="namespace-0001",
rateName="character-level",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;describeIncrementalRateModels
Get a list of Incremental Cost Exchange Rate Models
Retrieves the list of currently active (published) Incremental Cost Exchange Rate Models in the specified namespace. Each model defines an exchange where the cost increases progressively with each execution, including the consume action, calculation type (linear or GS2-Script), base/coefficient values, and acquire actions. Only models that have been activated via the CurrentRateMaster are returned.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| items | List<IncrementalRateModel> | List of Incremental Cost Exchange Rate Models |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeIncrementalRateModels(
&exchange.DescribeIncrementalRateModelsRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
items := result.Itemsuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeIncrementalRateModelsRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeIncrementalRateModels(
(new DescribeIncrementalRateModelsRequest())
->withNamespaceName("namespace-0001")
);
$items = $result->getItems();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeIncrementalRateModelsRequest;
import io.gs2.exchange.result.DescribeIncrementalRateModelsResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeIncrementalRateModelsResult result = client.describeIncrementalRateModels(
new DescribeIncrementalRateModelsRequest()
.withNamespaceName("namespace-0001")
);
List<IncrementalRateModel> items = result.getItems();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeIncrementalRateModelsResult> asyncResult = null;
yield return client.DescribeIncrementalRateModels(
new Gs2.Gs2Exchange.Request.DescribeIncrementalRateModelsRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeIncrementalRateModels(
new Gs2Exchange.DescribeIncrementalRateModelsRequest()
.withNamespaceName("namespace-0001")
);
const items = result.getItems();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_incremental_rate_models(
exchange.DescribeIncrementalRateModelsRequest()
.with_namespace_name('namespace-0001')
)
items = result.items
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_incremental_rate_models({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;client = gs2('exchange')
api_result_handler = client.describe_incremental_rate_models_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;getIncrementalRateModel
Get an Incremental Cost Exchange Rate Model
Retrieves the detailed information of a specific currently active Incremental Cost Exchange Rate Model by name. The returned model includes the consume action, calculation type, base value, coefficient value, exchange count ID, maximum exchange count, and acquire actions.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModel | Incremental Cost Exchange Rate Model |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetIncrementalRateModel(
&exchange.GetIncrementalRateModelRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("character-level"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetIncrementalRateModelRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getIncrementalRateModel(
(new GetIncrementalRateModelRequest())
->withNamespaceName("namespace-0001")
->withRateName("character-level")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetIncrementalRateModelRequest;
import io.gs2.exchange.result.GetIncrementalRateModelResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetIncrementalRateModelResult result = client.getIncrementalRateModel(
new GetIncrementalRateModelRequest()
.withNamespaceName("namespace-0001")
.withRateName("character-level")
);
IncrementalRateModel item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetIncrementalRateModelResult> asyncResult = null;
yield return client.GetIncrementalRateModel(
new Gs2.Gs2Exchange.Request.GetIncrementalRateModelRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("character-level"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getIncrementalRateModel(
new Gs2Exchange.GetIncrementalRateModelRequest()
.withNamespaceName("namespace-0001")
.withRateName("character-level")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_incremental_rate_model(
exchange.GetIncrementalRateModelRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('character-level')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_incremental_rate_model({
namespaceName="namespace-0001",
rateName="character-level",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_incremental_rate_model_async({
namespaceName="namespace-0001",
rateName="character-level",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;exportMaster
Export Rate Model Master in a master data format that can be activated
Exports the current Rate Model Master data (both Exchange Rate Models and Incremental Cost Exchange Rate Models) in a format that can be used for activation. The exported data can be used to back up the current master configuration, or to import it into another namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | CurrentRateMaster | Rate Model master data that can be activated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.ExportMaster(
&exchange.ExportMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\ExportMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->exportMaster(
(new ExportMasterRequest())
->withNamespaceName("namespace-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.ExportMasterRequest;
import io.gs2.exchange.result.ExportMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
ExportMasterResult result = client.exportMaster(
new ExportMasterRequest()
.withNamespaceName("namespace-0001")
);
CurrentRateMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.ExportMasterResult> asyncResult = null;
yield return client.ExportMaster(
new Gs2.Gs2Exchange.Request.ExportMasterRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.exportMaster(
new Gs2Exchange.ExportMasterRequest()
.withNamespaceName("namespace-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.export_master(
exchange.ExportMasterRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.export_master({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.export_master_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getCurrentRateMaster
Get currently active Rate Model master data
Retrieves the master data of the Rate Models (both Exchange Rate Models and Incremental Cost Exchange Rate Models) that are currently active (published) in the specified namespace. This represents the configuration that is actually being used in production, as opposed to the editable master data.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | CurrentRateMaster | Currently Active Rate Model Master Data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetCurrentRateMaster(
&exchange.GetCurrentRateMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetCurrentRateMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getCurrentRateMaster(
(new GetCurrentRateMasterRequest())
->withNamespaceName("namespace-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetCurrentRateMasterRequest;
import io.gs2.exchange.result.GetCurrentRateMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetCurrentRateMasterResult result = client.getCurrentRateMaster(
new GetCurrentRateMasterRequest()
.withNamespaceName("namespace-0001")
);
CurrentRateMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetCurrentRateMasterResult> asyncResult = null;
yield return client.GetCurrentRateMaster(
new Gs2.Gs2Exchange.Request.GetCurrentRateMasterRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getCurrentRateMaster(
new Gs2Exchange.GetCurrentRateMasterRequest()
.withNamespaceName("namespace-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_current_rate_master(
exchange.GetCurrentRateMasterRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_current_rate_master({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_current_rate_master_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;preUpdateCurrentRateMaster
Update Currently Active Rate Model Master Data (3-phase version)
When uploading master data larger than 1MB, the update is performed in 3 phases.
- Execute this API to obtain a token and URL for uploading.
- Upload the master data to the obtained URL.
- Execute UpdateCurrentModelMaster by passing the token obtained from the the upload to reflect the master data.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| uploadToken | string | Token used to reflect results after upload |
| uploadUrl | string | URL used to upload |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.PreUpdateCurrentRateMaster(
&exchange.PreUpdateCurrentRateMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\PreUpdateCurrentRateMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->preUpdateCurrentRateMaster(
(new PreUpdateCurrentRateMasterRequest())
->withNamespaceName("namespace-0001")
);
$uploadToken = $result->getUploadToken();
$uploadUrl = $result->getUploadUrl();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.PreUpdateCurrentRateMasterRequest;
import io.gs2.exchange.result.PreUpdateCurrentRateMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
PreUpdateCurrentRateMasterResult result = client.preUpdateCurrentRateMaster(
new PreUpdateCurrentRateMasterRequest()
.withNamespaceName("namespace-0001")
);
String uploadToken = result.getUploadToken();
String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.PreUpdateCurrentRateMasterResult> asyncResult = null;
yield return client.PreUpdateCurrentRateMaster(
new Gs2.Gs2Exchange.Request.PreUpdateCurrentRateMasterRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.preUpdateCurrentRateMaster(
new Gs2Exchange.PreUpdateCurrentRateMasterRequest()
.withNamespaceName("namespace-0001")
);
const uploadToken = result.getUploadToken();
const uploadUrl = result.getUploadUrl();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.pre_update_current_rate_master(
exchange.PreUpdateCurrentRateMasterRequest()
.with_namespace_name('namespace-0001')
)
upload_token = result.upload_token
upload_url = result.upload_url
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.pre_update_current_rate_master({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;client = gs2('exchange')
api_result_handler = client.pre_update_current_rate_master_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;updateCurrentRateMaster
Update Currently Active Rate Model Master Data
Updates and activates (publishes) the master data of the Rate Models in the specified namespace. Supports two modes: ‘direct’ mode for inline master data, and ‘preUpload’ mode for master data that was uploaded in advance. For master data larger than 1MB, use the 3-phase update flow: PreUpdate -> Upload -> Update (preUpload mode). The uploaded master data is validated before being applied.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| mode | String Enum enum { “direct”, “preUpload” } | “direct” | Update mode
| |||||||||
| settings | string | {mode} == “direct” | ✓* | ~ 5242880 chars | Master Data * Required if mode is “direct” | |||||||
| uploadToken | string | {mode} == “preUpload” | ✓* | ~ 1024 chars | Token obtained by pre-upload Used to apply the uploaded master data. * Required if mode is “preUpload” |
Result
| Type | Description | |
|---|---|---|
| item | CurrentRateMaster | Updated master data of the currently active Rate Models |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.UpdateCurrentRateMaster(
&exchange.UpdateCurrentRateMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
Mode: pointy.String("direct"),
Settings: pointy.String("{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}"),
UploadToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\UpdateCurrentRateMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->updateCurrentRateMaster(
(new UpdateCurrentRateMasterRequest())
->withNamespaceName("namespace-0001")
->withMode("direct")
->withSettings("{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}")
->withUploadToken(null)
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.UpdateCurrentRateMasterRequest;
import io.gs2.exchange.result.UpdateCurrentRateMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
UpdateCurrentRateMasterResult result = client.updateCurrentRateMaster(
new UpdateCurrentRateMasterRequest()
.withNamespaceName("namespace-0001")
.withMode("direct")
.withSettings("{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}")
.withUploadToken(null)
);
CurrentRateMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.UpdateCurrentRateMasterResult> asyncResult = null;
yield return client.UpdateCurrentRateMaster(
new Gs2.Gs2Exchange.Request.UpdateCurrentRateMasterRequest()
.WithNamespaceName("namespace-0001")
.WithMode("direct")
.WithSettings("{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}")
.WithUploadToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.updateCurrentRateMaster(
new Gs2Exchange.UpdateCurrentRateMasterRequest()
.withNamespaceName("namespace-0001")
.withMode("direct")
.withSettings("{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}")
.withUploadToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.update_current_rate_master(
exchange.UpdateCurrentRateMasterRequest()
.with_namespace_name('namespace-0001')
.with_mode('direct')
.with_settings('{\n "version": "2019-08-19",\n "rateModels": [\n {\n "name": "material_n_to_r",\n "metadata": "N2R",\n "timingType": "await",\n "enableSkip": false,\n "lockTime": 50,\n "consumeActions": [\n {\n "action": "Gs2Inventory:ConsumeItemSetByUserId",\n "request": "{\\"namespaceName\\": \\"namespace-0001\\", \\"inventoryName\\": \\"inventory-0001\\", \\"itemName\\": \\"item-0001\\", \\"userId\\": \\"#{userId}\\", \\"consumeCount\\": 10}"\n }\n ],\n "acquireActions": [\n {\n "action": "Gs2Inventory:AcquireItemSetByUserId",\n "request": "{\\"namespaceName\\": \\"namespace-0001\\", \\"inventoryName\\": \\"inventory-0001\\", \\"itemName\\": \\"item-0002\\", \\"userId\\": \\"#{userId}\\", \\"acquireCount\\": 1}"\n }\n ]\n },\n {\n "name": "material_r_to_n",\n "metadata": "N2R",\n "timingType": "await",\n "enableSkip": false,\n "lockTime": 50,\n "consumeActions": [\n {\n "action": "Gs2Inventory:ConsumeItemSetByUserId",\n "request": "{\\"namespaceName\\": \\"namespace-0001\\", \\"inventoryName\\": \\"inventory-0001\\", \\"itemName\\": \\"item-0002\\", \\"userId\\": \\"#{userId}\\", \\"consumeCount\\": 1}"\n }\n ],\n "acquireActions": [\n {\n "action": "Gs2Inventory:AcquireItemSetByUserId",\n "request": "{\\"namespaceName\\": \\"category-0001\\", \\"inventoryName\\": \\"item\\", \\"itemName\\": \\"item-0001\\", \\"userId\\": \\"#{userId}\\", \\"acquireCount\\": 10}"\n }\n ]\n }\n ]\n}')
.with_upload_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.update_current_rate_master({
namespaceName="namespace-0001",
mode="direct",
settings="{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}",
uploadToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.update_current_rate_master_async({
namespaceName="namespace-0001",
mode="direct",
settings="{\n \"version\": \"2019-08-19\",\n \"rateModels\": [\n {\n \"name\": \"material_n_to_r\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 10}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 1}\"\n }\n ]\n },\n {\n \"name\": \"material_r_to_n\",\n \"metadata\": \"N2R\",\n \"timingType\": \"await\",\n \"enableSkip\": false,\n \"lockTime\": 50,\n \"consumeActions\": [\n {\n \"action\": \"Gs2Inventory:ConsumeItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"namespace-0001\\\", \\\"inventoryName\\\": \\\"inventory-0001\\\", \\\"itemName\\\": \\\"item-0002\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"consumeCount\\\": 1}\"\n }\n ],\n \"acquireActions\": [\n {\n \"action\": \"Gs2Inventory:AcquireItemSetByUserId\",\n \"request\": \"{\\\"namespaceName\\\": \\\"category-0001\\\", \\\"inventoryName\\\": \\\"item\\\", \\\"itemName\\\": \\\"item-0001\\\", \\\"userId\\\": \\\"#{userId}\\\", \\\"acquireCount\\\": 10}\"\n }\n ]\n }\n ]\n}",
uploadToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;updateCurrentRateMasterFromGitHub
Update Currently Active Rate Model Master Data from GitHub
Updates and activates (publishes) the master data by fetching it directly from a GitHub repository. The checkout settings specify the repository, branch/tag, and file path to use. This is useful for managing master data in version control and deploying it directly.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| checkoutSetting | GitHubCheckoutSetting | ✓ | Setup to check out master data from GitHub |
Result
| Type | Description | |
|---|---|---|
| item | CurrentRateMaster | Updated master data of the currently active Rate Models |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.UpdateCurrentRateMasterFromGitHub(
&exchange.UpdateCurrentRateMasterFromGitHubRequest {
NamespaceName: pointy.String("namespace-0001"),
CheckoutSetting: &exchange.GitHubCheckoutSetting{
ApiKeyId: pointy.String("apiKeyId-0001"),
RepositoryName: pointy.String("gs2io/master-data"),
SourcePath: pointy.String("path/to/file.json"),
ReferenceType: pointy.String("branch"),
BranchName: pointy.String("develop"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\UpdateCurrentRateMasterFromGitHubRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->updateCurrentRateMasterFromGitHub(
(new UpdateCurrentRateMasterFromGitHubRequest())
->withNamespaceName("namespace-0001")
->withCheckoutSetting((new GitHubCheckoutSetting())
->withApiKeyId("apiKeyId-0001")
->withRepositoryName("gs2io/master-data")
->withSourcePath("path/to/file.json")
->withReferenceType("branch")
->withBranchName("develop")
)
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.UpdateCurrentRateMasterFromGitHubRequest;
import io.gs2.exchange.result.UpdateCurrentRateMasterFromGitHubResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
UpdateCurrentRateMasterFromGitHubResult result = client.updateCurrentRateMasterFromGitHub(
new UpdateCurrentRateMasterFromGitHubRequest()
.withNamespaceName("namespace-0001")
.withCheckoutSetting(new GitHubCheckoutSetting()
.withApiKeyId("apiKeyId-0001")
.withRepositoryName("gs2io/master-data")
.withSourcePath("path/to/file.json")
.withReferenceType("branch")
.withBranchName("develop")
)
);
CurrentRateMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.UpdateCurrentRateMasterFromGitHubResult> asyncResult = null;
yield return client.UpdateCurrentRateMasterFromGitHub(
new Gs2.Gs2Exchange.Request.UpdateCurrentRateMasterFromGitHubRequest()
.WithNamespaceName("namespace-0001")
.WithCheckoutSetting(new Gs2.Gs2Exchange.Model.GitHubCheckoutSetting()
.WithApiKeyId("apiKeyId-0001")
.WithRepositoryName("gs2io/master-data")
.WithSourcePath("path/to/file.json")
.WithReferenceType("branch")
.WithBranchName("develop")
),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.updateCurrentRateMasterFromGitHub(
new Gs2Exchange.UpdateCurrentRateMasterFromGitHubRequest()
.withNamespaceName("namespace-0001")
.withCheckoutSetting(new Gs2Exchange.model.GitHubCheckoutSetting()
.withApiKeyId("apiKeyId-0001")
.withRepositoryName("gs2io/master-data")
.withSourcePath("path/to/file.json")
.withReferenceType("branch")
.withBranchName("develop")
)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.update_current_rate_master_from_git_hub(
exchange.UpdateCurrentRateMasterFromGitHubRequest()
.with_namespace_name('namespace-0001')
.with_checkout_setting(exchange.GitHubCheckoutSetting()
.with_api_key_id('apiKeyId-0001')
.with_repository_name('gs2io/master-data')
.with_source_path('path/to/file.json')
.with_reference_type('branch')
.with_branch_name('develop')
)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.update_current_rate_master_from_git_hub({
namespaceName="namespace-0001",
checkoutSetting={
api_key_id="apiKeyId-0001",
repository_name="gs2io/master-data",
source_path="path/to/file.json",
reference_type="branch",
branch_name="develop",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.update_current_rate_master_from_git_hub_async({
namespaceName="namespace-0001",
checkoutSetting={
api_key_id="apiKeyId-0001",
repository_name="gs2io/master-data",
source_path="path/to/file.json",
reference_type="branch",
branch_name="develop",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;describeRateModelMasters
Get a list of Exchange Rate Model Masters
Retrieves a paginated list of editable Exchange Rate Model Masters with optional name prefix filtering. Exchange Rate Model Masters are the editable definitions for exchange rate configurations. Changes to masters do not take effect until the master data is activated via the CurrentRateMaster API.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| namePrefix | string | ~ 64 chars | Filter by exchange rate name prefix | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<RateModelMaster> | List of Exchange Rate Model Master |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeRateModelMasters(
&exchange.DescribeRateModelMastersRequest {
NamespaceName: pointy.String("namespace-0001"),
NamePrefix: nil,
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeRateModelMastersRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeRateModelMasters(
(new DescribeRateModelMastersRequest())
->withNamespaceName("namespace-0001")
->withNamePrefix(null)
->withPageToken(null)
->withLimit(null)
);
$items = $result->getItems();
$nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeRateModelMastersRequest;
import io.gs2.exchange.result.DescribeRateModelMastersResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeRateModelMastersResult result = client.describeRateModelMasters(
new DescribeRateModelMastersRequest()
.withNamespaceName("namespace-0001")
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
List<RateModelMaster> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeRateModelMastersResult> asyncResult = null;
yield return client.DescribeRateModelMasters(
new Gs2.Gs2Exchange.Request.DescribeRateModelMastersRequest()
.WithNamespaceName("namespace-0001")
.WithNamePrefix(null)
.WithPageToken(null)
.WithLimit(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeRateModelMasters(
new Gs2Exchange.DescribeRateModelMastersRequest()
.withNamespaceName("namespace-0001")
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
const items = result.getItems();
const nextPageToken = result.getNextPageToken();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_rate_model_masters(
exchange.DescribeRateModelMastersRequest()
.with_namespace_name('namespace-0001')
.with_name_prefix(None)
.with_page_token(None)
.with_limit(None)
)
items = result.items
next_page_token = result.next_page_token
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_rate_model_masters({
namespaceName="namespace-0001",
namePrefix=nil,
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('exchange')
api_result_handler = client.describe_rate_model_masters_async({
namespaceName="namespace-0001",
namePrefix=nil,
pageToken=nil,
limit=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;createRateModelMaster
Create a new Exchange Rate Model Master
Creates a new editable Exchange Rate Model Master definition. The rate model defines the timing type (‘immediate’ for instant exchange, ‘await’ for time-delayed exchange), lock time for await exchanges, and the consume/verify/acquire actions that are executed during the exchange. Changes do not take effect until the master data is activated via the CurrentRateMaster API.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| name | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| description | string | ~ 1024 chars | Description | |||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||
| timingType | String Enum enum { “immediate”, “await” } | “immediate” | Type of exchange Determines when rewards are delivered after performing the exchange. immediate delivers rewards instantly upon exchange execution. await requires real-time to elapse before rewards can be claimed, creating a waiting period (e.g., crafting time).
| |||||||||
| lockTime | int | {timingType} == “await” | ✓* | 0 ~ 538214400 | Waiting time (minutes) from the execution of the exchange until the reward is actually received Only applicable when timingType is await. Specifies the number of minutes that must elapse in real time after the exchange is initiated before the player can claim the rewards. The waiting time can be shortened by using the skip mechanism.* Required if timingType is “await” | |||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the exchange. Multiple acquire actions can be specified to grant various resource types simultaneously. These actions are executed as acquire actions within a distributed transaction. | ||||||||
| verifyActions | List<VerifyAction> | [] | 0 ~ 10 items | List of Verify Actions Precondition checks that must all pass before the exchange is executed. If any verify action fails, the exchange is aborted without consuming resources. Used to enforce conditions such as level requirements or inventory capacity. | ||||||||
| consumeActions | List<ConsumeAction> | [] | 0 ~ 10 items | List of Consume Actions Defines the resources (cost) that the player must pay to perform this exchange. Multiple consume actions can be specified, allowing complex exchange costs such as requiring both gold and items. These actions are executed as consume actions within a distributed transaction. |
Result
| Type | Description | |
|---|---|---|
| item | RateModelMaster | Exchange Rate Model Master created |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CreateRateModelMaster(
&exchange.CreateRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
Name: pointy.String("rate-0001"),
Description: nil,
Metadata: pointy.String("N2R"),
TimingType: nil,
LockTime: nil,
AcquireActions: []exchange.AcquireAction{
exchange.AcquireAction{
Action: pointy.String("Gs2Inventory:AcquireItemSetByUserId"),
Request: pointy.String("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
},
},
VerifyActions: nil,
ConsumeActions: []exchange.ConsumeAction{
exchange.ConsumeAction{
Action: pointy.String("Gs2Inventory:ConsumeItemSetByUserId"),
Request: pointy.String("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"),
},
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CreateRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->createRateModelMaster(
(new CreateRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withName("rate-0001")
->withDescription(null)
->withMetadata("N2R")
->withTimingType(null)
->withLockTime(null)
->withAcquireActions([
(new \Gs2\Exchange\Model\AcquireAction())
->withAction("Gs2Inventory:AcquireItemSetByUserId")
->withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
])
->withVerifyActions(null)
->withConsumeActions([
(new \Gs2\Exchange\Model\ConsumeAction())
->withAction("Gs2Inventory:ConsumeItemSetByUserId")
->withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"),
])
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CreateRateModelMasterRequest;
import io.gs2.exchange.result.CreateRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CreateRateModelMasterResult result = client.createRateModelMaster(
new CreateRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withName("rate-0001")
.withDescription(null)
.withMetadata("N2R")
.withTimingType(null)
.withLockTime(null)
.withAcquireActions(Arrays.asList(
new io.gs2.exchange.model.AcquireAction()
.withAction("Gs2Inventory:AcquireItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}")
))
.withVerifyActions(null)
.withConsumeActions(Arrays.asList(
new io.gs2.exchange.model.ConsumeAction()
.withAction("Gs2Inventory:ConsumeItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}")
))
);
RateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CreateRateModelMasterResult> asyncResult = null;
yield return client.CreateRateModelMaster(
new Gs2.Gs2Exchange.Request.CreateRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithName("rate-0001")
.WithDescription(null)
.WithMetadata("N2R")
.WithTimingType(null)
.WithLockTime(null)
.WithAcquireActions(new Gs2.Core.Model.AcquireAction[] {
new Gs2.Core.Model.AcquireAction()
.WithAction("Gs2Inventory:AcquireItemSetByUserId")
.WithRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
})
.WithVerifyActions(null)
.WithConsumeActions(new Gs2.Core.Model.ConsumeAction[] {
new Gs2.Core.Model.ConsumeAction()
.WithAction("Gs2Inventory:ConsumeItemSetByUserId")
.WithRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"),
}),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.createRateModelMaster(
new Gs2Exchange.CreateRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withName("rate-0001")
.withDescription(null)
.withMetadata("N2R")
.withTimingType(null)
.withLockTime(null)
.withAcquireActions([
new Gs2Exchange.model.AcquireAction()
.withAction("Gs2Inventory:AcquireItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
])
.withVerifyActions(null)
.withConsumeActions([
new Gs2Exchange.model.ConsumeAction()
.withAction("Gs2Inventory:ConsumeItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"),
])
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.create_rate_model_master(
exchange.CreateRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_name('rate-0001')
.with_description(None)
.with_metadata('N2R')
.with_timing_type(None)
.with_lock_time(None)
.with_acquire_actions([
exchange.AcquireAction()
.with_action('Gs2Inventory:AcquireItemSetByUserId')
.with_request('{"namespaceName": "namespace-0001", "inventoryName": "item", "itemName": "item-0002", "userId": "#{userId}", "acquireCount": 1}'),
])
.with_verify_actions(None)
.with_consume_actions([
exchange.ConsumeAction()
.with_action('Gs2Inventory:ConsumeItemSetByUserId')
.with_request('{"namespaceName": "namespace-0001", "inventoryName": "item", "itemName": "item-0001", "userId": "#{userId}", "consumeCount": 10}'),
])
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.create_rate_model_master({
namespaceName="namespace-0001",
name="rate-0001",
description=nil,
metadata="N2R",
timingType=nil,
lockTime=nil,
acquireActions={
{
action="Gs2Inventory:AcquireItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}",
}
},
verifyActions=nil,
consumeActions={
{
action="Gs2Inventory:ConsumeItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}",
}
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.create_rate_model_master_async({
namespaceName="namespace-0001",
name="rate-0001",
description=nil,
metadata="N2R",
timingType=nil,
lockTime=nil,
acquireActions={
{
action="Gs2Inventory:AcquireItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}",
}
},
verifyActions=nil,
consumeActions={
{
action="Gs2Inventory:ConsumeItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}",
}
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getRateModelMaster
Get Exchange Rate Model Master
Retrieves the detailed information of a specific editable Exchange Rate Model Master by name. This is used for viewing and editing the master definition before activation.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | RateModelMaster | Exchange Rate Model Master |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetRateModelMaster(
&exchange.GetRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getRateModelMaster(
(new GetRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetRateModelMasterRequest;
import io.gs2.exchange.result.GetRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetRateModelMasterResult result = client.getRateModelMaster(
new GetRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
RateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetRateModelMasterResult> asyncResult = null;
yield return client.GetRateModelMaster(
new Gs2.Gs2Exchange.Request.GetRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getRateModelMaster(
new Gs2Exchange.GetRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_rate_model_master(
exchange.GetRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_rate_model_master({
namespaceName="namespace-0001",
rateName="rate-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_rate_model_master_async({
namespaceName="namespace-0001",
rateName="rate-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;updateRateModelMaster
Update Exchange Rate Model Master
Updates the description, metadata, timing type, lock time, and consume/verify/acquire actions of an existing Exchange Rate Model Master. The rate model name cannot be changed after creation. Changes do not take effect until the master data is re-activated via the CurrentRateMaster API.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| description | string | ~ 1024 chars | Description | |||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||
| timingType | String Enum enum { “immediate”, “await” } | “immediate” | Type of exchange Determines when rewards are delivered after performing the exchange. immediate delivers rewards instantly upon exchange execution. await requires real-time to elapse before rewards can be claimed, creating a waiting period (e.g., crafting time).
| |||||||||
| lockTime | int | {timingType} == “await” | ✓* | 0 ~ 538214400 | Waiting time (minutes) from the execution of the exchange until the reward is actually received Only applicable when timingType is await. Specifies the number of minutes that must elapse in real time after the exchange is initiated before the player can claim the rewards. The waiting time can be shortened by using the skip mechanism.* Required if timingType is “await” | |||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the exchange. Multiple acquire actions can be specified to grant various resource types simultaneously. These actions are executed as acquire actions within a distributed transaction. | ||||||||
| verifyActions | List<VerifyAction> | [] | 0 ~ 10 items | List of Verify Actions Precondition checks that must all pass before the exchange is executed. If any verify action fails, the exchange is aborted without consuming resources. Used to enforce conditions such as level requirements or inventory capacity. | ||||||||
| consumeActions | List<ConsumeAction> | [] | 0 ~ 10 items | List of Consume Actions Defines the resources (cost) that the player must pay to perform this exchange. Multiple consume actions can be specified, allowing complex exchange costs such as requiring both gold and items. These actions are executed as consume actions within a distributed transaction. |
Result
| Type | Description | |
|---|---|---|
| item | RateModelMaster | Exchange Rate Model Master updated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.UpdateRateModelMaster(
&exchange.UpdateRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
Description: pointy.String("description1"),
Metadata: pointy.String("RATE_0001"),
TimingType: pointy.String("await"),
LockTime: pointy.Int32(180),
AcquireActions: []exchange.AcquireAction{
exchange.AcquireAction{
Action: pointy.String("Gs2Stamina:RecoverStaminaByUserId"),
Request: pointy.String("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
},
},
VerifyActions: nil,
ConsumeActions: []exchange.ConsumeAction{
exchange.ConsumeAction{
Action: pointy.String("Gs2Money:WithdrawByUserId"),
Request: pointy.String("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
},
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\UpdateRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->updateRateModelMaster(
(new UpdateRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
->withDescription("description1")
->withMetadata("RATE_0001")
->withTimingType("await")
->withLockTime(180)
->withAcquireActions([
(new \Gs2\Exchange\Model\AcquireAction())
->withAction("Gs2Stamina:RecoverStaminaByUserId")
->withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
])
->withVerifyActions(null)
->withConsumeActions([
(new \Gs2\Exchange\Model\ConsumeAction())
->withAction("Gs2Money:WithdrawByUserId")
->withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
])
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.UpdateRateModelMasterRequest;
import io.gs2.exchange.result.UpdateRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
UpdateRateModelMasterResult result = client.updateRateModelMaster(
new UpdateRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withDescription("description1")
.withMetadata("RATE_0001")
.withTimingType("await")
.withLockTime(180)
.withAcquireActions(Arrays.asList(
new io.gs2.exchange.model.AcquireAction()
.withAction("Gs2Stamina:RecoverStaminaByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}")
))
.withVerifyActions(null)
.withConsumeActions(Arrays.asList(
new io.gs2.exchange.model.ConsumeAction()
.withAction("Gs2Money:WithdrawByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}")
))
);
RateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.UpdateRateModelMasterResult> asyncResult = null;
yield return client.UpdateRateModelMaster(
new Gs2.Gs2Exchange.Request.UpdateRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001")
.WithDescription("description1")
.WithMetadata("RATE_0001")
.WithTimingType("await")
.WithLockTime(180)
.WithAcquireActions(new Gs2.Core.Model.AcquireAction[] {
new Gs2.Core.Model.AcquireAction()
.WithAction("Gs2Stamina:RecoverStaminaByUserId")
.WithRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
})
.WithVerifyActions(null)
.WithConsumeActions(new Gs2.Core.Model.ConsumeAction[] {
new Gs2.Core.Model.ConsumeAction()
.WithAction("Gs2Money:WithdrawByUserId")
.WithRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
}),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.updateRateModelMaster(
new Gs2Exchange.UpdateRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withDescription("description1")
.withMetadata("RATE_0001")
.withTimingType("await")
.withLockTime(180)
.withAcquireActions([
new Gs2Exchange.model.AcquireAction()
.withAction("Gs2Stamina:RecoverStaminaByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
])
.withVerifyActions(null)
.withConsumeActions([
new Gs2Exchange.model.ConsumeAction()
.withAction("Gs2Money:WithdrawByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
])
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.update_rate_model_master(
exchange.UpdateRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
.with_description('description1')
.with_metadata('RATE_0001')
.with_timing_type('await')
.with_lock_time(180)
.with_acquire_actions([
exchange.AcquireAction()
.with_action('Gs2Stamina:RecoverStaminaByUserId')
.with_request('{"moneyName": "money-0001", "userId": "user-0001", "slot": 0, "count": 200, "paidOnly": false}'),
])
.with_verify_actions(None)
.with_consume_actions([
exchange.ConsumeAction()
.with_action('Gs2Money:WithdrawByUserId')
.with_request('{"moneyName": "money-0001", "userId": "user-0001", "slot": 0, "count": 200, "paidOnly": false}'),
])
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.update_rate_model_master({
namespaceName="namespace-0001",
rateName="rate-0001",
description="description1",
metadata="RATE_0001",
timingType="await",
lockTime=180,
acquireActions={
{
action="Gs2Stamina:RecoverStaminaByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
}
},
verifyActions=nil,
consumeActions={
{
action="Gs2Money:WithdrawByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
}
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.update_rate_model_master_async({
namespaceName="namespace-0001",
rateName="rate-0001",
description="description1",
metadata="RATE_0001",
timingType="await",
lockTime=180,
acquireActions={
{
action="Gs2Stamina:RecoverStaminaByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
}
},
verifyActions=nil,
consumeActions={
{
action="Gs2Money:WithdrawByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
}
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteRateModelMaster
Delete Exchange Rate Model Master
Deletes an editable Exchange Rate Model Master definition. This only affects the master data; the currently active (published) model is not affected until the master data is re-activated.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Exchange Rate Model name Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | RateModelMaster | Exchange Rate Model Master deleted |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DeleteRateModelMaster(
&exchange.DeleteRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DeleteRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->deleteRateModelMaster(
(new DeleteRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DeleteRateModelMasterRequest;
import io.gs2.exchange.result.DeleteRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DeleteRateModelMasterResult result = client.deleteRateModelMaster(
new DeleteRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
RateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DeleteRateModelMasterResult> asyncResult = null;
yield return client.DeleteRateModelMaster(
new Gs2.Gs2Exchange.Request.DeleteRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.deleteRateModelMaster(
new Gs2Exchange.DeleteRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.delete_rate_model_master(
exchange.DeleteRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.delete_rate_model_master({
namespaceName="namespace-0001",
rateName="rate-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.delete_rate_model_master_async({
namespaceName="namespace-0001",
rateName="rate-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;describeIncrementalRateModelMasters
Get a list of Incremental Cost Exchange Rate Model Masters
Retrieves a paginated list of editable Incremental Cost Exchange Rate Model Masters with optional name prefix filtering. Incremental Cost Exchange Rate Model Masters are the editable definitions for exchanges with progressively increasing costs. Changes to masters do not take effect until the master data is activated via the CurrentRateMaster API.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| namePrefix | string | ~ 64 chars | Filter by Incremental Cost Exchange Rate Model name prefix | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<IncrementalRateModelMaster> | List of Incremental Cost Exchange Rate Model Masters |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DescribeIncrementalRateModelMasters(
&exchange.DescribeIncrementalRateModelMastersRequest {
NamespaceName: pointy.String("namespace-0001"),
NamePrefix: nil,
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DescribeIncrementalRateModelMastersRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->describeIncrementalRateModelMasters(
(new DescribeIncrementalRateModelMastersRequest())
->withNamespaceName("namespace-0001")
->withNamePrefix(null)
->withPageToken(null)
->withLimit(null)
);
$items = $result->getItems();
$nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DescribeIncrementalRateModelMastersRequest;
import io.gs2.exchange.result.DescribeIncrementalRateModelMastersResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DescribeIncrementalRateModelMastersResult result = client.describeIncrementalRateModelMasters(
new DescribeIncrementalRateModelMastersRequest()
.withNamespaceName("namespace-0001")
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
List<IncrementalRateModelMaster> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DescribeIncrementalRateModelMastersResult> asyncResult = null;
yield return client.DescribeIncrementalRateModelMasters(
new Gs2.Gs2Exchange.Request.DescribeIncrementalRateModelMastersRequest()
.WithNamespaceName("namespace-0001")
.WithNamePrefix(null)
.WithPageToken(null)
.WithLimit(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.describeIncrementalRateModelMasters(
new Gs2Exchange.DescribeIncrementalRateModelMastersRequest()
.withNamespaceName("namespace-0001")
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
const items = result.getItems();
const nextPageToken = result.getNextPageToken();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.describe_incremental_rate_model_masters(
exchange.DescribeIncrementalRateModelMastersRequest()
.with_namespace_name('namespace-0001')
.with_name_prefix(None)
.with_page_token(None)
.with_limit(None)
)
items = result.items
next_page_token = result.next_page_token
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.describe_incremental_rate_model_masters({
namespaceName="namespace-0001",
namePrefix=nil,
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('exchange')
api_result_handler = client.describe_incremental_rate_model_masters_async({
namespaceName="namespace-0001",
namePrefix=nil,
pageToken=nil,
limit=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;createIncrementalRateModelMaster
Create a new Incremental Cost Exchange Rate Model Master
Creates a new editable Incremental Cost Exchange Rate Model Master definition. The model defines a consume action whose cost increases based on the calculation type: ’linear’ (baseValue + coefficientValue * exchangeCount) or ‘gs2Script’ (using a custom GS2-Script). The exchange count ID tracks how many times the exchange has been performed, and a maximum exchange count can be set to limit exchanges. Changes do not take effect until the master data is activated via the CurrentRateMaster API.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||
| name | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||||||||||
| description | string | ~ 1024 chars | Description | |||||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||||
| consumeAction | ConsumeAction | ✓ | Consume Action (Quantity and Value are overwritten automatically) Defines the type of resource consumed as cost for the exchange. The actual quantity is calculated dynamically based on the exchange count and the calculation type (linear, power, or script). Only the action type and target resource need to be specified; the quantity field is overwritten automatically. | |||||||||||
| calculateType | String Enum enum { “linear”, “power”, “gs2_script” } | ✓ | Calculation method for cost increase amount Determines how the exchange cost escalates with each exchange. linear calculates cost as baseValue + (coefficientValue * exchangeCount). power calculates cost as coefficientValue * (exchangeCount + 1)^2. gs2_script delegates the calculation to a custom GS2-Script for arbitrary logic.
| |||||||||||
| baseValue | long | {calculateType} == “linear” | ✓* | 0 ~ 9223372036854775805 | Base Value The initial cost for the first exchange when using the linear calculation type. The total cost is calculated as: baseValue + (coefficientValue * exchangeCount).* Required if calculateType is “linear” | |||||||||
| coefficientValue | long | {calculateType} in [“linear”, “power”] | ✓* | 0 ~ 9223372036854775805 | Coefficient Value The multiplier that controls how quickly costs escalate with each exchange. In linear mode, each exchange adds this value to the cost. In power mode, the cost is calculated as: coefficientValue * (exchangeCount + 1)^2.* Required if calculateType is “linear”,“power” | |||||||||
| calculateScriptId | string | {calculateType} == “gs2_script” | ✓* | ~ 1024 chars | GRN
of cost calculation script * Required if calculateType is “gs2_script” | |||||||||
| exchangeCountId | string | ✓ | ~ 1024 chars | GS2-Limit Usage Limit Model GRN for managing exchange execution counts | ||||||||||
| maximumExchangeCount | int | 2147483646 | 0 ~ 2147483646 | Maximum number of exchanges The maximum number of times this incremental exchange can be performed by a user. Once the exchange count reaches this limit, further exchanges are denied until the count is reset via GS2-Limit. | ||||||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the incremental exchange. The rewards remain constant regardless of the exchange count; only the cost increases with each exchange. |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModelMaster | Incremental Cost Exchange Rate Model Master created |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.CreateIncrementalRateModelMaster(
&exchange.CreateIncrementalRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
Name: pointy.String("rate-0001"),
Description: nil,
Metadata: pointy.String("N2R"),
ConsumeAction: &exchange.ConsumeAction{
Action: pointy.String("Gs2Inventory:ConsumeItemSetByUserId"),
Request: pointy.String("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"),
},
CalculateType: pointy.String("linear"),
BaseValue: pointy.Int64(100),
CoefficientValue: pointy.Int64(150),
CalculateScriptId: nil,
ExchangeCountId: pointy.String("grn:gs2:limit-0001"),
MaximumExchangeCount: nil,
AcquireActions: []exchange.AcquireAction{
exchange.AcquireAction{
Action: pointy.String("Gs2Inventory:AcquireItemSetByUserId"),
Request: pointy.String("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
},
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\CreateIncrementalRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->createIncrementalRateModelMaster(
(new CreateIncrementalRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withName("rate-0001")
->withDescription(null)
->withMetadata("N2R")
->withConsumeAction((new \Gs2\Exchange\Model\ConsumeAction())
->withAction("Gs2Inventory:ConsumeItemSetByUserId")
->withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"))
->withCalculateType("linear")
->withBaseValue(100)
->withCoefficientValue(150)
->withCalculateScriptId(null)
->withExchangeCountId("grn:gs2:limit-0001")
->withMaximumExchangeCount(null)
->withAcquireActions([
(new \Gs2\Exchange\Model\AcquireAction())
->withAction("Gs2Inventory:AcquireItemSetByUserId")
->withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
])
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.CreateIncrementalRateModelMasterRequest;
import io.gs2.exchange.result.CreateIncrementalRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
CreateIncrementalRateModelMasterResult result = client.createIncrementalRateModelMaster(
new CreateIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withName("rate-0001")
.withDescription(null)
.withMetadata("N2R")
.withConsumeAction(new io.gs2.exchange.model.ConsumeAction()
.withAction("Gs2Inventory:ConsumeItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"))
.withCalculateType("linear")
.withBaseValue(100L)
.withCoefficientValue(150L)
.withCalculateScriptId(null)
.withExchangeCountId("grn:gs2:limit-0001")
.withMaximumExchangeCount(null)
.withAcquireActions(Arrays.asList(
new io.gs2.exchange.model.AcquireAction()
.withAction("Gs2Inventory:AcquireItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}")
))
);
IncrementalRateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.CreateIncrementalRateModelMasterResult> asyncResult = null;
yield return client.CreateIncrementalRateModelMaster(
new Gs2.Gs2Exchange.Request.CreateIncrementalRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithName("rate-0001")
.WithDescription(null)
.WithMetadata("N2R")
.WithConsumeAction(new Gs2.Core.Model.ConsumeAction()
.WithAction("Gs2Inventory:ConsumeItemSetByUserId")
.WithRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"))
.WithCalculateType("linear")
.WithBaseValue(100L)
.WithCoefficientValue(150L)
.WithCalculateScriptId(null)
.WithExchangeCountId("grn:gs2:limit-0001")
.WithMaximumExchangeCount(null)
.WithAcquireActions(new Gs2.Core.Model.AcquireAction[] {
new Gs2.Core.Model.AcquireAction()
.WithAction("Gs2Inventory:AcquireItemSetByUserId")
.WithRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
}),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.createIncrementalRateModelMaster(
new Gs2Exchange.CreateIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withName("rate-0001")
.withDescription(null)
.withMetadata("N2R")
.withConsumeAction(new Gs2Exchange.model.ConsumeAction()
.withAction("Gs2Inventory:ConsumeItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}"))
.withCalculateType("linear")
.withBaseValue(100)
.withCoefficientValue(150)
.withCalculateScriptId(null)
.withExchangeCountId("grn:gs2:limit-0001")
.withMaximumExchangeCount(null)
.withAcquireActions([
new Gs2Exchange.model.AcquireAction()
.withAction("Gs2Inventory:AcquireItemSetByUserId")
.withRequest("{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}"),
])
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.create_incremental_rate_model_master(
exchange.CreateIncrementalRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_name('rate-0001')
.with_description(None)
.with_metadata('N2R')
.with_consume_action(
exchange.ConsumeAction()
.with_action('Gs2Inventory:ConsumeItemSetByUserId')
.with_request('{"namespaceName": "namespace-0001", "inventoryName": "item", "itemName": "item-0001", "userId": "#{userId}", "consumeCount": 10}'))
.with_calculate_type('linear')
.with_base_value(100)
.with_coefficient_value(150)
.with_calculate_script_id(None)
.with_exchange_count_id('grn:gs2:limit-0001')
.with_maximum_exchange_count(None)
.with_acquire_actions([
exchange.AcquireAction()
.with_action('Gs2Inventory:AcquireItemSetByUserId')
.with_request('{"namespaceName": "namespace-0001", "inventoryName": "item", "itemName": "item-0002", "userId": "#{userId}", "acquireCount": 1}'),
])
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.create_incremental_rate_model_master({
namespaceName="namespace-0001",
name="rate-0001",
description=nil,
metadata="N2R",
consumeAction={
action="Gs2Inventory:ConsumeItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}",
},
calculateType="linear",
baseValue=100,
coefficientValue=150,
calculateScriptId=nil,
exchangeCountId="grn:gs2:limit-0001",
maximumExchangeCount=nil,
acquireActions={
{
action="Gs2Inventory:AcquireItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}",
}
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.create_incremental_rate_model_master_async({
namespaceName="namespace-0001",
name="rate-0001",
description=nil,
metadata="N2R",
consumeAction={
action="Gs2Inventory:ConsumeItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0001\", \"userId\": \"#{userId}\", \"consumeCount\": 10}",
},
calculateType="linear",
baseValue=100,
coefficientValue=150,
calculateScriptId=nil,
exchangeCountId="grn:gs2:limit-0001",
maximumExchangeCount=nil,
acquireActions={
{
action="Gs2Inventory:AcquireItemSetByUserId",
request="{\"namespaceName\": \"namespace-0001\", \"inventoryName\": \"item\", \"itemName\": \"item-0002\", \"userId\": \"#{userId}\", \"acquireCount\": 1}",
}
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getIncrementalRateModelMaster
Get Incremental Cost Exchange Rate Model Master
Retrieves the detailed information of a specific editable Incremental Cost Exchange Rate Model Master by name. This is used for viewing and editing the master definition before activation.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModelMaster | Incremental Cost Exchange Rate Model Master |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.GetIncrementalRateModelMaster(
&exchange.GetIncrementalRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\GetIncrementalRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->getIncrementalRateModelMaster(
(new GetIncrementalRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.GetIncrementalRateModelMasterRequest;
import io.gs2.exchange.result.GetIncrementalRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
GetIncrementalRateModelMasterResult result = client.getIncrementalRateModelMaster(
new GetIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
IncrementalRateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.GetIncrementalRateModelMasterResult> asyncResult = null;
yield return client.GetIncrementalRateModelMaster(
new Gs2.Gs2Exchange.Request.GetIncrementalRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.getIncrementalRateModelMaster(
new Gs2Exchange.GetIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.get_incremental_rate_model_master(
exchange.GetIncrementalRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.get_incremental_rate_model_master({
namespaceName="namespace-0001",
rateName="rate-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.get_incremental_rate_model_master_async({
namespaceName="namespace-0001",
rateName="rate-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;updateIncrementalRateModelMaster
Update Incremental Cost Exchange Rate Model Master
Updates the description, metadata, consume action, calculation type, base/coefficient values, script ID, exchange count ID, maximum exchange count, and acquire actions of an existing Incremental Cost Exchange Rate Model Master. The rate model name cannot be changed after creation. Changes do not take effect until the master data is re-activated via the CurrentRateMaster API.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||
| rateName | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||||||||||
| description | string | ~ 1024 chars | Description | |||||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||||
| consumeAction | ConsumeAction | ✓ | Consume Action (Quantity and Value are overwritten automatically) Defines the type of resource consumed as cost for the exchange. The actual quantity is calculated dynamically based on the exchange count and the calculation type (linear, power, or script). Only the action type and target resource need to be specified; the quantity field is overwritten automatically. | |||||||||||
| calculateType | String Enum enum { “linear”, “power”, “gs2_script” } | ✓ | Calculation method for cost increase amount Determines how the exchange cost escalates with each exchange. linear calculates cost as baseValue + (coefficientValue * exchangeCount). power calculates cost as coefficientValue * (exchangeCount + 1)^2. gs2_script delegates the calculation to a custom GS2-Script for arbitrary logic.
| |||||||||||
| baseValue | long | {calculateType} == “linear” | ✓* | 0 ~ 9223372036854775805 | Base Value The initial cost for the first exchange when using the linear calculation type. The total cost is calculated as: baseValue + (coefficientValue * exchangeCount).* Required if calculateType is “linear” | |||||||||
| coefficientValue | long | {calculateType} in [“linear”, “power”] | ✓* | 0 ~ 9223372036854775805 | Coefficient Value The multiplier that controls how quickly costs escalate with each exchange. In linear mode, each exchange adds this value to the cost. In power mode, the cost is calculated as: coefficientValue * (exchangeCount + 1)^2.* Required if calculateType is “linear”,“power” | |||||||||
| calculateScriptId | string | {calculateType} == “gs2_script” | ✓* | ~ 1024 chars | GRN
of cost calculation script * Required if calculateType is “gs2_script” | |||||||||
| exchangeCountId | string | ✓ | ~ 1024 chars | GS2-Limit Usage Limit Model GRN for managing exchange execution counts | ||||||||||
| maximumExchangeCount | int | 2147483646 | 0 ~ 2147483646 | Maximum number of exchanges The maximum number of times this incremental exchange can be performed by a user. Once the exchange count reaches this limit, further exchanges are denied until the count is reset via GS2-Limit. | ||||||||||
| acquireActions | List<AcquireAction> | [] | 0 ~ 100 items | List of Acquire Actions Defines the resources (rewards) that the player receives upon completing the incremental exchange. The rewards remain constant regardless of the exchange count; only the cost increases with each exchange. |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModelMaster | Incremental Cost Exchange Rate Model Master updated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.UpdateIncrementalRateModelMaster(
&exchange.UpdateIncrementalRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
Description: pointy.String("description1"),
Metadata: pointy.String("RATE_0001"),
ConsumeAction: &exchange.ConsumeAction{
Action: pointy.String("Gs2Money:WithdrawByUserId"),
Request: pointy.String("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
},
CalculateType: pointy.String("gs2_script"),
BaseValue: pointy.Int64(100),
CoefficientValue: pointy.Int64(150),
CalculateScriptId: pointy.String("grn:gs2:script-0001"),
ExchangeCountId: pointy.String("grn:gs2:limit-0001"),
MaximumExchangeCount: nil,
AcquireActions: []exchange.AcquireAction{
exchange.AcquireAction{
Action: pointy.String("Gs2Stamina:RecoverStaminaByUserId"),
Request: pointy.String("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
},
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\UpdateIncrementalRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->updateIncrementalRateModelMaster(
(new UpdateIncrementalRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
->withDescription("description1")
->withMetadata("RATE_0001")
->withConsumeAction((new \Gs2\Exchange\Model\ConsumeAction())
->withAction("Gs2Money:WithdrawByUserId")
->withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"))
->withCalculateType("gs2_script")
->withBaseValue(100)
->withCoefficientValue(150)
->withCalculateScriptId("grn:gs2:script-0001")
->withExchangeCountId("grn:gs2:limit-0001")
->withMaximumExchangeCount(null)
->withAcquireActions([
(new \Gs2\Exchange\Model\AcquireAction())
->withAction("Gs2Stamina:RecoverStaminaByUserId")
->withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
])
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.UpdateIncrementalRateModelMasterRequest;
import io.gs2.exchange.result.UpdateIncrementalRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
UpdateIncrementalRateModelMasterResult result = client.updateIncrementalRateModelMaster(
new UpdateIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withDescription("description1")
.withMetadata("RATE_0001")
.withConsumeAction(new io.gs2.exchange.model.ConsumeAction()
.withAction("Gs2Money:WithdrawByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"))
.withCalculateType("gs2_script")
.withBaseValue(100L)
.withCoefficientValue(150L)
.withCalculateScriptId("grn:gs2:script-0001")
.withExchangeCountId("grn:gs2:limit-0001")
.withMaximumExchangeCount(null)
.withAcquireActions(Arrays.asList(
new io.gs2.exchange.model.AcquireAction()
.withAction("Gs2Stamina:RecoverStaminaByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}")
))
);
IncrementalRateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.UpdateIncrementalRateModelMasterResult> asyncResult = null;
yield return client.UpdateIncrementalRateModelMaster(
new Gs2.Gs2Exchange.Request.UpdateIncrementalRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001")
.WithDescription("description1")
.WithMetadata("RATE_0001")
.WithConsumeAction(new Gs2.Core.Model.ConsumeAction()
.WithAction("Gs2Money:WithdrawByUserId")
.WithRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"))
.WithCalculateType("gs2_script")
.WithBaseValue(100L)
.WithCoefficientValue(150L)
.WithCalculateScriptId("grn:gs2:script-0001")
.WithExchangeCountId("grn:gs2:limit-0001")
.WithMaximumExchangeCount(null)
.WithAcquireActions(new Gs2.Core.Model.AcquireAction[] {
new Gs2.Core.Model.AcquireAction()
.WithAction("Gs2Stamina:RecoverStaminaByUserId")
.WithRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
}),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.updateIncrementalRateModelMaster(
new Gs2Exchange.UpdateIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
.withDescription("description1")
.withMetadata("RATE_0001")
.withConsumeAction(new Gs2Exchange.model.ConsumeAction()
.withAction("Gs2Money:WithdrawByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"))
.withCalculateType("gs2_script")
.withBaseValue(100)
.withCoefficientValue(150)
.withCalculateScriptId("grn:gs2:script-0001")
.withExchangeCountId("grn:gs2:limit-0001")
.withMaximumExchangeCount(null)
.withAcquireActions([
new Gs2Exchange.model.AcquireAction()
.withAction("Gs2Stamina:RecoverStaminaByUserId")
.withRequest("{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}"),
])
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.update_incremental_rate_model_master(
exchange.UpdateIncrementalRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
.with_description('description1')
.with_metadata('RATE_0001')
.with_consume_action(
exchange.ConsumeAction()
.with_action('Gs2Money:WithdrawByUserId')
.with_request('{"moneyName": "money-0001", "userId": "user-0001", "slot": 0, "count": 200, "paidOnly": false}'))
.with_calculate_type('gs2_script')
.with_base_value(100)
.with_coefficient_value(150)
.with_calculate_script_id('grn:gs2:script-0001')
.with_exchange_count_id('grn:gs2:limit-0001')
.with_maximum_exchange_count(None)
.with_acquire_actions([
exchange.AcquireAction()
.with_action('Gs2Stamina:RecoverStaminaByUserId')
.with_request('{"moneyName": "money-0001", "userId": "user-0001", "slot": 0, "count": 200, "paidOnly": false}'),
])
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.update_incremental_rate_model_master({
namespaceName="namespace-0001",
rateName="rate-0001",
description="description1",
metadata="RATE_0001",
consumeAction={
action="Gs2Money:WithdrawByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
},
calculateType="gs2_script",
baseValue=100,
coefficientValue=150,
calculateScriptId="grn:gs2:script-0001",
exchangeCountId="grn:gs2:limit-0001",
maximumExchangeCount=nil,
acquireActions={
{
action="Gs2Stamina:RecoverStaminaByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
}
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.update_incremental_rate_model_master_async({
namespaceName="namespace-0001",
rateName="rate-0001",
description="description1",
metadata="RATE_0001",
consumeAction={
action="Gs2Money:WithdrawByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
},
calculateType="gs2_script",
baseValue=100,
coefficientValue=150,
calculateScriptId="grn:gs2:script-0001",
exchangeCountId="grn:gs2:limit-0001",
maximumExchangeCount=nil,
acquireActions={
{
action="Gs2Stamina:RecoverStaminaByUserId",
request="{\"moneyName\": \"money-0001\", \"userId\": \"user-0001\", \"slot\": 0, \"count\": 200, \"paidOnly\": false}",
}
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteIncrementalRateModelMaster
Delete Incremental Cost Exchange Rate Model Master
Deletes an editable Incremental Cost Exchange Rate Model Master definition. This only affects the master data; the currently active (published) model is not affected until the master data is re-activated.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| rateName | string | ✓ | ~ 128 chars | Incremental Cost Exchange Rate Model name Incremental Cost Exchange Rate Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). |
Result
| Type | Description | |
|---|---|---|
| item | IncrementalRateModelMaster | Incremental Cost Exchange Rate Model Master deleted |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/exchange"
import "github.com/openlyinc/pointy"
session := core.Gs2RestSession{
Credential: &core.BasicGs2Credential{
ClientId: "your client id",
ClientSecret: "your client secret",
},
Region: core.ApNortheast1,
}
if err := session.Connect(); err != nil {
panic("error occurred")
}
client := exchange.Gs2ExchangeRestClient{
Session: &session,
}
result, err := client.DeleteIncrementalRateModelMaster(
&exchange.DeleteIncrementalRateModelMasterRequest {
NamespaceName: pointy.String("namespace-0001"),
RateName: pointy.String("rate-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Exchange\Gs2ExchangeRestClient;
use Gs2\Exchange\Request\DeleteIncrementalRateModelMasterRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2ExchangeRestClient(
$session
);
try {
$result = $client->deleteIncrementalRateModelMaster(
(new DeleteIncrementalRateModelMasterRequest())
->withNamespaceName("namespace-0001")
->withRateName("rate-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.exchange.rest.Gs2ExchangeRestClient;
import io.gs2.exchange.request.DeleteIncrementalRateModelMasterRequest;
import io.gs2.exchange.result.DeleteIncrementalRateModelMasterResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2ExchangeRestClient client = new Gs2ExchangeRestClient(session);
try {
DeleteIncrementalRateModelMasterResult result = client.deleteIncrementalRateModelMaster(
new DeleteIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
IncrementalRateModelMaster item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ExchangeRestClient(session);
AsyncResult<Gs2.Gs2Exchange.Result.DeleteIncrementalRateModelMasterResult> asyncResult = null;
yield return client.DeleteIncrementalRateModelMaster(
new Gs2.Gs2Exchange.Request.DeleteIncrementalRateModelMasterRequest()
.WithNamespaceName("namespace-0001")
.WithRateName("rate-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as Gs2Exchange from '@/gs2/exchange';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Exchange.Gs2ExchangeRestClient(session);
try {
const result = await client.deleteIncrementalRateModelMaster(
new Gs2Exchange.DeleteIncrementalRateModelMasterRequest()
.withNamespaceName("namespace-0001")
.withRateName("rate-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import exchange
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = exchange.Gs2ExchangeRestClient(session)
try:
result = client.delete_incremental_rate_model_master(
exchange.DeleteIncrementalRateModelMasterRequest()
.with_namespace_name('namespace-0001')
.with_rate_name('rate-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('exchange')
api_result = client.delete_incremental_rate_model_master({
namespaceName="namespace-0001",
rateName="rate-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('exchange')
api_result_handler = client.delete_incremental_rate_model_master_async({
namespaceName="namespace-0001",
rateName="rate-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;