Skip to content

Smartcat Perl API library generated by swagger-codegen

License

Notifications You must be signed in to change notification settings

ta2-1/smartcat-api-perl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Smartcat::Client::Role - a Moose role for the Smartcat Integration API

This module is generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen. It is used and tested for Smartcat::App only.

VERSION

Automatically generated by the Swagger Codegen project:

  • API version: v1
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.languages.PerlClientCodegen

A note on Moose

This role is the only component of the library that uses Moose. See Smartcat::Client::ApiFactory for non-Moosey usage.

SYNOPSIS

The Perl Swagger Codegen project builds a library of Perl modules to interact with a web service defined by a OpenAPI Specification. See below for how to build the library.

This module provides an interface to the generated library. All the classes, objects, and methods (well, not quite *all*, see below) are flattened into this role.

    package MyApp;
    use Moose;
    with 'Smartcat::Client::Role';

    package main;

    my $api = MyApp->new({ tokens => $tokens });

    my $pet = $api->get_pet_by_id(pet_id => $pet_id);

Structure of the library

The library consists of a set of API classes, one for each endpoint. These APIs implement the method calls available on each endpoint.

Additionally, there is a set of "object" classes, which represent the objects returned by and sent to the methods on the endpoints.

An API factory class is provided, which builds instances of each endpoint API.

This Moose role flattens all the methods from the endpoint APIs onto the consuming class. It also provides methods to retrieve the endpoint API objects, and the API factory object, should you need it.

For documentation of all these methods, see AUTOMATIC DOCUMENTATION below.

Configuring authentication

In the normal case, the OpenAPI Spec will describe what parameters are required and where to put them. You just need to supply the tokens.

my $tokens = {
    # basic
    username => $username,
    password => $password,

    # oauth
    access_token => $oauth_token,

    # keys
    $some_key => { token => $token,
                   prefix => $prefix,
                   in => $in,             # 'head||query',
                   },

    $another => { token => $token,
                  prefix => $prefix,
                  in => $in,              # 'head||query',
                  },
    ...,

    };

    my $api = MyApp->new({ tokens => $tokens });

Note these are all optional, as are prefix and in, and depend on the API you are accessing. Usually prefix and in will be determined by the code generator from the spec and you will not need to set them at run time. If not, in will default to 'head' and prefix to the empty string.

The tokens will be placed in a Smartcat::Client::Configuration instance as follows, but you don't need to know about this.

  • $cfg->{username}

    String. The username for basic auth.

  • $cfg->{password}

    String. The password for basic auth.

  • $cfg->{api_key}

    Hashref. Keyed on the name of each key (there can be multiple tokens).

          $cfg->{api_key} = {
                  secretKey => 'aaaabbbbccccdddd',
                  anotherKey => '1111222233334444',
                  };
    
  • $cfg->{api_key_prefix}

    Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix.

          $cfg->{api_key_prefix} = {
                  secretKey => 'string',
                  anotherKey => 'same or some other string',
                  };
    
  • $cfg->{access_token}

    String. The OAuth access token.

METHODS

base_url

The generated code has the base_url already set as a default value. This method returns the current value of base_url.

api_factory

Returns an API factory object. You probably won't need to call this directly.

    $self->api_factory('Pet'); # returns a Smartcat::Client::PetApi instance

    $self->pet_api;            # the same

MISSING METHODS

Most of the methods on the API are delegated to individual endpoint API objects (e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the same method name (e.g. new()), these methods can't be delegated. So you need to call $api->pet_api->new().

In principle, every API is susceptible to the presence of a few, random, undelegatable method names. In practice, because of the way method names are constructed, it's unlikely in general that any methods will be undelegatable, except for:

    new()
    class_documentation()
    method_documentation()

To call these methods, you need to get a handle on the relevant object, either by calling $api->foo_api or by retrieving an object, e.g. $api->get_pet_by_id(pet_id => $pet_id). They are class methods, so you could also call them on class names.

BUILDING YOUR LIBRARY

See the homepage https://github.com/swagger-api/swagger-codegen for full details. But briefly, clone the git repository, build the codegen codebase, set up your build config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed.

The config file should specify the project name for the generated library:

    {"moduleName":"WWW::MyProjectName"}

Your library files will be built under WWW::MyProjectName.

      $ git clone https://github.com/swagger-api/swagger-codegen.git
      $ cd swagger-codegen
      $ mvn package
      $ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-c /path/to/config/file.json \
-o /path/to/output/folder

Bang, all done. Run the autodoc script in the bin directory to see the API you just built.

AUTOMATIC DOCUMENTATION

You can print out a summary of the generated API by running the included autodoc script in the bin directory of your generated library. A few output formats are supported:

      Usage: autodoc [OPTION]

-w           wide format (default)
-n           narrow format
-p           POD format
-H           HTML format
-m           Markdown format
-h           print this help message
-c           your application class

The -c option allows you to load and inspect your own application. A dummy namespace is used if you don't supply your own class.

DOCUMENTATION FROM THE OpenAPI Spec

Additional documentation for each class and method may be provided by the Swagger spec. If so, this is available via the class_documentation() and method_documentation() methods on each generated object class, and the method_documentation() method on the endpoint API classes:

    my $cmdoc = $api->pet_api->method_documentation->{$method_name};

    my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
    my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name};

Each of these calls returns a hashref with various useful pieces of information.

LOAD THE MODULES

To load the API packages:

use Smartcat::Client::AccountApi;
use Smartcat::Client::CallbackApi;
use Smartcat::Client::ClientApi;
use Smartcat::Client::DirectoriesApi;
use Smartcat::Client::DocumentApi;
use Smartcat::Client::DocumentExportApi;
use Smartcat::Client::GlossaryApi;
use Smartcat::Client::InvoiceApi;
use Smartcat::Client::PlaceholderFormatApiApi;
use Smartcat::Client::ProjectApi;
use Smartcat::Client::TranslationMemoriesApi;

To load the models:

use Smartcat::Client::Object::AccountModel;
use Smartcat::Client::Object::AdditionalHeaderModel;
use Smartcat::Client::Object::AssignExecutivesRequestModel;
use Smartcat::Client::Object::AssignMyTeamExecutivesRequestModel;
use Smartcat::Client::Object::AssignedExecutiveModel;
use Smartcat::Client::Object::BilingualFileImportSetingsModel;
use Smartcat::Client::Object::CallbackErrorModel;
use Smartcat::Client::Object::CallbackPropertyModel;
use Smartcat::Client::Object::CancelInvoiceModel;
use Smartcat::Client::Object::ClientModel;
use Smartcat::Client::Object::CreateDocumentPropertyModel;
use Smartcat::Client::Object::CreateInvoiceModel;
use Smartcat::Client::Object::CreateProjectModel;
use Smartcat::Client::Object::CreateTranslationMemoryModel;
use Smartcat::Client::Object::DirectoryItemModel;
use Smartcat::Client::Object::DirectoryModel;
use Smartcat::Client::Object::DocumentModel;
use Smartcat::Client::Object::DocumentStatisticsModel;
use Smartcat::Client::Object::DocumentTargetId;
use Smartcat::Client::Object::DocumentWorkflowStageModel;
use Smartcat::Client::Object::Executive;
use Smartcat::Client::Object::ExecutiveModel;
use Smartcat::Client::Object::ExecutiveStatisticsModel;
use Smartcat::Client::Object::ExportDocumentTaskModel;
use Smartcat::Client::Object::FileFormatModel;
use Smartcat::Client::Object::GlossaryModel;
use Smartcat::Client::Object::ImportJobModel;
use Smartcat::Client::Object::InhouseTranslatorCreationModel;
use Smartcat::Client::Object::LspServiceModel;
use Smartcat::Client::Object::MTEngineModel;
use Smartcat::Client::Object::ModelWithFilesCreateProjectModel;
use Smartcat::Client::Object::ModelWithFilesIReadOnlyListCreateDocumentPropertyModel;
use Smartcat::Client::Object::ModelWithFilesUploadDocumentPropertiesModel;
use Smartcat::Client::Object::MyTeamMemberModel;
use Smartcat::Client::Object::MyTeamSearchRequestModel;
use Smartcat::Client::Object::NetRateModel;
use Smartcat::Client::Object::Object;
use Smartcat::Client::Object::PlaceholderFormatModel;
use Smartcat::Client::Object::ProjectChangesModel;
use Smartcat::Client::Object::ProjectModel;
use Smartcat::Client::Object::ProjectStatisticsModel;
use Smartcat::Client::Object::ProjectStatisticsObsoleteModel;
use Smartcat::Client::Object::ProjectTranslationMemoryModel;
use Smartcat::Client::Object::ProjectWorkflowStageModel;
use Smartcat::Client::Object::SegmentModel;
use Smartcat::Client::Object::SegmentTagModel;
use Smartcat::Client::Object::SegmentWithMatchesModel;
use Smartcat::Client::Object::ServiceModel;
use Smartcat::Client::Object::StatisticsRowModel;
use Smartcat::Client::Object::TMImportTaskModel;
use Smartcat::Client::Object::TMMatchesRequest;
use Smartcat::Client::Object::TMRangeRateModel;
use Smartcat::Client::Object::TagsFromUnit;
use Smartcat::Client::Object::TranslationMemoriesForLanguageModel;
use Smartcat::Client::Object::TranslationMemoryForProjectModel;
use Smartcat::Client::Object::TranslationMemoryModel;
use Smartcat::Client::Object::UploadDocumentPropertiesModel;
use Smartcat::Client::Object::UploadedFile;

GETTING STARTED

Put the Perl SDK under the 'lib' folder in your project directory, then run the following

#!/usr/bin/perl
use lib 'lib';
use strict;
use warnings;
# load the API package
use Smartcat::Client::AccountApi;
use Smartcat::Client::CallbackApi;
use Smartcat::Client::ClientApi;
use Smartcat::Client::DirectoriesApi;
use Smartcat::Client::DocumentApi;
use Smartcat::Client::DocumentExportApi;
use Smartcat::Client::GlossaryApi;
use Smartcat::Client::InvoiceApi;
use Smartcat::Client::PlaceholderFormatApiApi;
use Smartcat::Client::ProjectApi;
use Smartcat::Client::TranslationMemoriesApi;

# load the models
use Smartcat::Client::Object::AccountModel;
use Smartcat::Client::Object::AdditionalHeaderModel;
use Smartcat::Client::Object::AssignExecutivesRequestModel;
use Smartcat::Client::Object::AssignMyTeamExecutivesRequestModel;
use Smartcat::Client::Object::AssignedExecutiveModel;
use Smartcat::Client::Object::BilingualFileImportSetingsModel;
use Smartcat::Client::Object::CallbackErrorModel;
use Smartcat::Client::Object::CallbackPropertyModel;
use Smartcat::Client::Object::CancelInvoiceModel;
use Smartcat::Client::Object::ClientModel;
use Smartcat::Client::Object::CreateDocumentPropertyModel;
use Smartcat::Client::Object::CreateInvoiceModel;
use Smartcat::Client::Object::CreateProjectModel;
use Smartcat::Client::Object::CreateTranslationMemoryModel;
use Smartcat::Client::Object::DirectoryItemModel;
use Smartcat::Client::Object::DirectoryModel;
use Smartcat::Client::Object::DocumentModel;
use Smartcat::Client::Object::DocumentStatisticsModel;
use Smartcat::Client::Object::DocumentTargetId;
use Smartcat::Client::Object::DocumentWorkflowStageModel;
use Smartcat::Client::Object::Executive;
use Smartcat::Client::Object::ExecutiveModel;
use Smartcat::Client::Object::ExecutiveStatisticsModel;
use Smartcat::Client::Object::ExportDocumentTaskModel;
use Smartcat::Client::Object::FileFormatModel;
use Smartcat::Client::Object::GlossaryModel;
use Smartcat::Client::Object::ImportJobModel;
use Smartcat::Client::Object::InhouseTranslatorCreationModel;
use Smartcat::Client::Object::LspServiceModel;
use Smartcat::Client::Object::MTEngineModel;
use Smartcat::Client::Object::ModelWithFilesCreateProjectModel;
use Smartcat::Client::Object::ModelWithFilesIReadOnlyListCreateDocumentPropertyModel;
use Smartcat::Client::Object::ModelWithFilesUploadDocumentPropertiesModel;
use Smartcat::Client::Object::MyTeamMemberModel;
use Smartcat::Client::Object::MyTeamSearchRequestModel;
use Smartcat::Client::Object::NetRateModel;
use Smartcat::Client::Object::Object;
use Smartcat::Client::Object::PlaceholderFormatModel;
use Smartcat::Client::Object::ProjectChangesModel;
use Smartcat::Client::Object::ProjectModel;
use Smartcat::Client::Object::ProjectStatisticsModel;
use Smartcat::Client::Object::ProjectStatisticsObsoleteModel;
use Smartcat::Client::Object::ProjectTranslationMemoryModel;
use Smartcat::Client::Object::ProjectWorkflowStageModel;
use Smartcat::Client::Object::SegmentModel;
use Smartcat::Client::Object::SegmentTagModel;
use Smartcat::Client::Object::SegmentWithMatchesModel;
use Smartcat::Client::Object::ServiceModel;
use Smartcat::Client::Object::StatisticsRowModel;
use Smartcat::Client::Object::TMImportTaskModel;
use Smartcat::Client::Object::TMMatchesRequest;
use Smartcat::Client::Object::TMRangeRateModel;
use Smartcat::Client::Object::TagsFromUnit;
use Smartcat::Client::Object::TranslationMemoriesForLanguageModel;
use Smartcat::Client::Object::TranslationMemoryForProjectModel;
use Smartcat::Client::Object::TranslationMemoryModel;
use Smartcat::Client::Object::UploadDocumentPropertiesModel;
use Smartcat::Client::Object::UploadedFile;

# for displaying the API response data
use Data::Dumper;
use Smartcat::Client::;

my $api_instance = Smartcat::Client::->new(
);

my $model = Smartcat::Client::Object::InhouseTranslatorCreationModel->new(); # InhouseTranslatorCreationModel | 

eval {
    my $result = $api_instance->account_add_inhouse_translator(model => $model);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling AccountApi->account_add_inhouse_translator: $@\n";
}

DOCUMENTATION FOR API ENDPOINTS

All URIs are relative to https://smartcat.ai

Class Method HTTP request Description
AccountApi account_add_inhouse_translator POST /api/integration/v1/account/myTeam
AccountApi account_get_account_info GET /api/integration/v1/account Receiving the account details
AccountApi account_get_lsp_services GET /api/integration/v1/account/lsp/services
AccountApi account_get_mt_engines_for_account GET /api/integration/v1/account/mtengines Receiving MT engines available for the account
AccountApi account_get_my_team_member_by_external_id GET /api/integration/v1/account/myTeam
AccountApi account_get_my_team_member_by_id GET /api/integration/v1/account/myTeam/{userId}
AccountApi account_remove_user_from_my_team DELETE /api/integration/v1/account/myTeam/{userId}
AccountApi account_search_my_team POST /api/integration/v1/account/searchMyTeam
CallbackApi callback_delete DELETE /api/integration/v1/callback Resetting the configuration of notifications reception
CallbackApi callback_get GET /api/integration/v1/callback Reading configurations of notifications reception of the account
CallbackApi callback_get_last_errors GET /api/integration/v1/callback/lastErrors Reading the recent sending errors
CallbackApi callback_update POST /api/integration/v1/callback
ClientApi client_create_client POST /api/integration/v1/client/create Create a new client with the specified name and return their ID. Simply return the ID if a client with that name already exists
ClientApi client_get_client GET /api/integration/v1/client/{clientId}
ClientApi client_set_client_net_rate PUT /api/integration/v1/client/{clientId}/set
DirectoriesApi directories_get GET /api/integration/v1/directory
DirectoriesApi directories_get_supported_formats_for_account GET /api/integration/v1/directory/formats Receive parsing formats supported by the account
DocumentApi document_assign_executives POST /api/integration/v1/document/assign
DocumentApi document_assign_freelancers_to_document POST /api/integration/v1/document/assignFreelancers Split the document into equal segments according to the number of words and assign each freelancer to one segment
DocumentApi document_assign_my_team_executives POST /api/integration/v1/document/assignFromMyTeam
DocumentApi document_delete DELETE /api/integration/v1/document Delete one or several documents
DocumentApi document_get GET /api/integration/v1/document Receive the document details
DocumentApi document_get_auth_url GET /api/integration/v1/document/getAuthUrl
DocumentApi document_get_statistics GET /api/integration/v1/document/statistics
DocumentApi document_get_translation_status GET /api/integration/v1/document/translate/status Receive the status of adding document translation
DocumentApi document_get_translations_import_result GET /api/integration/v1/document/translate/result
DocumentApi document_rename PUT /api/integration/v1/document/rename Rename the assigned document
DocumentApi document_translate PUT /api/integration/v1/document/translate
DocumentApi document_translate_with_xliff PUT /api/integration/v1/document/translateWithXliff
DocumentApi document_update PUT /api/integration/v1/document/update
DocumentExportApi document_export_download_export_result GET /api/integration/v1/document/export/{taskId} Download the results of export
DocumentExportApi document_export_request_export POST /api/integration/v1/document/export
GlossaryApi glossary_get_glossaries GET /api/integration/v1/glossaries
InvoiceApi invoice_import_job POST /api/integration/v1/invoice/job
PlaceholderFormatApiApi placeholder_format_api_get_placeholder_formats GET /api/integration/v1/placeholders
PlaceholderFormatApiApi placeholder_format_api_update_placeholder_formats PUT /api/integration/v1/placeholders
PlaceholderFormatApiApi placeholder_format_api_validate_placeholder_format GET /api/integration/v1/placeholders/validate
ProjectApi project_add_document POST /api/integration/v1/project/document
ProjectApi project_add_language POST /api/integration/v1/project/language Add a new target language to the project
ProjectApi project_build_statistics POST /api/integration/v1/project/{projectId}/statistics/build
ProjectApi project_cancel_project POST /api/integration/v1/project/cancel Cancel the project
ProjectApi project_complete_project POST /api/integration/v1/project/complete
ProjectApi project_create_project POST /api/integration/v1/project/create
ProjectApi project_delete DELETE /api/integration/v1/project/{projectId} Delete the project
ProjectApi project_get GET /api/integration/v1/project/{projectId} Receive the project model
ProjectApi project_get_all GET /api/integration/v1/project/list
ProjectApi project_get_completed_work_statistics GET /api/integration/v1/project/{projectId}/completedWorkStatistics Receiving statistics for the completed parts of the project
ProjectApi project_get_glossaries GET /api/integration/v1/project/{projectId}/glossaries
ProjectApi project_get_project_statistics GET /api/integration/v2/project/{projectId}/statistics Receive statistics
ProjectApi project_get_project_statistics_obsolete GET /api/integration/v1/project/{projectId}/statistics (This method is obsolete. Newer version can be found here: /api/integrationv2/project/{projectId}/statistics) Receive statistics
ProjectApi project_get_project_translation_memories GET /api/integration/v1/project/{projectId}/translationmemories Receiving a list of the TMs plugged into the project
ProjectApi project_restore_project POST /api/integration/v1/project/restore Restore the project
ProjectApi project_set_glossaries PUT /api/integration/v1/project/{projectId}/glossaries
ProjectApi project_set_project_translation_memories_by_languages POST /api/integration/v1/project/{projectId}/translationmemories/bylanguages
ProjectApi project_set_translation_memories_for_whole_project POST /api/integration/v1/project/{projectId}/translationmemories
ProjectApi project_update_project PUT /api/integration/v1/project/{projectId}
TranslationMemoriesApi translation_memories_create_empty_tm POST /api/integration/v1/translationmemory
TranslationMemoriesApi translation_memories_export_file GET /api/integration/v1/translationmemory/{tmId}/file
TranslationMemoriesApi translation_memories_get_meta_info GET /api/integration/v1/translationmemory/{tmId} Receiving TM details
TranslationMemoriesApi translation_memories_get_pending_tasks GET /api/integration/v1/translationmemory/task Receive a collection of TMX import tasks
TranslationMemoriesApi translation_memories_get_tm_translations POST /api/integration/v1/translationmemory/matches
TranslationMemoriesApi translation_memories_get_translation_memories_batch GET /api/integration/v1/translationmemory
TranslationMemoriesApi translation_memories_import POST /api/integration/v1/translationmemory/{tmId} TMX import to TM
TranslationMemoriesApi translation_memories_remove_specific_import_task DELETE /api/integration/v1/translationmemory/task/{taskId} Remove a given import task
TranslationMemoriesApi translation_memories_remove_translation_memory DELETE /api/integration/v1/translationmemory/{tmId} Delete the TM
TranslationMemoriesApi translation_memories_set_tm_target_languages PUT /api/integration/v1/translationmemory/{tmId}/targets Set an array of target languages required by the TM

DOCUMENTATION FOR MODELS

DOCUMENTATION FOR AUTHORIZATION

All endpoints do not require authorization.

About

Smartcat Perl API library generated by swagger-codegen

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages