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.



1742
1743
1744
# File 'lib/phraseapp-ruby.rb', line 1742

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


1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
# File 'lib/phraseapp-ruby.rb', line 1756

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


1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
# File 'lib/phraseapp-ruby.rb', line 1789

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


1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
# File 'lib/phraseapp-ruby.rb', line 1812

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


1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
# File 'lib/phraseapp-ruby.rb', line 1837

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


1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
# File 'lib/phraseapp-ruby.rb', line 1869

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


1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
# File 'lib/phraseapp-ruby.rb', line 1894

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


1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
# File 'lib/phraseapp-ruby.rb', line 1929

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


1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
# File 'lib/phraseapp-ruby.rb', line 1954

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


1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
# File 'lib/phraseapp-ruby.rb', line 1981

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


2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
# File 'lib/phraseapp-ruby.rb', line 2015

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


2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
# File 'lib/phraseapp-ruby.rb', line 2042

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


2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
# File 'lib/phraseapp-ruby.rb', line 2079

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


2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
# File 'lib/phraseapp-ruby.rb', line 2105

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


2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
# File 'lib/phraseapp-ruby.rb', line 2131

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


2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
# File 'lib/phraseapp-ruby.rb', line 2157

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


2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
# File 'lib/phraseapp-ruby.rb', line 2184

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


2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
# File 'lib/phraseapp-ruby.rb', line 2213

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


2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
# File 'lib/phraseapp-ruby.rb', line 2249

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


2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
# File 'lib/phraseapp-ruby.rb', line 2270

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


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
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
# File 'lib/phraseapp-ruby.rb', line 2295

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


2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
# File 'lib/phraseapp-ruby.rb', line 2388

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


2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
# File 'lib/phraseapp-ruby.rb', line 2413

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


2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
# File 'lib/phraseapp-ruby.rb', line 2440

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


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

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


2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
# File 'lib/phraseapp-ruby.rb', line 2570

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


2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
# File 'lib/phraseapp-ruby.rb', line 2606

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


2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
# File 'lib/phraseapp-ruby.rb', line 2642

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


2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
# File 'lib/phraseapp-ruby.rb', line 2678

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


2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
# File 'lib/phraseapp-ruby.rb', line 2714

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


2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
# File 'lib/phraseapp-ruby.rb', line 2749

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


2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
# File 'lib/phraseapp-ruby.rb', line 2775

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


2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
# File 'lib/phraseapp-ruby.rb', line 2811

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


2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
# File 'lib/phraseapp-ruby.rb', line 2838

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


2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
# File 'lib/phraseapp-ruby.rb', line 2872

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


2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
# File 'lib/phraseapp-ruby.rb', line 2897

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


2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
# File 'lib/phraseapp-ruby.rb', line 2922

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


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

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


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

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


3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
# File 'lib/phraseapp-ruby.rb', line 3005

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


3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
# File 'lib/phraseapp-ruby.rb', line 3028

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


3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
# File 'lib/phraseapp-ruby.rb', line 3061

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


3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
# File 'lib/phraseapp-ruby.rb', line 3084

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


3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
# File 'lib/phraseapp-ruby.rb', line 3109

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


3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
# File 'lib/phraseapp-ruby.rb', line 3141

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


3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
# File 'lib/phraseapp-ruby.rb', line 3162

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


3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
# File 'lib/phraseapp-ruby.rb', line 3187

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


3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
# File 'lib/phraseapp-ruby.rb', line 3222

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


3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
# File 'lib/phraseapp-ruby.rb', line 3247

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


3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
# File 'lib/phraseapp-ruby.rb', line 3274

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


3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
# File 'lib/phraseapp-ruby.rb', line 3308

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


3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
# File 'lib/phraseapp-ruby.rb', line 3333

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


3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
# File 'lib/phraseapp-ruby.rb', line 3368

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


3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
# File 'lib/phraseapp-ruby.rb', line 3393

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


3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
# File 'lib/phraseapp-ruby.rb', line 3416

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


3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
# File 'lib/phraseapp-ruby.rb', line 3441

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


3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
# File 'lib/phraseapp-ruby.rb', line 3477

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


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

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


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_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. If you want to download all translations for one locale we recommend to use the locales#download endpoint. 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


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

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


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

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


3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
# File 'lib/phraseapp-ruby.rb', line 3652

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. If you want to download all translations for one locale we recommend to use the locales#download endpoint. API Path: /v2/projects/:project_id/translations

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::TranslationsListParams

Returns:

PhraseApp::ResponseObjects::Translation
err


3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
# File 'lib/phraseapp-ruby.rb', line 3688

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. If you want to download all translations for one locale we recommend to use the locales#download endpoint. 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


3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
# File 'lib/phraseapp-ruby.rb', line 3724

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


3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
# File 'lib/phraseapp-ruby.rb', line 3760

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


3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
# File 'lib/phraseapp-ruby.rb', line 3796

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::UploadParams

Returns:

PhraseApp::ResponseObjects::Upload
err


3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
# File 'lib/phraseapp-ruby.rb', line 3832

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::UploadParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::UploadParams")
    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::Upload.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::Upload
err


3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
# File 'lib/phraseapp-ruby.rb', line 3902

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::Upload.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::Upload
err


3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
# File 'lib/phraseapp-ruby.rb', line 3925

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::Upload.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


3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
# File 'lib/phraseapp-ruby.rb', line 3952

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


3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
# File 'lib/phraseapp-ruby.rb', line 3977

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

#webhook_create(project_id, params) ⇒ Object

Create a new webhook. API Path: /v2/projects/:project_id/webhooks

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::WebhookParams

Returns:

PhraseApp::ResponseObjects::Webhook
err


4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
# File 'lib/phraseapp-ruby.rb', line 4002

def webhook_create(project_id, params)
  path = sprintf("/api/v2/projects/%s/webhooks", project_id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::WebhookParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::WebhookParams")
    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::Webhook.new(JSON.load(rc.body)), err
end

#webhook_delete(project_id, id) ⇒ Object

Delete an existing webhook. API Path: /v2/projects/:project_id/webhooks/:id

Parameters:

project_id

project_id

id

id

Returns:

err


4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
# File 'lib/phraseapp-ruby.rb', line 4037

def webhook_delete(project_id, id)
  path = sprintf("/api/v2/projects/%s/webhooks/%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

#webhook_show(project_id, id) ⇒ Object

Get details on a single webhook. API Path: /v2/projects/:project_id/webhooks/:id

Parameters:

project_id

project_id

id

id

Returns:

PhraseApp::ResponseObjects::Webhook
err


4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
# File 'lib/phraseapp-ruby.rb', line 4062

def webhook_show(project_id, id)
  path = sprintf("/api/v2/projects/%s/webhooks/%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::Webhook.new(JSON.load(rc.body)), err
end

#webhook_test(project_id, id) ⇒ Object

Perform a test request for a webhook. API Path: /v2/projects/:project_id/webhooks/:id/test

Parameters:

project_id

project_id

id

id

Returns:

err


4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
# File 'lib/phraseapp-ruby.rb', line 4086

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

#webhook_update(project_id, id, params) ⇒ Object

Update an existing webhook. API Path: /v2/projects/:project_id/webhooks/:id

Parameters:

project_id

project_id

id

id

params

Parameters of type PhraseApp::RequestParams::WebhookParams

Returns:

PhraseApp::ResponseObjects::Webhook
err


4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
# File 'lib/phraseapp-ruby.rb', line 4113

def webhook_update(project_id, id, params)
  path = sprintf("/api/v2/projects/%s/webhooks/%s", project_id, id)
  data_hash = {}
  post_body = nil
  
  if params.present?
    unless params.kind_of?(PhraseApp::RequestParams::WebhookParams)
      raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::WebhookParams")
    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::Webhook.new(JSON.load(rc.body)), err
end

#webhooks_list(project_id, page, per_page) ⇒ Object

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

Parameters:

project_id

project_id

Returns:

PhraseApp::ResponseObjects::Webhook
err


4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
# File 'lib/phraseapp-ruby.rb', line 4147

def webhooks_list(project_id, page, per_page)
  path = sprintf("/api/v2/projects/%s/webhooks", 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::Webhook.new(item) }, err
end