/dyspatch-golang

An OpenAPI generated Dyspatch client in Go

Primary LanguageGoApache License 2.0Apache-2.0

Go API client for Dyspatch

Introduction

The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted.

See our Implementation Guide for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks.

Overview

This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.

  • API version: 2019.03
  • Package version: 2.0.0
  • Build package: io.swagger.codegen.languages.GoClientCodegen

For more information, please visit https://docs.dyspatch.io

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional

Install the latest version of the client project:

go get -u github.com/getdyspatch/dyspatch-golang

Installing a versioned client:

go get gopkg.in/getdyspatch/dyspatch-golang.v2

Importing a versioned client:

import "gopkg.in/getdyspatch/dyspatch-golang.v2"

Read more at gopkg.in

Getting Started

package main

import (
	"fmt"
	"github.com/antihax/optional"
	"gopkg.in/getdyspatch/dyspatch-golang.v2"
	"golang.org/x/net/context"
)

func main() {
	cfg := dyspatch.NewConfiguration()
	auth := context.WithValue(context.Background(), dyspatch.ContextAPIKey, dyspatch.APIKey{
		Key:    "DYSPATCH_API_KEY",
		Prefix: "Bearer",
	})

	api := dyspatch.NewAPIClient(cfg)
	opts := dyspatch.TemplatesGetOpts{Cursor: optional.NewString("")} // Use this to page API results
	templates, _, err := api.TemplatesApi.TemplatesGet(auth, &opts)

	if err != nil {
		fmt.Println(err)
	}

	for _, template := range templates.Data {
		fmt.Println(template.Name)
	}
}

Documentation for API Endpoints

All URIs are relative to https://api.dyspatch.io

Class Method HTTP request Description
LocalizationsApi LocalizationsLocalizationIdGet Get /localizations/{localizationId} Get Localization Object by ID
TemplatesApi TemplatesGet Get /templates List Templates
TemplatesApi TemplatesTemplateIdGet Get /templates/{templateId} Get Template by ID

Documentation For Models

Documentation For Authorization

Bearer

  • Type: API key

Example

auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
	Key: "APIKEY",
	Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)

Author

support@dyspatch.io