public function test_get_languages() { $service = Gengo_Api::factory('service', $this->key, $this->secret); $service->getLanguages(); $body = $service->getResponseBody(); $response = json_decode($body, true); $this->assertEquals($response['opstat'], 'ok'); $this->assertTrue(isset($response['response'])); }
public function test_get_stats() { $service = Gengo_Api::factory('account', $this->key, $this->secret); $service->getStats(); $body = $service->getResponseBody(); $response = json_decode($body, true); $this->assertEquals($response['opstat'], 'ok'); $this->assertTrue(isset($response['response'])); $this->assertTrue(isset($response['response']['credits_spent'])); $this->assertTrue(isset($response['response']['user_since'])); }
<?php /** * Retrieve an array of preferred translators by langs and tier */ require_once '../init.php'; // TODO: this example assumes you set the 2 values below. $api_key = 'your-public-api-key'; $private_key = 'your-private-api-key'; // Get an instance of an Account Client $account = Gengo_Api::factory('account', $api_key, $private_key); // Request the balance. $account->getPreferredTranslators(); // Show the server response in depth if you need it. echo $account->getResponseBody(); /* * Typical answer: {"opstat":"ok","response":[ { "lc_src" : "en", "lc_tgt" : "ja", "tier" : "standard", "translators" : [ {"id" : 8596, "number_of_jobs" : 5, "last_login" : 1375824155}, {"id" : 24123, "number_of_jobs" : 2, "last_login" : 1372822132} ] }, { "lc_src" : "ja", "lc_tgt" : "en",
<?php /** * Delete a job already sent into Gengo. */ require_once '../init.php'; // TODO: this example assumes you replaced the 3 values below. $api_key = 'your-public-api-key'; $private_key = 'your private-api-key'; $job_id = 1; // Get an instance of Job Client $job_client = Gengo_Api::factory('job', $api_key, $private_key); // Cancel a job which has not been started by a translator. $job_client->cancel($job_id); // Display the server response. echo $job_client->getResponseBody(); /** * Typical response: {"opstat":"ok","response":{}} */
<?php /** * Returns detail of a glossary file */ require_once '../init.php'; // TODO: this example assumes you set the 3 values below. $api_key = 'your-public-api-key'; $private_key = 'your-private-api-key'; $glossary_id = 817; // Get an instance of an Service Client $service = Gengo_Api::factory('glossary', $api_key, $private_key); $service->setBaseUrl('https://api.gengo.com/'); $service->getGlossary($glossary_id); // Display server response. echo $service->getResponseBody(); /** * Typical response: * { * "opstat": "ok", * "response": { * "ctime": "2014-03-31 02:26:54.967180", * "customer_user_id": 154422, * "description": null, * "id": 817, * "is_public": false, * "source_language_code": "en-US", * "source_language_id": 8, * "status": 1, * "target_languages": [ * [
<?php /** * Returns supported translation language pairs, tiers, and credit prices. */ require_once '../init.php'; // TODO: this example assumes you set the 2 values below. $api_key = 'your-public-api-key'; $private_key = 'your private-api-key'; // Get an instance of an Service Client $service = Gengo_Api::factory('service', $api_key, $private_key); // Request the language pairs. $service->getLanguagePairs(); // Display server response. echo $service->getResponseBody(); /* * Typical partial response: {"opstat":"ok","response":[ {"lc_src":"de","lc_tgt":"en","tier":"standard","unit_price":"0.0500"}, {"lc_src":"de","lc_tgt":"en","tier":"pro","unit_price":"0.1000"}, {"lc_src":"de","lc_tgt":"en","tier":"ultra","unit_price":"0.1500"}, {"lc_src":"en","lc_tgt":"de","tier":"standard","unit_price":"0.0500"}, {"lc_src":"en","lc_tgt":"de","tier":"pro","unit_price":"0.1000"}, {"lc_src":"en","lc_tgt":"de","tier":"ultra","unit_price":"0.1500"}, {"lc_src":"en","lc_tgt":"de","tier":"machine","unit_price":"0.0000"}, {"lc_src":"en","lc_tgt":"es","tier":"standard","unit_price":"0.0500"}, ... ]} */
<?php /** * Delete an order, cancels all available jobs and the order itself */ require_once '../init.php'; // TODO: this example assumes you replaced the 3 values below. $api_key = 'your-public-api-key'; $private_key = 'your private-api-key'; $order_id = 1; // Get an instance of Job Client $order_client = Gengo_Api::factory('order', $api_key, $private_key); // Cancel a job which has not been started by a translator. $order_client->cancel($order_id); // Display the server response. echo $order_client->getResponseBody(); /** * Typical response: {"opstat":"ok","response":{}} */
public function test_jobs_max_chars() { $job1 = array('type' => 'text', 'slug' => 'Language name', 'body_src' => 'Japanese', 'lc_src' => 'en', 'lc_tgt' => 'ja', 'tier' => 'standard', 'force' => 1, 'max_chars' => 3); $job2 = array('type' => 'text', 'slug' => 'Name of Country', 'body_src' => 'Italia', 'lc_src' => 'en', 'lc_tgt' => 'ja', 'tier' => 'standard', 'force' => 1, 'max_chars' => 4); $jobs = array('job_01' => $job1, 'job_02' => $job2); // Get an instance of Jobs Client $jobs_client = Gengo_Api::factory('jobs', $this->key, $this->secret); // Post the jobs. The second parameter is optional and determines whether or // not the jobs are submitted as a group (default: false). $jobs_client->postJobs($jobs); // Display the server response. $body = $jobs_client->getResponseBody(); $response = json_decode($body, true); $this->assertEquals($response['opstat'], 'ok'); $this->assertTrue(isset($response['response'])); $order_id = $response['response']['order_id']; return $order_id; }