Class: PhraseApp::Client
- Inherits:
-
Object
- Object
- PhraseApp::Client
- Defined in:
- lib/phraseapp-ruby.rb
Class Method Summary collapse
-
.authorization_create(params) ⇒ Object
Create a new authorization.
-
.authorization_delete(id) ⇒ Object
Delete an existing authorization.
-
.authorization_show(id) ⇒ Object
Get details on a single authorization.
-
.authorization_update(id, params) ⇒ Object
Update an existing authorization.
-
.authorizations_list(page, per_page) ⇒ Object
List all your authorizations.
-
.comment_create(project_id, key_id, params) ⇒ Object
Create a new comment for a key.
-
.comment_delete(project_id, key_id, id) ⇒ Object
Delete an existing comment.
-
.comment_mark_check(project_id, key_id, id) ⇒ Object
Check if comment was marked as read.
-
.comment_mark_read(project_id, key_id, id) ⇒ Object
Mark a comment as read.
-
.comment_mark_unread(project_id, key_id, id) ⇒ Object
Mark a comment as unread.
-
.comment_show(project_id, key_id, id) ⇒ Object
Get details on a single comment.
-
.comment_update(project_id, key_id, id, params) ⇒ Object
Update an existing comment.
-
.comments_list(project_id, key_id, page, per_page) ⇒ Object
List all comments for a key.
-
.exclude_rule_create(project_id, params) ⇒ Object
Create a new blacklisted key.
-
.exclude_rule_delete(project_id, id) ⇒ Object
Delete an existing blacklisted key.
-
.exclude_rule_show(project_id, id) ⇒ Object
Get details on a single blacklisted key for a given project.
-
.exclude_rule_update(project_id, id, params) ⇒ Object
Update an existing blacklisted key.
-
.exclude_rules_index(project_id, page, per_page) ⇒ Object
List all blacklisted keys for the given project.
-
.formats_list(page, per_page) ⇒ Object
Get a handy list of all localization file formats supported in PhraseApp.
-
.key_create(project_id, params) ⇒ Object
Create a new key.
-
.key_delete(project_id, id) ⇒ Object
Delete an existing key.
-
.key_show(project_id, id) ⇒ Object
Get details on a single key for a given project.
-
.key_update(project_id, id, params) ⇒ Object
Update an existing key.
-
.keys_delete(project_id, params) ⇒ Object
Delete all keys matching query.
-
.keys_list(project_id, page, per_page, params) ⇒ Object
List all keys for the given project.
-
.keys_search(project_id, page, per_page, params) ⇒ Object
List all keys for the given project matching query.
-
.keys_tag(project_id, params) ⇒ Object
Tags all keys matching query.
-
.keys_untag(project_id, params) ⇒ Object
Removes specified tags from keys matching query.
-
.locale_create(project_id, params) ⇒ Object
Create a new locale.
-
.locale_delete(project_id, id) ⇒ Object
Delete an existing locale.
-
.locale_download(project_id, id, params) ⇒ Object
Download a locale in a specific file format.
-
.locale_show(project_id, id) ⇒ Object
Get details on a single locale for a given project.
-
.locale_update(project_id, id, params) ⇒ Object
Update an existing locale.
-
.locales_list(project_id, page, per_page) ⇒ Object
List all locales for the given project.
-
.order_confirm(project_id, id) ⇒ Object
Confirm an existing order and send it to the provider for translation.
-
.order_create(project_id, params) ⇒ Object
Create a new order.
-
.order_delete(project_id, id) ⇒ Object
Cancel an existing order.
-
.order_show(project_id, id) ⇒ Object
Get details on a single order.
-
.orders_list(project_id, page, per_page) ⇒ Object
List all orders for the given project.
-
.project_create(params) ⇒ Object
Create a new project.
-
.project_delete(id) ⇒ Object
Delete an existing project.
-
.project_show(id) ⇒ Object
Get details on a single project.
-
.project_update(id, params) ⇒ Object
Update an existing project.
-
.projects_list(page, per_page) ⇒ Object
List all projects the current user has access to.
-
.show_user ⇒ Object
Show details for current User.
-
.styleguide_create(project_id, params) ⇒ Object
Create a new style guide.
-
.styleguide_delete(project_id, id) ⇒ Object
Delete an existing style guide.
-
.styleguide_show(project_id, id) ⇒ Object
Get details on a single style guide.
-
.styleguide_update(project_id, id, params) ⇒ Object
Update an existing style guide.
-
.styleguides_list(project_id, page, per_page) ⇒ Object
List all styleguides for the given project.
-
.tag_create(project_id, params) ⇒ Object
Create a new tag.
-
.tag_delete(project_id, name) ⇒ Object
Delete an existing tag.
-
.tag_show(project_id, name) ⇒ Object
Get details and progress information on a single tag for a given project.
-
.tags_list(project_id, page, per_page) ⇒ Object
List all tags for the given project.
-
.translation_create(project_id, params) ⇒ Object
Create a translation.
-
.translation_show(project_id, id) ⇒ Object
Get details on a single translation.
-
.translation_update(project_id, id, params) ⇒ Object
Update an existing translation.
-
.translations_by_key(project_id, key_id, page, per_page, params) ⇒ Object
List translations for a specific key.
-
.translations_by_locale(project_id, locale_id, page, per_page, params) ⇒ Object
List translations for a specific locale.
-
.translations_exclude(project_id, params) ⇒ Object
Exclude translations matching query from locale export.
-
.translations_include(project_id, params) ⇒ Object
Include translations matching query in locale export.
-
.translations_list(project_id, page, per_page, params) ⇒ Object
List translations for the given project.
-
.translations_search(project_id, page, per_page, params) ⇒ Object
List translations for the given project if you exceed GET request limitations on translations list.
-
.translations_unverify(project_id, params) ⇒ Object
Mark translations matching query as unverified.
-
.translations_verify(project_id, params) ⇒ Object
Verify translations matching query.
-
.upload_create(project_id, params) ⇒ Object
Upload a new language file.
-
.upload_show(project_id, id) ⇒ Object
View details and summary for a single upload.
-
.version_show(project_id, translation_id, id) ⇒ Object
Get details on a single version.
-
.versions_list(project_id, translation_id, page, per_page) ⇒ Object
List all versions for the given translation.
Class Method Details
.authorization_create(params) ⇒ Object
Create a new authorization.
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 |
# File 'lib/phraseapp-ruby.rb', line 1180 def self.(params) path = sprintf("/v2/authorizations") data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::AuthorizationCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::AuthorizationCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::AuthorizationWithToken.new(JSON.load(rc.body)), err end |
.authorization_delete(id) ⇒ Object
Delete an existing authorization. API calls using that token will stop working.
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'lib/phraseapp-ruby.rb', line 1206 def self.(id) path = sprintf("/v2/authorizations/%s", id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.authorization_show(id) ⇒ Object
Get details on a single authorization.
1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 |
# File 'lib/phraseapp-ruby.rb', line 1221 def self.(id) path = sprintf("/v2/authorizations/%s", id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::Authorization.new(JSON.load(rc.body)), err end |
.authorization_update(id, params) ⇒ Object
Update an existing authorization.
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
# File 'lib/phraseapp-ruby.rb', line 1236 def self.(id, params) path = sprintf("/v2/authorizations/%s", id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::AuthorizationUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::AuthorizationUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::Authorization.new(JSON.load(rc.body)), err end |
.authorizations_list(page, per_page) ⇒ Object
List all your authorizations.
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 |
# File 'lib/phraseapp-ruby.rb', line 1262 def self.(page, per_page) path = sprintf("/v2/authorizations") data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Authorization.new(item) }, err end |
.comment_create(project_id, key_id, params) ⇒ Object
Create a new comment for a key.
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'lib/phraseapp-ruby.rb', line 1277 def self.comment_create(project_id, key_id, params) path = sprintf("/v2/projects/%s/keys/%s/comments", project_id, key_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::CommentCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::CommentCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::Comment.new(JSON.load(rc.body)), err end |
.comment_delete(project_id, key_id, id) ⇒ Object
Delete an existing comment.
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 |
# File 'lib/phraseapp-ruby.rb', line 1303 def self.comment_delete(project_id, key_id, id) path = sprintf("/v2/projects/%s/keys/%s/comments/%s", project_id, key_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.comment_mark_check(project_id, key_id, id) ⇒ Object
Check if comment was marked as read. Returns 204 if read, 404 if unread.
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
# File 'lib/phraseapp-ruby.rb', line 1318 def self.comment_mark_check(project_id, key_id, id) path = sprintf("/v2/projects/%s/keys/%s/comments/%s/read", project_id, key_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.comment_mark_read(project_id, key_id, id) ⇒ Object
Mark a comment as read
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 |
# File 'lib/phraseapp-ruby.rb', line 1333 def self.comment_mark_read(project_id, key_id, id) path = sprintf("/v2/projects/%s/keys/%s/comments/%s/read", project_id, key_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.comment_mark_unread(project_id, key_id, id) ⇒ Object
Mark a comment as unread
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
# File 'lib/phraseapp-ruby.rb', line 1348 def self.comment_mark_unread(project_id, key_id, id) path = sprintf("/v2/projects/%s/keys/%s/comments/%s/read", project_id, key_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.comment_show(project_id, key_id, id) ⇒ Object
Get details on a single comment.
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
# File 'lib/phraseapp-ruby.rb', line 1363 def self.comment_show(project_id, key_id, id) path = sprintf("/v2/projects/%s/keys/%s/comments/%s", project_id, key_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::Comment.new(JSON.load(rc.body)), err end |
.comment_update(project_id, key_id, id, params) ⇒ Object
Update an existing comment.
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 |
# File 'lib/phraseapp-ruby.rb', line 1378 def self.comment_update(project_id, key_id, id, params) path = sprintf("/v2/projects/%s/keys/%s/comments/%s", project_id, key_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::CommentUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::CommentUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::Comment.new(JSON.load(rc.body)), err end |
.comments_list(project_id, key_id, page, per_page) ⇒ Object
List all comments for a key.
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 |
# File 'lib/phraseapp-ruby.rb', line 1404 def self.comments_list(project_id, key_id, page, per_page) path = sprintf("/v2/projects/%s/keys/%s/comments", project_id, key_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Comment.new(item) }, err end |
.exclude_rule_create(project_id, params) ⇒ Object
Create a new blacklisted key.
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 |
# File 'lib/phraseapp-ruby.rb', line 1419 def self.exclude_rule_create(project_id, params) path = sprintf("/v2/projects/%s/blacklisted_keys", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::ExcludeRuleCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::ExcludeRuleCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::BlacklistedKey.new(JSON.load(rc.body)), err end |
.exclude_rule_delete(project_id, id) ⇒ Object
Delete an existing blacklisted key.
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 |
# File 'lib/phraseapp-ruby.rb', line 1445 def self.exclude_rule_delete(project_id, id) path = sprintf("/v2/projects/%s/blacklisted_keys/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.exclude_rule_show(project_id, id) ⇒ Object
Get details on a single blacklisted key for a given project.
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 |
# File 'lib/phraseapp-ruby.rb', line 1460 def self.exclude_rule_show(project_id, id) path = sprintf("/v2/projects/%s/blacklisted_keys/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::BlacklistedKey.new(JSON.load(rc.body)), err end |
.exclude_rule_update(project_id, id, params) ⇒ Object
Update an existing blacklisted key.
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 |
# File 'lib/phraseapp-ruby.rb', line 1475 def self.exclude_rule_update(project_id, id, params) path = sprintf("/v2/projects/%s/blacklisted_keys/%s", project_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::ExcludeRuleUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::ExcludeRuleUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::BlacklistedKey.new(JSON.load(rc.body)), err end |
.exclude_rules_index(project_id, page, per_page) ⇒ Object
List all blacklisted keys for the given project.
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 |
# File 'lib/phraseapp-ruby.rb', line 1501 def self.exclude_rules_index(project_id, page, per_page) path = sprintf("/v2/projects/%s/blacklisted_keys", project_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::BlacklistedKey.new(item) }, err end |
.formats_list(page, per_page) ⇒ Object
Get a handy list of all localization file formats supported in PhraseApp.
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 |
# File 'lib/phraseapp-ruby.rb', line 1516 def self.formats_list(page, per_page) path = sprintf("/v2/formats") data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Format.new(item) }, err end |
.key_create(project_id, params) ⇒ Object
Create a new key.
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 |
# File 'lib/phraseapp-ruby.rb', line 1531 def self.key_create(project_id, params) path = sprintf("/v2/projects/%s/keys", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeyCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeyCreateParams") end end if params.data_type != nil data_hash["data_type"] = params.data_type end if params.description != nil data_hash["description"] = params.description end if params.localized_format_key != nil data_hash["localized_format_key"] = params.localized_format_key end if params.localized_format_string != nil data_hash["localized_format_string"] = params.localized_format_string end if params.max_characters_allowed != nil data_hash["max_characters_allowed"] = params.max_characters_allowed.to_i end if params.name != nil data_hash["name"] = params.name end if params.name_plural != nil data_hash["name_plural"] = params.name_plural end if params.original_file != nil data_hash["original_file"] = params.original_file end if params.plural != nil data_hash["plural"] = (params.plural == "true") end if params.remove_screenshot != nil data_hash["remove_screenshot"] = (params.remove_screenshot == "true") end if params.screenshot != nil post_body = [] post_body << "--#{PhraseApp::MULTIPART_BOUNDARY}\r\n" post_body << "Content-Disposition: form-data; name=\"screenshot\"; filename=\"#{File.basename(params.screenshot )}\"\r\n" post_body << "Content-Type: text/plain\r\n" post_body << "\r\n" post_body << File.read(params.screenshot) post_body << "\r\n" end if params. != nil data_hash["tags"] = params. end if params.unformatted != nil data_hash["unformatted"] = (params.unformatted == "true") end if params.xml_space_preserve != nil data_hash["xml_space_preserve"] = (params.xml_space_preserve == "true") end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::TranslationKeyDetails.new(JSON.load(rc.body)), err end |
.key_delete(project_id, id) ⇒ Object
Delete an existing key.
1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 |
# File 'lib/phraseapp-ruby.rb', line 1615 def self.key_delete(project_id, id) path = sprintf("/v2/projects/%s/keys/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.key_show(project_id, id) ⇒ Object
Get details on a single key for a given project.
1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 |
# File 'lib/phraseapp-ruby.rb', line 1630 def self.key_show(project_id, id) path = sprintf("/v2/projects/%s/keys/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationKeyDetails.new(JSON.load(rc.body)), err end |
.key_update(project_id, id, params) ⇒ Object
Update an existing key.
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 |
# File 'lib/phraseapp-ruby.rb', line 1645 def self.key_update(project_id, id, params) path = sprintf("/v2/projects/%s/keys/%s", project_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeyUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeyUpdateParams") end end if params.data_type != nil data_hash["data_type"] = params.data_type end if params.description != nil data_hash["description"] = params.description end if params.localized_format_key != nil data_hash["localized_format_key"] = params.localized_format_key end if params.localized_format_string != nil data_hash["localized_format_string"] = params.localized_format_string end if params.max_characters_allowed != nil data_hash["max_characters_allowed"] = params.max_characters_allowed.to_i end if params.name != nil data_hash["name"] = params.name end if params.name_plural != nil data_hash["name_plural"] = params.name_plural end if params.original_file != nil data_hash["original_file"] = params.original_file end if params.plural != nil data_hash["plural"] = (params.plural == "true") end if params.remove_screenshot != nil data_hash["remove_screenshot"] = (params.remove_screenshot == "true") end if params.screenshot != nil post_body = [] post_body << "--#{PhraseApp::MULTIPART_BOUNDARY}\r\n" post_body << "Content-Disposition: form-data; name=\"screenshot\"; filename=\"#{File.basename(params.screenshot )}\"\r\n" post_body << "Content-Type: text/plain\r\n" post_body << "\r\n" post_body << File.read(params.screenshot) post_body << "\r\n" end if params. != nil data_hash["tags"] = params. end if params.unformatted != nil data_hash["unformatted"] = (params.unformatted == "true") end if params.xml_space_preserve != nil data_hash["xml_space_preserve"] = (params.xml_space_preserve == "true") end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationKeyDetails.new(JSON.load(rc.body)), err end |
.keys_delete(project_id, params) ⇒ Object
Delete all keys matching query. Same constraints as list.
1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 |
# File 'lib/phraseapp-ruby.rb', line 1729 def self.keys_delete(project_id, params) path = sprintf("/v2/projects/%s/keys", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeysDeleteParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeysDeleteParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.keys_list(project_id, page, per_page, params) ⇒ Object
List all keys for the given project. Alternatively you can POST requests to /search.
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 |
# File 'lib/phraseapp-ruby.rb', line 1755 def self.keys_list(project_id, page, per_page, params) path = sprintf("/v2/projects/%s/keys", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeysListParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeysListParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::TranslationKey.new(item) }, err end |
.keys_search(project_id, page, per_page, params) ⇒ Object
List all keys for the given project matching query.
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 |
# File 'lib/phraseapp-ruby.rb', line 1781 def self.keys_search(project_id, page, per_page, params) path = sprintf("/v2/projects/%s/keys/search", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeysSearchParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeysSearchParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("POST", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::TranslationKey.new(item) }, err end |
.keys_tag(project_id, params) ⇒ Object
Tags all keys matching query. Same constraints as list.
1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 |
# File 'lib/phraseapp-ruby.rb', line 1807 def self.keys_tag(project_id, params) path = sprintf("/v2/projects/%s/keys/tag", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeysTagParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeysTagParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.keys_untag(project_id, params) ⇒ Object
Removes specified tags from keys matching query.
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 |
# File 'lib/phraseapp-ruby.rb', line 1833 def self.keys_untag(project_id, params) path = sprintf("/v2/projects/%s/keys/tag", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::KeysUntagParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::KeysUntagParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.locale_create(project_id, params) ⇒ Object
Create a new locale.
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 |
# File 'lib/phraseapp-ruby.rb', line 1859 def self.locale_create(project_id, params) path = sprintf("/v2/projects/%s/locales", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::LocaleCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::LocaleCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::LocaleDetails.new(JSON.load(rc.body)), err end |
.locale_delete(project_id, id) ⇒ Object
Delete an existing locale.
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 |
# File 'lib/phraseapp-ruby.rb', line 1885 def self.locale_delete(project_id, id) path = sprintf("/v2/projects/%s/locales/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.locale_download(project_id, id, params) ⇒ Object
Download a locale in a specific file format.
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 |
# File 'lib/phraseapp-ruby.rb', line 1900 def self.locale_download(project_id, id, params) path = sprintf("/v2/projects/%s/locales/%s/download", project_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::LocaleDownloadParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::LocaleDownloadParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return rc.body return err end |
.locale_show(project_id, id) ⇒ Object
Get details on a single locale for a given project.
1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 |
# File 'lib/phraseapp-ruby.rb', line 1926 def self.locale_show(project_id, id) path = sprintf("/v2/projects/%s/locales/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::LocaleDetails.new(JSON.load(rc.body)), err end |
.locale_update(project_id, id, params) ⇒ Object
Update an existing locale.
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 |
# File 'lib/phraseapp-ruby.rb', line 1941 def self.locale_update(project_id, id, params) path = sprintf("/v2/projects/%s/locales/%s", project_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::LocaleUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::LocaleUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::LocaleDetails.new(JSON.load(rc.body)), err end |
.locales_list(project_id, page, per_page) ⇒ Object
List all locales for the given project.
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 |
# File 'lib/phraseapp-ruby.rb', line 1967 def self.locales_list(project_id, page, per_page) path = sprintf("/v2/projects/%s/locales", project_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Locale.new(item) }, err end |
.order_confirm(project_id, id) ⇒ Object
Confirm an existing order and send it to the provider for translation. Same constraints as for create.
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 |
# File 'lib/phraseapp-ruby.rb', line 1982 def self.order_confirm(project_id, id) path = sprintf("/v2/projects/%s/orders/%s/confirm", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationOrder.new(JSON.load(rc.body)), err end |
.order_create(project_id, params) ⇒ Object
Create a new order. Access token scope must include orders.create.
1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 |
# File 'lib/phraseapp-ruby.rb', line 1997 def self.order_create(project_id, params) path = sprintf("/v2/projects/%s/orders", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::OrderCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::OrderCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::TranslationOrder.new(JSON.load(rc.body)), err end |
.order_delete(project_id, id) ⇒ Object
Cancel an existing order. Must not yet be confirmed.
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 |
# File 'lib/phraseapp-ruby.rb', line 2023 def self.order_delete(project_id, id) path = sprintf("/v2/projects/%s/orders/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.order_show(project_id, id) ⇒ Object
Get details on a single order.
2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
# File 'lib/phraseapp-ruby.rb', line 2038 def self.order_show(project_id, id) path = sprintf("/v2/projects/%s/orders/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationOrder.new(JSON.load(rc.body)), err end |
.orders_list(project_id, page, per_page) ⇒ Object
List all orders for the given project.
2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 |
# File 'lib/phraseapp-ruby.rb', line 2053 def self.orders_list(project_id, page, per_page) path = sprintf("/v2/projects/%s/orders", project_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::TranslationOrder.new(item) }, err end |
.project_create(params) ⇒ Object
Create a new project.
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 |
# File 'lib/phraseapp-ruby.rb', line 2068 def self.project_create(params) path = sprintf("/v2/projects") data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::ProjectCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::ProjectCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::ProjectDetails.new(JSON.load(rc.body)), err end |
.project_delete(id) ⇒ Object
Delete an existing project.
2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 |
# File 'lib/phraseapp-ruby.rb', line 2094 def self.project_delete(id) path = sprintf("/v2/projects/%s", id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.project_show(id) ⇒ Object
Get details on a single project.
2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 |
# File 'lib/phraseapp-ruby.rb', line 2109 def self.project_show(id) path = sprintf("/v2/projects/%s", id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::ProjectDetails.new(JSON.load(rc.body)), err end |
.project_update(id, params) ⇒ Object
Update an existing project.
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 |
# File 'lib/phraseapp-ruby.rb', line 2124 def self.project_update(id, params) path = sprintf("/v2/projects/%s", id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::ProjectUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::ProjectUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::ProjectDetails.new(JSON.load(rc.body)), err end |
.projects_list(page, per_page) ⇒ Object
List all projects the current user has access to.
2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 |
# File 'lib/phraseapp-ruby.rb', line 2150 def self.projects_list(page, per_page) path = sprintf("/v2/projects") data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Project.new(item) }, err end |
.show_user ⇒ Object
Show details for current User.
2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 |
# File 'lib/phraseapp-ruby.rb', line 2165 def self.show_user() path = sprintf("/v2/user") data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::User.new(JSON.load(rc.body)), err end |
.styleguide_create(project_id, params) ⇒ Object
Create a new style guide.
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 |
# File 'lib/phraseapp-ruby.rb', line 2180 def self.styleguide_create(project_id, params) path = sprintf("/v2/projects/%s/styleguides", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::StyleguideCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::StyleguideCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::StyleguideDetails.new(JSON.load(rc.body)), err end |
.styleguide_delete(project_id, id) ⇒ Object
Delete an existing style guide.
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 |
# File 'lib/phraseapp-ruby.rb', line 2206 def self.styleguide_delete(project_id, id) path = sprintf("/v2/projects/%s/styleguides/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.styleguide_show(project_id, id) ⇒ Object
Get details on a single style guide.
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 |
# File 'lib/phraseapp-ruby.rb', line 2221 def self.styleguide_show(project_id, id) path = sprintf("/v2/projects/%s/styleguides/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::StyleguideDetails.new(JSON.load(rc.body)), err end |
.styleguide_update(project_id, id, params) ⇒ Object
Update an existing style guide.
2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 |
# File 'lib/phraseapp-ruby.rb', line 2236 def self.styleguide_update(project_id, id, params) path = sprintf("/v2/projects/%s/styleguides/%s", project_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::StyleguideUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::StyleguideUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::StyleguideDetails.new(JSON.load(rc.body)), err end |
.styleguides_list(project_id, page, per_page) ⇒ Object
List all styleguides for the given project.
2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 |
# File 'lib/phraseapp-ruby.rb', line 2262 def self.styleguides_list(project_id, page, per_page) path = sprintf("/v2/projects/%s/styleguides", project_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Styleguide.new(item) }, err end |
.tag_create(project_id, params) ⇒ Object
Create a new tag.
2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 |
# File 'lib/phraseapp-ruby.rb', line 2277 def self.tag_create(project_id, params) path = sprintf("/v2/projects/%s/tags", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TagCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TagCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::TagWithStats.new(JSON.load(rc.body)), err end |
.tag_delete(project_id, name) ⇒ Object
Delete an existing tag.
2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/phraseapp-ruby.rb', line 2303 def self.tag_delete(project_id, name) path = sprintf("/v2/projects/%s/tags/%s", project_id, name) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("DELETE", path, reqHelper.ctype, reqHelper.body, 204) if err != nil return nil, err end return err end |
.tag_show(project_id, name) ⇒ Object
Get details and progress information on a single tag for a given project.
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 |
# File 'lib/phraseapp-ruby.rb', line 2318 def self.tag_show(project_id, name) path = sprintf("/v2/projects/%s/tags/%s", project_id, name) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TagWithStats.new(JSON.load(rc.body)), err end |
.tags_list(project_id, page, per_page) ⇒ Object
List all tags for the given project.
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 |
# File 'lib/phraseapp-ruby.rb', line 2333 def self.(project_id, page, per_page) path = sprintf("/v2/projects/%s/tags", project_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Tag.new(item) }, err end |
.translation_create(project_id, params) ⇒ Object
Create a translation.
2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 |
# File 'lib/phraseapp-ruby.rb', line 2348 def self.translation_create(project_id, params) path = sprintf("/v2/projects/%s/translations", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationCreateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::TranslationDetails.new(JSON.load(rc.body)), err end |
.translation_show(project_id, id) ⇒ Object
Get details on a single translation.
2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 |
# File 'lib/phraseapp-ruby.rb', line 2374 def self.translation_show(project_id, id) path = sprintf("/v2/projects/%s/translations/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationDetails.new(JSON.load(rc.body)), err end |
.translation_update(project_id, id, params) ⇒ Object
Update an existing translation.
2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 |
# File 'lib/phraseapp-ruby.rb', line 2389 def self.translation_update(project_id, id, params) path = sprintf("/v2/projects/%s/translations/%s", project_id, id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationUpdateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationUpdateParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationDetails.new(JSON.load(rc.body)), err end |
.translations_by_key(project_id, key_id, page, per_page, params) ⇒ Object
List translations for a specific key.
2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 |
# File 'lib/phraseapp-ruby.rb', line 2415 def self.translations_by_key(project_id, key_id, page, per_page, params) path = sprintf("/v2/projects/%s/keys/%s/translations", project_id, key_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsByKeyParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsByKeyParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Translation.new(item) }, err end |
.translations_by_locale(project_id, locale_id, page, per_page, params) ⇒ Object
List translations for a specific locale.
2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 |
# File 'lib/phraseapp-ruby.rb', line 2441 def self.translations_by_locale(project_id, locale_id, page, per_page, params) path = sprintf("/v2/projects/%s/locales/%s/translations", project_id, locale_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsByLocaleParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsByLocaleParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Translation.new(item) }, err end |
.translations_exclude(project_id, params) ⇒ Object
Exclude translations matching query from locale export.
2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 |
# File 'lib/phraseapp-ruby.rb', line 2467 def self.translations_exclude(project_id, params) path = sprintf("/v2/projects/%s/translations/exclude", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsExcludeParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsExcludeParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::AffectedCount.new(JSON.load(rc.body)), err end |
.translations_include(project_id, params) ⇒ Object
Include translations matching query in locale export
2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 |
# File 'lib/phraseapp-ruby.rb', line 2493 def self.translations_include(project_id, params) path = sprintf("/v2/projects/%s/translations/include", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsIncludeParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsIncludeParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::AffectedCount.new(JSON.load(rc.body)), err end |
.translations_list(project_id, page, per_page, params) ⇒ Object
List translations for the given project. Alternatively, POST request to /search
2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 |
# File 'lib/phraseapp-ruby.rb', line 2519 def self.translations_list(project_id, page, per_page, params) path = sprintf("/v2/projects/%s/translations", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsListParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsListParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Translation.new(item) }, err end |
.translations_search(project_id, page, per_page, params) ⇒ Object
List translations for the given project if you exceed GET request limitations on translations list.
2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 |
# File 'lib/phraseapp-ruby.rb', line 2545 def self.translations_search(project_id, page, per_page, params) path = sprintf("/v2/projects/%s/translations/search", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsSearchParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsSearchParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("POST", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::Translation.new(item) }, err end |
.translations_unverify(project_id, params) ⇒ Object
Mark translations matching query as unverified
2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 |
# File 'lib/phraseapp-ruby.rb', line 2571 def self.translations_unverify(project_id, params) path = sprintf("/v2/projects/%s/translations/unverify", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsUnverifyParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsUnverifyParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::AffectedCount.new(JSON.load(rc.body)), err end |
.translations_verify(project_id, params) ⇒ Object
Verify translations matching query.
2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 |
# File 'lib/phraseapp-ruby.rb', line 2597 def self.translations_verify(project_id, params) path = sprintf("/v2/projects/%s/translations/verify", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::TranslationsVerifyParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::TranslationsVerifyParams") end end data_hash = params.to_h err = params.validate if err != nil return nil, err end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("PATCH", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::AffectedCount.new(JSON.load(rc.body)), err end |
.upload_create(project_id, params) ⇒ Object
Upload a new language file. Creates necessary resources in your project.
2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 |
# File 'lib/phraseapp-ruby.rb', line 2623 def self.upload_create(project_id, params) path = sprintf("/v2/projects/%s/uploads", project_id) data_hash = {} post_body = nil if params.present? unless params.kind_of?(PhraseApp::UploadCreateParams) raise PhraseApp::ParamsError.new("Expected params to be kind_of PhraseApp::UploadCreateParams") end end if params.convert_emoji != nil data_hash["convert_emoji"] = (params.convert_emoji == "true") end if params.file != nil post_body = [] post_body << "--#{PhraseApp::MULTIPART_BOUNDARY}\r\n" post_body << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(params.file )}\"\r\n" post_body << "Content-Type: text/plain\r\n" post_body << "\r\n" post_body << File.read(params.file) post_body << "\r\n" end if params.file_format != nil data_hash["file_format"] = params.file_format end if params. != nil params..each do |key, value| data_hash["format_options"][key] = value end end if params.locale_id != nil data_hash["locale_id"] = params.locale_id end if params.skip_unverification != nil data_hash["skip_unverification"] = (params.skip_unverification == "true") end if params. != nil data_hash["skip_upload_tags"] = (params. == "true") end if params. != nil data_hash["tags"] = params. end if params.update_translations != nil data_hash["update_translations"] = (params.update_translations == "true") end reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("POST", path, reqHelper.ctype, reqHelper.body, 201) if err != nil return nil, err end return PhraseApp::LocaleFileImportWithSummary.new(JSON.load(rc.body)), err end |
.upload_show(project_id, id) ⇒ Object
View details and summary for a single upload.
2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 |
# File 'lib/phraseapp-ruby.rb', line 2689 def self.upload_show(project_id, id) path = sprintf("/v2/projects/%s/uploads/%s", project_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::LocaleFileImportWithSummary.new(JSON.load(rc.body)), err end |
.version_show(project_id, translation_id, id) ⇒ Object
Get details on a single version.
2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 |
# File 'lib/phraseapp-ruby.rb', line 2704 def self.version_show(project_id, translation_id, id) path = sprintf("/v2/projects/%s/translations/%s/versions/%s", project_id, translation_id, id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request("GET", path, reqHelper.ctype, reqHelper.body, 200) if err != nil return nil, err end return PhraseApp::TranslationVersionWithUser.new(JSON.load(rc.body)), err end |
.versions_list(project_id, translation_id, page, per_page) ⇒ Object
List all versions for the given translation.
2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 |
# File 'lib/phraseapp-ruby.rb', line 2719 def self.versions_list(project_id, translation_id, page, per_page) path = sprintf("/v2/projects/%s/translations/%s/versions", project_id, translation_id) data_hash = {} post_body = nil reqHelper = PhraseApp::RequestHelper.new(data_hash, post_body) rc, err = PhraseApp.send_request_paginated("GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page) if err != nil return nil, err end return JSON.load(rc.body).map { |item| PhraseApp::TranslationVersion.new(item) }, err end |