Class: PhraseApp::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/phraseapp-ruby.rb

Overview

Usage example:

Require the gem

require 'phraseapp-ruby'

Setup Credentials for Authentication

credentials = PhraseApp::Auth::Credentials.new(token: "YOUR_ACCESS_TOKEN")

Create a client

client = PhraseApp::Client.new(credentials)

List Projects

rsp, err = client.projects_list(1, 10)
puts rsp

Create a new key

params = PhraseApp::RequestParams::TranslationKeyParams.new(:name => "foo")
rsp, err = client.key_create('YOUR_PROJECT_ID', params)
puts rsp

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Client

Returns a new instance of Client.



1560
1561
1562
# File 'lib/phraseapp-ruby.rb', line 1560

def initialize(credentials)
  @credentials = credentials
end

Instance Method Details

#authorization_create(params) ⇒ Object

Create a new authorization. API Path: /v2/authorizations

Parameters:

params

Parameters of type PhraseApp::RequestParams::AuthorizationParams

Returns:

PhraseApp::ResponseObjects::AuthorizationWithToken
err


1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
# File 'lib/phraseapp-ruby.rb', line 1574

def authorization_create(params)
  path = sprintf("/api/v2/authorizations")
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::AuthorizationParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::AuthorizationParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::AuthorizationWithToken.new(JSON.load(rc.body)), err
end

#authorization_delete(id) ⇒ Object

Delete an existing authorization. API calls using that token will stop working. API Path: /v2/authorizations/:id

Parameters:

id

id

Returns:

err


1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
# File 'lib/phraseapp-ruby.rb', line 1607

def authorization_delete(id)
  path = sprintf("/api/v2/authorizations/%s", id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/authorizations/:id

Parameters:

id

id

Returns:

PhraseApp::ResponseObjects::Authorization
err


1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
# File 'lib/phraseapp-ruby.rb', line 1630

def authorization_show(id)
  path = sprintf("/api/v2/authorizations/%s", id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::Authorization.new(JSON.load(rc.body)), err
end

#authorization_update(id, params) ⇒ Object

Update an existing authorization. API Path: /v2/authorizations/:id

Parameters:

id

id

params

Parameters of type PhraseApp::RequestParams::AuthorizationParams

Returns:

PhraseApp::ResponseObjects::Authorization
err


1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
# File 'lib/phraseapp-ruby.rb', line 1655

def authorization_update(id, params)
  path = sprintf("/api/v2/authorizations/%s", id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::AuthorizationParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::AuthorizationParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::Authorization.new(JSON.load(rc.body)), err
end

#authorizations_list(page, per_page) ⇒ Object

List all your authorizations. API Path: /v2/authorizations

Parameters:

Returns:

PhraseApp::ResponseObjects::Authorization
err


1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
# File 'lib/phraseapp-ruby.rb', line 1687

def authorizations_list(page, per_page)
  path = sprintf("/api/v2/authorizations")
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Authorization.new(item) }, err
end

#blacklisted_key_create(project_id, params) ⇒ Object

Create a new rule for blacklisting keys. API Path: /v2/projects/:project_id/blacklisted_keys

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::BlacklistedKeyParams

Returns:

PhraseApp::ResponseObjects::BlacklistedKey
err


1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
# File 'lib/phraseapp-ruby.rb', line 1712

def blacklisted_key_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/blacklisted_keys", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::BlacklistedKeyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::BlacklistedKeyParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::BlacklistedKey.new(JSON.load(rc.body)), err
end

#blacklisted_key_delete(project_id, id) ⇒ Object

Delete an existing rule for blacklisting keys. API Path: /v2/projects/:project_id/blacklisted_keys/:id

Parameters:

project_id

project_id

id

id

Returns:

err


1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
# File 'lib/phraseapp-ruby.rb', line 1747

def blacklisted_key_delete(project_id, id)
  path = sprintf("/api/v2/projects/%s/blacklisted_keys/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "DELETE", path, reqHelper.ctype, reqHelper.body, 204)
  if err != nil
    return nil, err
  end
  
  return err
end

#blacklisted_key_show(project_id, id) ⇒ Object

Get details on a single rule for blacklisting keys for a given project. API Path: /v2/projects/:project_id/blacklisted_keys/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::BlacklistedKey
err


1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
# File 'lib/phraseapp-ruby.rb', line 1772

def blacklisted_key_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/blacklisted_keys/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::BlacklistedKey.new(JSON.load(rc.body)), err
end

#blacklisted_key_update(project_id, id, params) ⇒ Object

Update an existing rule for blacklisting keys. API Path: /v2/projects/:project_id/blacklisted_keys/:id

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::BlacklistedKeyParams

Returns:

PhraseApp::ResponseObjects::BlacklistedKey
err


1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
# File 'lib/phraseapp-ruby.rb', line 1799

def blacklisted_key_update(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/blacklisted_keys/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::BlacklistedKeyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::BlacklistedKeyParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::BlacklistedKey.new(JSON.load(rc.body)), err
end

#blacklisted_keys_list(project_id, page, per_page) ⇒ Object

List all rules for blacklisting keys for the given project. API Path: /v2/projects/:project_id/blacklisted_keys

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::BlacklistedKey
err


1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
# File 'lib/phraseapp-ruby.rb', line 1833

def blacklisted_keys_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/blacklisted_keys", project_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::BlacklistedKey.new(item) }, err
end

#comment_create(project_id, key_id, params) ⇒ Object

Create a new comment for a key. API Path: /v2/projects/:project_id/keys/:key_id/comments

Parameters:

project_id

project_id

key_id

key_id

params

Parameters of type PhraseApp::RequestParams::CommentParams

Returns:

PhraseApp::ResponseObjects::Comment
err


1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
# File 'lib/phraseapp-ruby.rb', line 1860

def comment_create(project_id, key_id, params)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments", project_id, key_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::CommentParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::CommentParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::Comment.new(JSON.load(rc.body)), err
end

#comment_delete(project_id, key_id, id) ⇒ Object

Delete an existing comment. API Path: /v2/projects/:project_id/keys/:key_id/comments/:id

Parameters:

project_id

project_id

key_id

key_id

id

id

Returns:

err


1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
# File 'lib/phraseapp-ruby.rb', line 1897

def comment_delete(project_id, key_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments/%s", project_id, key_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/keys/:key_id/comments/:id/read

Parameters:

project_id

project_id

key_id

key_id

id

id

Returns:

err


1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
# File 'lib/phraseapp-ruby.rb', line 1923

def comment_mark_check(project_id, key_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments/%s/read", project_id, key_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/keys/:key_id/comments/:id/read

Parameters:

project_id

project_id

key_id

key_id

id

id

Returns:

err


1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
# File 'lib/phraseapp-ruby.rb', line 1949

def comment_mark_read(project_id, key_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments/%s/read", project_id, key_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/keys/:key_id/comments/:id/read

Parameters:

project_id

project_id

key_id

key_id

id

id

Returns:

err


1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
# File 'lib/phraseapp-ruby.rb', line 1975

def comment_mark_unread(project_id, key_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments/%s/read", project_id, key_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/keys/:key_id/comments/:id

Parameters:

project_id

project_id

key_id

key_id

id

id

Returns:

PhraseApp::ResponseObjects::Comment
err


2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
# File 'lib/phraseapp-ruby.rb', line 2002

def comment_show(project_id, key_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments/%s", project_id, key_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::Comment.new(JSON.load(rc.body)), err
end

#comment_update(project_id, key_id, id, params) ⇒ Object

Update an existing comment. API Path: /v2/projects/:project_id/keys/:key_id/comments/:id

Parameters:

project_id

project_id

key_id

key_id

id

id

params

Parameters of type PhraseApp::RequestParams::CommentParams

Returns:

PhraseApp::ResponseObjects::Comment
err


2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
# File 'lib/phraseapp-ruby.rb', line 2031

def comment_update(project_id, key_id, id, params)
  path = sprintf("/api/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::RequestParams::CommentParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::CommentParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::Comment.new(JSON.load(rc.body)), err
end

#comments_list(project_id, key_id, page, per_page) ⇒ Object

List all comments for a key. API Path: /v2/projects/:project_id/keys/:key_id/comments

Parameters:

project_id

project_id

key_id

key_id

Returns:

PhraseApp::ResponseObjects::Comment
err


2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
# File 'lib/phraseapp-ruby.rb', line 2067

def comments_list(project_id, key_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/keys/%s/comments", project_id, key_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Comment.new(item) }, err
end

#formats_list(page, per_page) ⇒ Object

Get a handy list of all localization file formats supported in PhraseApp. API Path: /v2/formats

Parameters:

Returns:

PhraseApp::ResponseObjects::Format
err


2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
# File 'lib/phraseapp-ruby.rb', line 2088

def formats_list(page, per_page)
  path = sprintf("/api/v2/formats")
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Format.new(item) }, err
end

#key_create(project_id, params) ⇒ Object

Create a new key. API Path: /v2/projects/:project_id/keys

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationKeyParams

Returns:

PhraseApp::ResponseObjects::TranslationKeyDetails
err


2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
# File 'lib/phraseapp-ruby.rb', line 2113

def key_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/keys", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationKeyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationKeyParams")
    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.tags != nil
    data_hash["tags"] = params.tags
  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::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationKeyDetails.new(JSON.load(rc.body)), err
end

#key_delete(project_id, id) ⇒ Object

Delete an existing key. API Path: /v2/projects/:project_id/keys/:id

Parameters:

project_id

project_id

id

id

Returns:

err


2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
# File 'lib/phraseapp-ruby.rb', line 2206

def key_delete(project_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/keys/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::TranslationKeyDetails
err


2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
# File 'lib/phraseapp-ruby.rb', line 2231

def key_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/keys/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationKeyDetails.new(JSON.load(rc.body)), err
end

#key_update(project_id, id, params) ⇒ Object

Update an existing key. API Path: /v2/projects/:project_id/keys/:id

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::TranslationKeyParams

Returns:

PhraseApp::ResponseObjects::TranslationKeyDetails
err


2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
# File 'lib/phraseapp-ruby.rb', line 2258

def key_update(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/keys/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationKeyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationKeyParams")
    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.tags != nil
    data_hash["tags"] = params.tags
  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::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationKeyDetails.new(JSON.load(rc.body)), err
end

#keys_delete(project_id, params) ⇒ Object

Delete all keys matching query. Same constraints as list. API Path: /v2/projects/:project_id/keys

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::KeysDeleteParams

Returns:

PhraseApp::ResponseObjects::AffectedResources
err


2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
# File 'lib/phraseapp-ruby.rb', line 2352

def keys_delete(project_id, params)
  path = sprintf("/api/v2/projects/%s/keys", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::KeysDeleteParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::KeysDeleteParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "DELETE", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::AffectedResources.new(JSON.load(rc.body)), 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. API Path: /v2/projects/:project_id/keys

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::KeysListParams

Returns:

PhraseApp::ResponseObjects::TranslationKey
err


2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
# File 'lib/phraseapp-ruby.rb', line 2388

def keys_list(project_id, page, per_page, params)
  path = sprintf("/api/v2/projects/%s/keys", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::KeysListParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::KeysListParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::TranslationKey.new(item) }, err
end

#keys_search(project_id, page, per_page, params) ⇒ Object

Search keys for the given project matching query. API Path: /v2/projects/:project_id/keys/search

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::KeysSearchParams

Returns:

PhraseApp::ResponseObjects::TranslationKey
err


2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
# File 'lib/phraseapp-ruby.rb', line 2424

def keys_search(project_id, page, per_page, params)
  path = sprintf("/api/v2/projects/%s/keys/search", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::KeysSearchParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::KeysSearchParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::TranslationKey.new(item) }, err
end

#keys_tag(project_id, params) ⇒ Object

Tags all keys matching query. Same constraints as list. API Path: /v2/projects/:project_id/keys/tag

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::KeysTagParams

Returns:

PhraseApp::ResponseObjects::AffectedResources
err


2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
# File 'lib/phraseapp-ruby.rb', line 2460

def keys_tag(project_id, params)
  path = sprintf("/api/v2/projects/%s/keys/tag", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::KeysTagParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::KeysTagParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::AffectedResources.new(JSON.load(rc.body)), err
end

#keys_untag(project_id, params) ⇒ Object

Removes specified tags from keys matching query. API Path: /v2/projects/:project_id/keys/untag

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::KeysUntagParams

Returns:

PhraseApp::ResponseObjects::AffectedResources
err


2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
# File 'lib/phraseapp-ruby.rb', line 2496

def keys_untag(project_id, params)
  path = sprintf("/api/v2/projects/%s/keys/untag", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::KeysUntagParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::KeysUntagParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::AffectedResources.new(JSON.load(rc.body)), err
end

#locale_create(project_id, params) ⇒ Object

Create a new locale. API Path: /v2/projects/:project_id/locales

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::LocaleParams

Returns:

PhraseApp::ResponseObjects::LocaleDetails
err


2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
# File 'lib/phraseapp-ruby.rb', line 2532

def locale_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/locales", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::LocaleParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::LocaleParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::LocaleDetails.new(JSON.load(rc.body)), err
end

#locale_delete(project_id, id) ⇒ Object

Delete an existing locale. API Path: /v2/projects/:project_id/locales/:id

Parameters:

project_id

project_id

id

id

Returns:

err


2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
# File 'lib/phraseapp-ruby.rb', line 2567

def locale_delete(project_id, id)
  path = sprintf("/api/v2/projects/%s/locales/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/locales/:id/download

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::LocaleDownloadParams

Returns:

err


2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
# File 'lib/phraseapp-ruby.rb', line 2593

def locale_download(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/locales/%s/download", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::LocaleDownloadParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::LocaleDownloadParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/locales/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::LocaleDetails
err


2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
# File 'lib/phraseapp-ruby.rb', line 2629

def locale_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/locales/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::LocaleDetails.new(JSON.load(rc.body)), err
end

#locale_update(project_id, id, params) ⇒ Object

Update an existing locale. API Path: /v2/projects/:project_id/locales/:id

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::LocaleParams

Returns:

PhraseApp::ResponseObjects::LocaleDetails
err


2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
# File 'lib/phraseapp-ruby.rb', line 2656

def locale_update(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/locales/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::LocaleParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::LocaleParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::LocaleDetails.new(JSON.load(rc.body)), err
end

#locales_list(project_id, page, per_page) ⇒ Object

List all locales for the given project. API Path: /v2/projects/:project_id/locales

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::Locale
err


2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
# File 'lib/phraseapp-ruby.rb', line 2690

def locales_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/locales", project_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::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. API Path: /v2/projects/:project_id/orders/:id/confirm

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::TranslationOrder
err


2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
# File 'lib/phraseapp-ruby.rb', line 2715

def order_confirm(project_id, id)
  path = sprintf("/api/v2/projects/%s/orders/%s/confirm", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::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. API Path: /v2/projects/:project_id/orders

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationOrderParams

Returns:

PhraseApp::ResponseObjects::TranslationOrder
err


2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
# File 'lib/phraseapp-ruby.rb', line 2740

def order_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/orders", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationOrderParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationOrderParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationOrder.new(JSON.load(rc.body)), err
end

#order_delete(project_id, id) ⇒ Object

Cancel an existing order. Must not yet be confirmed. API Path: /v2/projects/:project_id/orders/:id

Parameters:

project_id

project_id

id

id

Returns:

err


2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
# File 'lib/phraseapp-ruby.rb', line 2775

def order_delete(project_id, id)
  path = sprintf("/api/v2/projects/%s/orders/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/orders/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::TranslationOrder
err


2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
# File 'lib/phraseapp-ruby.rb', line 2800

def order_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/orders/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationOrder.new(JSON.load(rc.body)), err
end

#orders_list(project_id, page, per_page) ⇒ Object

List all orders for the given project. API Path: /v2/projects/:project_id/orders

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::TranslationOrder
err


2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
# File 'lib/phraseapp-ruby.rb', line 2823

def orders_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/orders", project_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::TranslationOrder.new(item) }, err
end

#project_create(params) ⇒ Object

Create a new project. API Path: /v2/projects

Parameters:

params

Parameters of type PhraseApp::RequestParams::ProjectParams

Returns:

PhraseApp::ResponseObjects::ProjectDetails
err


2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
# File 'lib/phraseapp-ruby.rb', line 2846

def project_create(params)
  path = sprintf("/api/v2/projects")
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::ProjectParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::ProjectParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::ProjectDetails.new(JSON.load(rc.body)), err
end

#project_delete(id) ⇒ Object

Delete an existing project. API Path: /v2/projects/:id

Parameters:

id

id

Returns:

err


2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
# File 'lib/phraseapp-ruby.rb', line 2879

def project_delete(id)
  path = sprintf("/api/v2/projects/%s", id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:id

Parameters:

id

id

Returns:

PhraseApp::ResponseObjects::ProjectDetails
err


2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
# File 'lib/phraseapp-ruby.rb', line 2902

def project_show(id)
  path = sprintf("/api/v2/projects/%s", id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::ProjectDetails.new(JSON.load(rc.body)), err
end

#project_update(id, params) ⇒ Object

Update an existing project. API Path: /v2/projects/:id

Parameters:

id

id

params

Parameters of type PhraseApp::RequestParams::ProjectParams

Returns:

PhraseApp::ResponseObjects::ProjectDetails
err


2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
# File 'lib/phraseapp-ruby.rb', line 2927

def project_update(id, params)
  path = sprintf("/api/v2/projects/%s", id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::ProjectParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::ProjectParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::ProjectDetails.new(JSON.load(rc.body)), err
end

#projects_list(page, per_page) ⇒ Object

List all projects the current user has access to. API Path: /v2/projects

Parameters:

Returns:

PhraseApp::ResponseObjects::Project
err


2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
# File 'lib/phraseapp-ruby.rb', line 2959

def projects_list(page, per_page)
  path = sprintf("/api/v2/projects")
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Project.new(item) }, err
end

#show_userObject

Show details for current User. API Path: /v2/user

Parameters:

Returns:

PhraseApp::ResponseObjects::User
err


2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
# File 'lib/phraseapp-ruby.rb', line 2980

def show_user()
  path = sprintf("/api/v2/user")
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::User.new(JSON.load(rc.body)), err
end

#styleguide_create(project_id, params) ⇒ Object

Create a new style guide. API Path: /v2/projects/:project_id/styleguides

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::StyleguideParams

Returns:

PhraseApp::ResponseObjects::StyleguideDetails
err


3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
# File 'lib/phraseapp-ruby.rb', line 3005

def styleguide_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/styleguides", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::StyleguideParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::StyleguideParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::StyleguideDetails.new(JSON.load(rc.body)), err
end

#styleguide_delete(project_id, id) ⇒ Object

Delete an existing style guide. API Path: /v2/projects/:project_id/styleguides/:id

Parameters:

project_id

project_id

id

id

Returns:

err


3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
# File 'lib/phraseapp-ruby.rb', line 3040

def styleguide_delete(project_id, id)
  path = sprintf("/api/v2/projects/%s/styleguides/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/styleguides/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::StyleguideDetails
err


3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
# File 'lib/phraseapp-ruby.rb', line 3065

def styleguide_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/styleguides/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::StyleguideDetails.new(JSON.load(rc.body)), err
end

#styleguide_update(project_id, id, params) ⇒ Object

Update an existing style guide. API Path: /v2/projects/:project_id/styleguides/:id

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::StyleguideParams

Returns:

PhraseApp::ResponseObjects::StyleguideDetails
err


3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
# File 'lib/phraseapp-ruby.rb', line 3092

def styleguide_update(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/styleguides/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::StyleguideParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::StyleguideParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::StyleguideDetails.new(JSON.load(rc.body)), err
end

#styleguides_list(project_id, page, per_page) ⇒ Object

List all styleguides for the given project. API Path: /v2/projects/:project_id/styleguides

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::Styleguide
err


3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
# File 'lib/phraseapp-ruby.rb', line 3126

def styleguides_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/styleguides", project_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Styleguide.new(item) }, err
end

#tag_create(project_id, params) ⇒ Object

Create a new tag. API Path: /v2/projects/:project_id/tags

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TagParams

Returns:

PhraseApp::ResponseObjects::TagWithStats
err


3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
# File 'lib/phraseapp-ruby.rb', line 3151

def tag_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/tags", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TagParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TagParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TagWithStats.new(JSON.load(rc.body)), err
end

#tag_delete(project_id, name) ⇒ Object

Delete an existing tag. API Path: /v2/projects/:project_id/tags/:name

Parameters:

project_id

project_id

name

name

Returns:

err


3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
# File 'lib/phraseapp-ruby.rb', line 3186

def tag_delete(project_id, name)
  path = sprintf("/api/v2/projects/%s/tags/%s", project_id, name)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "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. API Path: /v2/projects/:project_id/tags/:name

Parameters:

project_id

project_id

name

name

Returns:

PhraseApp::ResponseObjects::TagWithStats
err


3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
# File 'lib/phraseapp-ruby.rb', line 3211

def tag_show(project_id, name)
  path = sprintf("/api/v2/projects/%s/tags/%s", project_id, name)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TagWithStats.new(JSON.load(rc.body)), err
end

#tags_list(project_id, page, per_page) ⇒ Object

List all tags for the given project. API Path: /v2/projects/:project_id/tags

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::Tag
err


3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
# File 'lib/phraseapp-ruby.rb', line 3234

def tags_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/tags", project_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Tag.new(item) }, err
end

#translation_create(project_id, params) ⇒ Object

Create a translation. API Path: /v2/projects/:project_id/translations

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationParams

Returns:

PhraseApp::ResponseObjects::TranslationDetails
err


3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
# File 'lib/phraseapp-ruby.rb', line 3259

def translation_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/translations", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationDetails.new(JSON.load(rc.body)), err
end

#translation_show(project_id, id) ⇒ Object

Get details on a single translation. API Path: /v2/projects/:project_id/translations/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::TranslationDetails
err


3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
# File 'lib/phraseapp-ruby.rb', line 3295

def translation_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/translations/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::TranslationDetails.new(JSON.load(rc.body)), err
end

#translation_update(project_id, id, params) ⇒ Object

Update an existing translation. API Path: /v2/projects/:project_id/translations/:id

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::TranslationUpdateParams

Returns:

PhraseApp::ResponseObjects::TranslationDetails
err


3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
# File 'lib/phraseapp-ruby.rb', line 3322

def translation_update(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/translations/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationUpdateParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationUpdateParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::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. API Path: /v2/projects/:project_id/keys/:key_id/translations

Parameters:

project_id

project_id

key_id

key_id

params

Parameters of type PhraseApp::RequestParams::TranslationsByKeyParams

Returns:

PhraseApp::ResponseObjects::Translation
err


3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
# File 'lib/phraseapp-ruby.rb', line 3360

def translations_by_key(project_id, key_id, page, per_page, params)
  path = sprintf("/api/v2/projects/%s/keys/%s/translations", project_id, key_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsByKeyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsByKeyParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Translation.new(item) }, err
end

#translations_by_locale(project_id, locale_id, page, per_page, params) ⇒ Object

List translations for a specific locale. API Path: /v2/projects/:project_id/locales/:locale_id/translations

Parameters:

project_id

project_id

locale_id

locale_id

params

Parameters of type PhraseApp::RequestParams::TranslationsByLocaleParams

Returns:

PhraseApp::ResponseObjects::Translation
err


3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
# File 'lib/phraseapp-ruby.rb', line 3398

def translations_by_locale(project_id, locale_id, page, per_page, params)
  path = sprintf("/api/v2/projects/%s/locales/%s/translations", project_id, locale_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsByLocaleParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsByLocaleParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Translation.new(item) }, err
end

#translations_exclude(project_id, params) ⇒ Object

Exclude translations matching query from locale export. API Path: /v2/projects/:project_id/translations/exclude

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsExcludeParams

Returns:

PhraseApp::ResponseObjects::AffectedCount
err


3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
# File 'lib/phraseapp-ruby.rb', line 3434

def translations_exclude(project_id, params)
  path = sprintf("/api/v2/projects/%s/translations/exclude", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsExcludeParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsExcludeParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::AffectedCount.new(JSON.load(rc.body)), err
end

#translations_include(project_id, params) ⇒ Object

Include translations matching query in locale export. API Path: /v2/projects/:project_id/translations/include

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsIncludeParams

Returns:

PhraseApp::ResponseObjects::AffectedCount
err


3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
# File 'lib/phraseapp-ruby.rb', line 3470

def translations_include(project_id, params)
  path = sprintf("/api/v2/projects/%s/translations/include", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsIncludeParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsIncludeParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::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 API Path: /v2/projects/:project_id/translations

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsListParams

Returns:

PhraseApp::ResponseObjects::Translation
err


3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
# File 'lib/phraseapp-ruby.rb', line 3506

def translations_list(project_id, page, per_page, params)
  path = sprintf("/api/v2/projects/%s/translations", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsListParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsListParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::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. API Path: /v2/projects/:project_id/translations/search

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsSearchParams

Returns:

PhraseApp::ResponseObjects::Translation
err


3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
# File 'lib/phraseapp-ruby.rb', line 3542

def translations_search(project_id, page, per_page, params)
  path = sprintf("/api/v2/projects/%s/translations/search", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsSearchParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsSearchParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::Translation.new(item) }, err
end

#translations_unverify(project_id, params) ⇒ Object

Mark translations matching query as unverified. API Path: /v2/projects/:project_id/translations/unverify

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsUnverifyParams

Returns:

PhraseApp::ResponseObjects::AffectedCount
err


3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
# File 'lib/phraseapp-ruby.rb', line 3578

def translations_unverify(project_id, params)
  path = sprintf("/api/v2/projects/%s/translations/unverify", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsUnverifyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsUnverifyParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::AffectedCount.new(JSON.load(rc.body)), err
end

#translations_verify(project_id, params) ⇒ Object

Verify translations matching query. API Path: /v2/projects/:project_id/translations/verify

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsVerifyParams

Returns:

PhraseApp::ResponseObjects::AffectedCount
err


3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
# File 'lib/phraseapp-ruby.rb', line 3614

def translations_verify(project_id, params)
  path = sprintf("/api/v2/projects/%s/translations/verify", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::TranslationsVerifyParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::TranslationsVerifyParams")
    end
  end
  
  data_hash = params.to_h
  err = params.validate
  if err != nil
    return nil, err
  end
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::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. API Path: /v2/projects/:project_id/uploads

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::LocaleFileImportParams

Returns:

PhraseApp::ResponseObjects::LocaleFileImportWithSummary
err


3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
# File 'lib/phraseapp-ruby.rb', line 3650

def upload_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/uploads", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::LocaleFileImportParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::LocaleFileImportParams")
    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.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.skip_upload_tags != nil
    data_hash["skip_upload_tags"] = (params.skip_upload_tags == true)
  end

  if params.tags != nil
    data_hash["tags"] = params.tags
  end

  if params.update_translations != nil
    data_hash["update_translations"] = (params.update_translations == true)
  end

  
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::LocaleFileImportWithSummary.new(JSON.load(rc.body)), err
end

#upload_show(project_id, id) ⇒ Object

View details and summary for a single upload. API Path: /v2/projects/:project_id/uploads/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::LocaleFileImportWithSummary
err


3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
# File 'lib/phraseapp-ruby.rb', line 3720

def upload_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/uploads/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::LocaleFileImportWithSummary.new(JSON.load(rc.body)), err
end

#uploads_list(project_id, page, per_page) ⇒ Object

List all uploads for the given project. API Path: /v2/projects/:project_id/uploads

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::LocaleFileImportWithSummary
err


3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
# File 'lib/phraseapp-ruby.rb', line 3743

def uploads_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/uploads", project_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::LocaleFileImportWithSummary.new(item) }, err
end

#version_show(project_id, translation_id, id) ⇒ Object

Get details on a single version. API Path: /v2/projects/:project_id/translations/:translation_id/versions/:id

Parameters:

project_id

project_id

translation_id

translation_id

id

id

Returns:

PhraseApp::ResponseObjects::TranslationVersionWithUser
err


3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
# File 'lib/phraseapp-ruby.rb', line 3770

def version_show(project_id, translation_id, id)
  path = sprintf("/api/v2/projects/%s/translations/%s/versions/%s", project_id, translation_id, id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
  if err != nil
    return nil, err
  end
  
  return PhraseApp::ResponseObjects::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. API Path: /v2/projects/:project_id/translations/:translation_id/versions

Parameters:

project_id

project_id

translation_id

translation_id

Returns:

PhraseApp::ResponseObjects::TranslationVersion
err


3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
# File 'lib/phraseapp-ruby.rb', line 3795

def versions_list(project_id, translation_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/translations/%s/versions", project_id, translation_id)
  data_hash = {}
  post_body = nil
  
  reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
  rc, err = PhraseApp.send_request_paginated(@credentials, "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::ResponseObjects::TranslationVersion.new(item) }, err
end