# README
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.
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 2019.10
- Package version: 4.0.0
- Build package: org.openapitools.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
Put the package under your project folder and add the following in import:
import "./dyspatch"
Install the latest version of the client project:
go get -u github.com/getdyspatch/dyspatch-golang
Installing a versioned client:
go get -u gopkg.in/getdyspatch/dyspatch-golang.v3
Importing a versioned client:
import "gopkg.in/getdyspatch/dyspatch-golang.v3"
Getting Started
package main
import (
"fmt"
"github.com/antihax/optional"
"gopkg.in/getdyspatch/dyspatch-golang.v3"
"golang.org/x/net/context"
)
func main() {
cfg := dyspatch.NewConfiguration()
cfg.AddDefaultHeader("Accept", "application/vnd.dyspatch.2019.10+json") // Set the API version
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)
}
res, err := client.DraftsApi.DraftsDraftIdLocalizationsLanguageIdPut(auth, "tdft_01dkyyta7dg5frv8e01186cdzf", "fr-CA", dyspatch.InlineObject{Name: "Test"})
if err != nil {
fmt.Println(err)
} else {
fmt.Println(res.Status)
}
}
Documentation for API Endpoints
All URIs are relative to https://api.dyspatch.io
Class | Method | HTTP request | Description |
---|---|---|---|
DraftsApi | DeleteLocalization | Delete /drafts/{draftId}/localizations/{languageId} | Remove a localization |
DraftsApi | GetDraftById | Get /drafts/{draftId} | Get Draft by ID |
DraftsApi | GetDraftLocalizationKeys | Get /drafts/{draftId}/localizationKeys | Get localization keys |
DraftsApi | GetDrafts | Get /drafts | List Drafts |
DraftsApi | GetLocalizationForDraft | Get /drafts/{draftId}/localizations | Get localizations on a draft |
DraftsApi | SaveLocalization | Put /drafts/{draftId}/localizations/{languageId} | Create or update a localization |
DraftsApi | SetTranslation | Put /drafts/{draftId}/localizations/{languageId}/translations | Set translations for language |
DraftsApi | SubmitDraftForApproval | Post /drafts/{draftId}/publishRequest | Submit the draft for approval |
LocalizationsApi | GetLocalizationById | Get /localizations/{localizationId} | Get Localization Object by ID |
TemplatesApi | GetTemplateById | Get /templates/{templateId} | Get Template by ID |
TemplatesApi | GetTemplates | Get /templates | List Templates |
Documentation For Models
- ApiError
- CompiledRead
- Cursor
- DraftMetaRead
- DraftRead
- DraftsRead
- InlineObject
- LocalizationKeyRead
- LocalizationMetaRead
- LocalizationRead
- TemplateMetaRead
- TemplateRead
- TemplatesRead
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
# Functions
CacheExpires helper function to determine remaining time before repeating a request.
NewAPIClient creates a new API client.
NewAPIResponse returns a new APIResonse object.
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
NewConfiguration returns a new Configuration object.
# Variables
ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAPIKey takes an APIKey as authentication for the request.
ContextBasicAuth takes BasicAuth as authentication for the request.
ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
# Structs
APIClient manages communication with the Dyspatch API API v2019.10 In most cases there should be only one, shared, APIClient.
ApiError possible errors from the api.
APIKey provides API key based authentication to a request passed via context using ContextAPIKey.
APIResponse stores the API response returned by the server.
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.
CompiledRead revision data.
Configuration stores the configuration of the API client.
Cursor Information about paginated results.
DraftMetaRead draft metadata.
DraftRead template draft metadata included latest draft revision.
DraftsRead list of draft metadata.
GenericOpenAPIError Provides access to the body, error and model on returned errors.
GetDraftsOpts Optional parameters for the method 'GetDrafts'.
GetTemplatesOpts Optional parameters for the method 'GetTemplates'.
InlineObject struct for InlineObject.
LocalizationKeyRead localization key.
LocalizationMetaRead localization metadata.
LocalizationRead localization metadata and latest revision for associated template.
ServerConfiguration stores the information about a server.
ServerVariable stores the information about a server variable.
TemplateMetaRead the template metadata.
TemplateRead list of template metadata.
TemplatesRead list of template metadata.
# Type aliases
DraftsApiService DraftsApi service.
LocalizationsApiService LocalizationsApi service.
TemplatesApiService TemplatesApi service.