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.



1728
1729
1730
# File 'lib/phraseapp-ruby.rb', line 1728

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


1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
# File 'lib/phraseapp-ruby.rb', line 1742

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


1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
# File 'lib/phraseapp-ruby.rb', line 1775

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


1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
# File 'lib/phraseapp-ruby.rb', line 1798

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


1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
# File 'lib/phraseapp-ruby.rb', line 1823

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


1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
# File 'lib/phraseapp-ruby.rb', line 1855

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


1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
# File 'lib/phraseapp-ruby.rb', line 1880

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


1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
# File 'lib/phraseapp-ruby.rb', line 1915

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


1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
# File 'lib/phraseapp-ruby.rb', line 1940

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


1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
# File 'lib/phraseapp-ruby.rb', line 1967

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


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

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


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

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


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

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


2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
# File 'lib/phraseapp-ruby.rb', line 2091

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


2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
# File 'lib/phraseapp-ruby.rb', line 2117

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


2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
# File 'lib/phraseapp-ruby.rb', line 2143

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


2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
# File 'lib/phraseapp-ruby.rb', line 2170

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


2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
# File 'lib/phraseapp-ruby.rb', line 2199

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


2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
# File 'lib/phraseapp-ruby.rb', line 2235

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


2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
# File 'lib/phraseapp-ruby.rb', line 2256

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


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
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
# File 'lib/phraseapp-ruby.rb', line 2281

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


2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
# File 'lib/phraseapp-ruby.rb', line 2374

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


2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
# File 'lib/phraseapp-ruby.rb', line 2399

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


2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
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
# File 'lib/phraseapp-ruby.rb', line 2426

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. Please limit the number of affected keys to about 1,000 as you might experience timeouts otherwise. API Path: /v2/projects/:project_id/keys

Parameters:

project_id

project_id

params

Parameters of type PhraseApp::RequestParams::KeysDeleteParams

Returns:

PhraseApp::ResponseObjects::AffectedResources
err


2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
# File 'lib/phraseapp-ruby.rb', line 2520

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


2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
# File 'lib/phraseapp-ruby.rb', line 2556

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


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

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


2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
# File 'lib/phraseapp-ruby.rb', line 2628

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


2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
# File 'lib/phraseapp-ruby.rb', line 2664

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


2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
# File 'lib/phraseapp-ruby.rb', line 2700

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


2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
# File 'lib/phraseapp-ruby.rb', line 2735

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


2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
# File 'lib/phraseapp-ruby.rb', line 2761

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


2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
# File 'lib/phraseapp-ruby.rb', line 2797

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


2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
# File 'lib/phraseapp-ruby.rb', line 2824

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


2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
# File 'lib/phraseapp-ruby.rb', line 2858

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


2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
# File 'lib/phraseapp-ruby.rb', line 2883

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


2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
# File 'lib/phraseapp-ruby.rb', line 2908

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


2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
# File 'lib/phraseapp-ruby.rb', line 2943

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


2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
# File 'lib/phraseapp-ruby.rb', line 2968

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


2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
# File 'lib/phraseapp-ruby.rb', line 2991

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


3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
# File 'lib/phraseapp-ruby.rb', line 3014

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


3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
# File 'lib/phraseapp-ruby.rb', line 3047

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


3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
# File 'lib/phraseapp-ruby.rb', line 3070

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


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

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


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

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


3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
# File 'lib/phraseapp-ruby.rb', line 3148

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


3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
# File 'lib/phraseapp-ruby.rb', line 3173

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


3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
# File 'lib/phraseapp-ruby.rb', line 3208

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


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

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


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

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


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

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


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

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


3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
# File 'lib/phraseapp-ruby.rb', line 3354

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


3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
# File 'lib/phraseapp-ruby.rb', line 3379

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


3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
# File 'lib/phraseapp-ruby.rb', line 3402

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


3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
# File 'lib/phraseapp-ruby.rb', line 3427

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


3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
# File 'lib/phraseapp-ruby.rb', line 3463

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


3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
# File 'lib/phraseapp-ruby.rb', line 3490

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


3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
# File 'lib/phraseapp-ruby.rb', line 3528

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


3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
# File 'lib/phraseapp-ruby.rb', line 3566

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


3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
# File 'lib/phraseapp-ruby.rb', line 3602

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


3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
# File 'lib/phraseapp-ruby.rb', line 3638

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


3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
# File 'lib/phraseapp-ruby.rb', line 3674

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


3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
# File 'lib/phraseapp-ruby.rb', line 3710

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


3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
# File 'lib/phraseapp-ruby.rb', line 3746

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


3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
# File 'lib/phraseapp-ruby.rb', line 3782

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


3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
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
# File 'lib/phraseapp-ruby.rb', line 3818

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_encoding != nil
    data_hash["file_encoding"] = params.file_encoding
  end

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

  if params.format_options != nil
    params.format_options.each do |key, value|
      data_hash["format_options"][key] = value
    end
  end

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

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

  if params.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


3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
# File 'lib/phraseapp-ruby.rb', line 3898

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


3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
# File 'lib/phraseapp-ruby.rb', line 3921

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


3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
# File 'lib/phraseapp-ruby.rb', line 3948

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


3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
# File 'lib/phraseapp-ruby.rb', line 3973

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


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

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


4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
# File 'lib/phraseapp-ruby.rb', line 4033

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


4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
# File 'lib/phraseapp-ruby.rb', line 4058

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


4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
# File 'lib/phraseapp-ruby.rb', line 4082

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


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

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


4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
# File 'lib/phraseapp-ruby.rb', line 4143

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