onesky

package module
v0.0.0-...-246f9a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2015 License: GPL-2.0 Imports: 13 Imported by: 0

README

onesky-go

Build Status Code Climate Coverage Status GoDoc License

Go utils for working with OneSky translation service.

Examples

Example 1 - Download file
package main

import (
	"fmt"
	"github.com/SebastianCzoch/onesky-go"
)

func main() {
	onesky := onesky.Client{APIKey: "abcdef", Secret: "abcdef", ProjectID: 1}
	fmt.Println(onesky.DownloadFile("filename", "locale"))
}
Example 2 - Upload file
package main

import (
	"fmt"
	"github.com/SebastianCzoch/onesky-go"
)

func main() {
	onesky := onesky.Client{APIKey: "abcdef", Secret: "abcdef", ProjectID: 1}
	err := onesky.UploadFile("messages.yml", "YAML", "en-US")
	if err != nil {
		fmt.Println("Can not upload file")
	}
}
Example 3 - Delete file
package main

import (
	"fmt"
	"github.com/SebastianCzoch/onesky-go"
)

func main() {
	onesky := onesky.Client{APIKey: "abcdef", Secret: "abcdef", ProjectID: 1}
	err := onesky.DeleteFile("messages.yml")
	if err != nil {
		fmt.Println("Can not delete file")
	}
}
Example 4 - Get informations about uploaded files
package main

import (
	"fmt"
	"github.com/SebastianCzoch/onesky-go"
)

func main() {
	onesky := onesky.Client{APIKey: "abcdef", Secret: "abcdef", ProjectID: 1}
	list, err := onesky.ListFiles(1, 100)
	if err != nil {
		fmt.Println("Can not download list of uploaded files")
	}
	fmt.Println(list)
}

Install

$ go get github.com/SebastianCzoch/onesky-go

API

(c *Client) DownloadFile(fileName, locale string) (string, error)

Downloads translation file from OneSky.

Returns file content via string.

(c *Client) UploadFile(file, fileFormat, locale string) error

Upload translation file to OneSky.

  • file should be a full path to file
(c *Client) DeleteFile(fileName string) error

Permanently remove file from OneSky service (with translations)!

(c *Client) ListFiles(page, perPage int) ([]FileData, error)

Get informations about files uploaded to OneSky

Tests

$ go test ./...

License

GNU v2

Support

Issues for this project should be reported on GitHub issues

Staff responsible for project:

Documentation

Overview

Package onesky is go utils for working with OneSky translation service Copyright (c) 2015 Sebastian Czoch <sebastian@czoch.eu>. All rights reserved. Use of this source code is governed by a GNU v2 license found in the LICENSE file.

Index

Constants

View Source
const APIAddress = "https://platform.api.onesky.io"

APIAddress is https address to OneSky API

View Source
const APIVersion = "1"

API Version is OneSky API version which will be used

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Secret    string
	APIKey    string
	ProjectID int
}

Client is basics struct for this package contains Secret, APIKey and ProjectID which is needed to authorize in OneSky service

func (*Client) DeleteFile

func (c *Client) DeleteFile(fileName string) error

DeleteFile is method on Client struct which remove file from OneSky service

func (*Client) DownloadFile

func (c *Client) DownloadFile(fileName, locale string) (string, error)

DownloadFile is method on Client struct which download form OneSky service choosen file as string

func (*Client) ListFiles

func (c *Client) ListFiles(page, perPage int) ([]FileData, error)

ListFiles is method on Client struct which download form OneSky service informations about uploaded files

func (*Client) UploadFile

func (c *Client) UploadFile(file, fileFormat, locale string) (string, error)

UploadFile is method on Client struct which upload file to OneSky service

type FileData

type FileData struct {
	Name                string     `json:"name"`
	StringCount         int        `json:"string_count"`
	LastImport          LastImport `json:"last_import"`
	UpoladedAt          string     `json:"uploaded_at"`
	UpoladedAtTimestamp int        `json:"uploaded_at_timestamp"`
}

FileData is a struct which contains informations about file uploaded to OneSky service

type LastImport

type LastImport struct {
	ID     int    `json:"id"`
	Status string `json:"status"`
}

LastImport is a struct which contains informations about last upload

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL