-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclient.go
More file actions
57 lines (51 loc) · 2.57 KB
/
client.go
File metadata and controls
57 lines (51 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2020 Smartling
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Package smartling is a client implementation of the Smartling Translation
// API v2 as documented at https://help.smartling.com/v1.0/reference
package smartling
import (
"io"
"github.com/Smartling/api-sdk-go/helpers/sm_client"
"github.com/Smartling/api-sdk-go/helpers/sm_file"
)
type APIClient interface {
Authenticate() error
DeleteFile(projectID string, uri string) error
DownloadFile(projectID string, uri string) (io.ReadCloser, error)
DownloadTranslation(projectID string, localeID string, request FileDownloadRequest) (io.ReadCloser, error)
GetFileStatus(projectID string, fileURI string) (*smfile.FileStatus, error)
GetProjectDetails(projectID string) (*ProjectDetails, error)
Import(projectID string, localeID string, request smfile.ImportRequest) (*FileImportResult, error)
ListAllFiles(projectID string, request smfile.FilesListRequest) ([]smfile.File, error)
ListProjects(accountID string, request smfile.ProjectsListRequest) (*ProjectsList, error)
RenameFile(projectID string, oldURI string, newURI string) error
UploadFile(projectID string, request smfile.FileUploadRequest) (*smfile.FileUploadResult, error)
}
// HttpAPIClient represents http Smartling API client.
type HttpAPIClient struct {
Client *smclient.Client
}
// NewHttpAPIClient returns new http Smartling API client with specified authentication
// data.
func NewHttpAPIClient(userID, tokenSecret string) *HttpAPIClient {
smclient := smclient.NewClient(userID, tokenSecret)
return &HttpAPIClient{
Client: smclient,
}
}