# {{ spec.title }} {{sdk.name}} SDK

![License](https://img.shields.io/github/license/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-{{ spec.version|url_encode }}-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/{{ sdk.gitUserName|url_encode }}/sdk-generator?style=flat-square)](https://travis-ci.com/{{ sdk.gitUserName|url_encode }}/sdk-generator)
{% if sdk.twitterHandle %}
[![Twitter Account](https://img.shields.io/twitter/follow/{{ sdk.twitterHandle }}?color=00acee&label=twitter&style=flat-square)](https://twitter.com/{{ sdk.twitterHandle }})
{% endif %}
{% if sdk.discordChannel %}
[![Discord](https://img.shields.io/discord/{{ sdk.discordChannel }}?label=discord&style=flat-square)]({{ sdk.discordUrl }})
{% endif %}
{% if sdk.warning %}

{{ sdk.warning|raw }}
{% endif %}

{{ sdk.description }}

{% if sdk.logo %}
![{{ spec.title }}]({{ sdk.logo }})
{% endif %}

## Installation

To install using `go get`:

```bash
go get github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName }}
```

## Testing the SDK

* clone this repo.
* create a project and within this project a collection.
* configure the documents in the collection to have a _key_ = __hello__.
* Then inject these environment variables:

  ```bash
  export YOUR_ENDPOINT=https://{{ sdk.gitUserName|url_encode }}.io/v1  
  export YOUR_PROJECT_ID=6…8  
  export YOUR_KEY="7055781…cd95"  
  export COLLECTION_ID=616a095b20180  
  ```

Create `main.go` file with:

```go
package main

import (
	"log"
	"os"
	"time"

	"github.com/{{sdk.gitUserName}}/{{ sdk.gitRepoName|url_encode }}/appwrite"
	"github.com/{{sdk.gitUserName}}/{{ sdk.gitRepoName|url_encode }}/id"
)

func main() {
	client := appwrite.NewClient(
		appwrite.WithEndpoint(os.Getenv("YOUR_ENDPOINT")),
		appwrite.WithProject(os.Getenv("YOUR_PROJECT_ID")),
		appwrite.WithKey(os.Getenv("YOUR_KEY")),
	)

	databases := appwrite.NewDatabase(client)

	data := map[string]string{
		"hello": "world",
	}
	doc, err := databases.CreateDocument(
		os.Getenv("DATABASE_ID"),
		os.Getenv("COLLECTION_ID"),
		id.Unique(),
		data,
	)
	if err != nil {
		log.Printf("Error creating document: %v", err)
	}

	log.Printf("Created document: %v", doc)
}
```

* After that, run the following

  > % go run main.go  
  > 2021/10/16 03:41:17 Created document: map[$collection:616a095b20180 $id:616a2dbd4df16 $permissions:map[read:[] write:[]] hello:world]  

{% if sdk.gettingStarted %}

{{ sdk.gettingStarted|raw }}
{% endif %}

## Contribution

This library is auto-generated by {{ spec.title }} custom [SDK Generator](https://github.com/{{ sdk.gitUserName|url_encode }}/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/{{ sdk.gitUserName|url_encode }}/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.

## License

Please see the [{{spec.licenseName}} license]({{spec.licenseURL}}) file for more information.
