https://github.com/dkoleev/unipantry
Unity wrapper for the Pantry API - https://getpantry.cloud
https://github.com/dkoleev/unipantry
Last synced: 4 months ago
JSON representation
Unity wrapper for the Pantry API - https://getpantry.cloud
- Host: GitHub
- URL: https://github.com/dkoleev/unipantry
- Owner: dkoleev
- License: mit
- Created: 2024-08-22T15:25:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-23T09:51:23.000Z (almost 2 years ago)
- Last Synced: 2025-06-30T12:44:45.499Z (11 months ago)
- Language: C#
- Size: 18.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# UniPantry
Unity wrapper for the Pantry API - https://getpantry.cloud
## Getting started
Install via UPM package with git reference or asset package(UniPantry.*.*.*.unitypackage) available in [UniPantry/releases](https://github.com/dkoleev/UniPantry/releases).
UPM Package
---
### Install via git URL
Use [UPM](https://docs.unity3d.com/Manual/upm-ui.html) to install the package via the following git URL:
```
https://github.com/dkoleev/UniPantry.git
```

Usage
---
Create a new client
---
```c#
using Yogi.UniPantry.Runtime;
var pantry = new Pantry();
```
Get Pantry
---
Given a PantryID, return the details of the pantry, including a list of baskets currently stored inside it.
```c#
using Yogi.UniPantry.Runtime;
private void GetPantry() {
StartCoroutine(
pantry.GetPantry(pantryId,
info => {
if (info is not null) {
Debug.Log($"name: {info.name} description: {info.description} percentFull: {info.percentFull} errors: {info.errors}");
foreach (var infoBasket in info.baskets) {
Debug.Log(infoBasket.name);
}
}
})
);
}
```
Update Pantry Details
---
```c#
using Yogi.UniPantry.Runtime;
private void UpdatePantryInfo() {
StartCoroutine(
pantry.UpdatePantryInfo(pantryId, "new name", "new description",
info => {
if (info is not null) {
Debug.Log($"name: {info.name} description: {info.description} percentFull: {info.percentFull} errors: {info.errors}");
foreach (var infoBasket in info.baskets) {
Debug.Log(infoBasket.name);
}
}
})
);
}
```
Get Basket
---
Given a basket name, return the full contents of the basket.
```c#
using Yogi.UniPantry.Runtime;
private void GetBasket() {
StartCoroutine(_pantry.GetBasket(pantryId, basketId, Debug.Log));
}
```
Create Basket
---
Given a basket name as provided in the url, this will either create a new basket inside your pantry, or replace an existing one.
```c#
using Yogi.UniPantry.Runtime;
private void CreateBasket() {
var content = JsonUtility.ToJson(SOME_SERIALIZABLE_CLASS);
StartCoroutine(_pantry.CreateBasket(pantryId, basketId, content, Debug.Log));
}
```
Update Basket
---
Given a basket name, this will update the existing contents and return the contents of the newly updated basket. This operation performs a deep merge and will overwrite the values of any existing keys, or append values to nested objects or arrays.
```c#
using Yogi.UniPantry.Runtime;
private void UpdateBasket() {
var content = JsonUtility.ToJson(SOME_SERIALIZABLE_CLASS);
StartCoroutine(_pantry.UpdateBasket(pantryId, basketId, content, Debug.Log));
}
```
Delete Basket
---
Delete the entire basket. Warning, this action cannot be undone.
```c#
using Yogi.UniPantry.Runtime;
private void DeleteBasket() {
StartCoroutine(_pantry.DeleteBasket(pantryId, basketId, Debug.Log));
}
```