phraseapp-ruby 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 827e1edf79b114d1ab6fbcdae8391bf4024a15ab
|
4
|
+
data.tar.gz: c34edbf3efc7e772a31288d1d2864468725d0bb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79969ca3ee1c165df5e7612378324802e03f857880455125fb6cca548f019551e03137e85b49d611de91d7b79ce0f8be7ab2936a583a0b889698aa1860eece88
|
7
|
+
data.tar.gz: f2b4fe0459da9f2f22a2cc3cc70bec73e48caad8601eac6eb83e4f581be0d48ab8952ece5f890c7b6c070f9f69194a04456437bac77ed9e2ad3c8f21b26ec96c
|
data/lib/phraseapp-ruby.rb
CHANGED
@@ -5,8 +5,9 @@ require 'uri'
|
|
5
5
|
require 'cgi'
|
6
6
|
require 'json'
|
7
7
|
require 'date'
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require 'phraseapp-ruby/auth'
|
9
|
+
require 'phraseapp-ruby/request_handler'
|
10
|
+
require 'phraseapp-ruby/version'
|
10
11
|
|
11
12
|
module PhraseApp
|
12
13
|
def self.handle_times(obj)
|
@@ -14,7 +15,7 @@ module PhraseApp
|
|
14
15
|
if is_a_date?(v)
|
15
16
|
obj.send(:"#{k}=", DateTime.parse(v))
|
16
17
|
end
|
17
|
-
end
|
18
|
+
end
|
18
19
|
end
|
19
20
|
|
20
21
|
def self.is_a_date?(str)
|
@@ -105,22 +106,6 @@ module ResponseObjects
|
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
|
-
class LocaleFileImport < ::OpenStruct
|
109
|
-
#created_at, file_format, id, state, updated_at,
|
110
|
-
def initialize(hash)
|
111
|
-
super(hash)
|
112
|
-
PhraseApp.handle_times(self)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
class LocaleFileImportWithSummary < LocaleFileImport
|
117
|
-
#summary,
|
118
|
-
def initialize(hash)
|
119
|
-
super(hash)
|
120
|
-
PhraseApp.handle_times(self)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
109
|
class LocalePreview < ::OpenStruct
|
125
110
|
#code, id, name,
|
126
111
|
def initialize(hash)
|
@@ -273,6 +258,14 @@ module ResponseObjects
|
|
273
258
|
end
|
274
259
|
end
|
275
260
|
|
261
|
+
class Upload < ::OpenStruct
|
262
|
+
#created_at, filename, format, id, state, summary, updated_at,
|
263
|
+
def initialize(hash)
|
264
|
+
super(hash)
|
265
|
+
PhraseApp.handle_times(self)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
276
269
|
class User < ::OpenStruct
|
277
270
|
#created_at, email, id, name, position, updated_at, username,
|
278
271
|
def initialize(hash)
|
@@ -289,9 +282,18 @@ module ResponseObjects
|
|
289
282
|
end
|
290
283
|
end
|
291
284
|
|
285
|
+
class Webhook < ::OpenStruct
|
286
|
+
#active, callback_url, created_at, description, events, id, updated_at,
|
287
|
+
def initialize(hash)
|
288
|
+
super(hash)
|
289
|
+
PhraseApp.handle_times(self)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
292
293
|
|
293
294
|
end
|
294
295
|
|
296
|
+
|
295
297
|
module RequestParams
|
296
298
|
# AuthorizationParams
|
297
299
|
# == Parameters:
|
@@ -943,7 +945,7 @@ end
|
|
943
945
|
|
944
946
|
|
945
947
|
module RequestParams
|
946
|
-
#
|
948
|
+
# UploadParams
|
947
949
|
# == Parameters:
|
948
950
|
# convert_emoji::
|
949
951
|
# Indicates whether the file contains Emoji symbols that should be converted. <a href="/guides/working-with-phraseapp/emoji-support/">Working with Emojis</a>.
|
@@ -961,7 +963,7 @@ module RequestParams
|
|
961
963
|
# List of tags separated by comma to be associated with the new keys contained in the upload.
|
962
964
|
# update_translations::
|
963
965
|
# Indicates whether existing translations should be updated with the file content.
|
964
|
-
class
|
966
|
+
class UploadParams < ::OpenStruct
|
965
967
|
def convert_emoji=(val)
|
966
968
|
if val.is_a?(TrueClass)
|
967
969
|
self.convert_emoji = true
|
@@ -1020,7 +1022,57 @@ module RequestParams
|
|
1020
1022
|
|
1021
1023
|
def validate
|
1022
1024
|
if self.file == nil
|
1023
|
-
raise PhraseApp::ParamsHelpers::ParamsValidationError.new("Required parameter \"file\" of \"
|
1025
|
+
raise PhraseApp::ParamsHelpers::ParamsValidationError.new("Required parameter \"file\" of \"UploadParams\" not set")
|
1026
|
+
end
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
def to_h
|
1030
|
+
@table.dup
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
|
1037
|
+
module RequestParams
|
1038
|
+
# WebhookParams
|
1039
|
+
# == Parameters:
|
1040
|
+
# active::
|
1041
|
+
# Whether webhook is active or inactive
|
1042
|
+
# callback_url::
|
1043
|
+
# Callback URL to send requests to
|
1044
|
+
# description::
|
1045
|
+
# Webhook description
|
1046
|
+
# events::
|
1047
|
+
# List of event names to trigger the webhook (separated by comma)
|
1048
|
+
class WebhookParams < ::OpenStruct
|
1049
|
+
def active=(val)
|
1050
|
+
if val.is_a?(TrueClass)
|
1051
|
+
self.active = true
|
1052
|
+
elsif val.is_a?(FalseClass) #ignore
|
1053
|
+
self.active = b
|
1054
|
+
else
|
1055
|
+
PhraseApp::ParamsHelpers::ParamsValidationError.new("invalid value #{val}")
|
1056
|
+
end
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
def callback_url=(val)
|
1060
|
+
self.callback_url = val
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
def description=(val)
|
1064
|
+
self.description = val
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
def events=(val)
|
1068
|
+
self.events = val
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
def validate
|
1072
|
+
if self.callback_url == nil || self.callback_url == ""
|
1073
|
+
raise PhraseApp::ParamsHelpers::ParamsValidationError.new("Required parameter \"callback_url\" of \"WebhookParams\" not set")
|
1074
|
+
endif self.events == nil || self.events == ""
|
1075
|
+
raise PhraseApp::ParamsHelpers::ParamsValidationError.new("Required parameter \"events\" of \"WebhookParams\" not set")
|
1024
1076
|
end
|
1025
1077
|
end
|
1026
1078
|
|
@@ -3512,7 +3564,7 @@ end
|
|
3512
3564
|
return JSON.load(rc.body).map { |item| PhraseApp::ResponseObjects::Translation.new(item) }, err
|
3513
3565
|
end
|
3514
3566
|
|
3515
|
-
# List translations for a specific locale.
|
3567
|
+
# List translations for a specific locale. If you want to download all translations for one locale we recommend to use the <code>locales#download</code> endpoint.
|
3516
3568
|
# API Path: /v2/projects/:project_id/locales/:locale_id/translations
|
3517
3569
|
# == Parameters:
|
3518
3570
|
# project_id::
|
@@ -3622,7 +3674,7 @@ end
|
|
3622
3674
|
return PhraseApp::ResponseObjects::AffectedCount.new(JSON.load(rc.body)), err
|
3623
3675
|
end
|
3624
3676
|
|
3625
|
-
# List translations for the given project.
|
3677
|
+
# List translations for the given project. If you want to download all translations for one locale we recommend to use the <code>locales#download</code> endpoint.
|
3626
3678
|
# API Path: /v2/projects/:project_id/translations
|
3627
3679
|
# == Parameters:
|
3628
3680
|
# project_id::
|
@@ -3658,7 +3710,7 @@ end
|
|
3658
3710
|
return JSON.load(rc.body).map { |item| PhraseApp::ResponseObjects::Translation.new(item) }, err
|
3659
3711
|
end
|
3660
3712
|
|
3661
|
-
# List translations for the given project if you exceed GET request limitations on translations list.
|
3713
|
+
# 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 <code>locales#download</code> endpoint.
|
3662
3714
|
# API Path: /v2/projects/:project_id/translations/search
|
3663
3715
|
# == Parameters:
|
3664
3716
|
# project_id::
|
@@ -3772,10 +3824,10 @@ end
|
|
3772
3824
|
# project_id::
|
3773
3825
|
# project_id
|
3774
3826
|
# params::
|
3775
|
-
# Parameters of type PhraseApp::RequestParams::
|
3827
|
+
# Parameters of type PhraseApp::RequestParams::UploadParams
|
3776
3828
|
#
|
3777
3829
|
# == Returns:
|
3778
|
-
# PhraseApp::ResponseObjects::
|
3830
|
+
# PhraseApp::ResponseObjects::Upload
|
3779
3831
|
# err
|
3780
3832
|
def upload_create(project_id, params)
|
3781
3833
|
path = sprintf("/api/v2/projects/%s/uploads", project_id)
|
@@ -3783,8 +3835,8 @@ end
|
|
3783
3835
|
post_body = nil
|
3784
3836
|
|
3785
3837
|
if params.present?
|
3786
|
-
unless params.kind_of?(PhraseApp::RequestParams::
|
3787
|
-
raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::
|
3838
|
+
unless params.kind_of?(PhraseApp::RequestParams::UploadParams)
|
3839
|
+
raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::UploadParams")
|
3788
3840
|
end
|
3789
3841
|
end
|
3790
3842
|
if params.convert_emoji != nil
|
@@ -3833,7 +3885,7 @@ end
|
|
3833
3885
|
return nil, err
|
3834
3886
|
end
|
3835
3887
|
|
3836
|
-
return PhraseApp::ResponseObjects::
|
3888
|
+
return PhraseApp::ResponseObjects::Upload.new(JSON.load(rc.body)), err
|
3837
3889
|
end
|
3838
3890
|
|
3839
3891
|
# View details and summary for a single upload.
|
@@ -3845,7 +3897,7 @@ end
|
|
3845
3897
|
# id
|
3846
3898
|
#
|
3847
3899
|
# == Returns:
|
3848
|
-
# PhraseApp::ResponseObjects::
|
3900
|
+
# PhraseApp::ResponseObjects::Upload
|
3849
3901
|
# err
|
3850
3902
|
def upload_show(project_id, id)
|
3851
3903
|
path = sprintf("/api/v2/projects/%s/uploads/%s", project_id, id)
|
@@ -3858,7 +3910,7 @@ end
|
|
3858
3910
|
return nil, err
|
3859
3911
|
end
|
3860
3912
|
|
3861
|
-
return PhraseApp::ResponseObjects::
|
3913
|
+
return PhraseApp::ResponseObjects::Upload.new(JSON.load(rc.body)), err
|
3862
3914
|
end
|
3863
3915
|
|
3864
3916
|
# List all uploads for the given project.
|
@@ -3868,7 +3920,7 @@ end
|
|
3868
3920
|
# project_id
|
3869
3921
|
#
|
3870
3922
|
# == Returns:
|
3871
|
-
# PhraseApp::ResponseObjects::
|
3923
|
+
# PhraseApp::ResponseObjects::Upload
|
3872
3924
|
# err
|
3873
3925
|
def uploads_list(project_id, page, per_page)
|
3874
3926
|
path = sprintf("/api/v2/projects/%s/uploads", project_id)
|
@@ -3881,7 +3933,7 @@ end
|
|
3881
3933
|
return nil, err
|
3882
3934
|
end
|
3883
3935
|
|
3884
|
-
return JSON.load(rc.body).map { |item| PhraseApp::ResponseObjects::
|
3936
|
+
return JSON.load(rc.body).map { |item| PhraseApp::ResponseObjects::Upload.new(item) }, err
|
3885
3937
|
end
|
3886
3938
|
|
3887
3939
|
# Get details on a single version.
|
@@ -3936,6 +3988,176 @@ end
|
|
3936
3988
|
return JSON.load(rc.body).map { |item| PhraseApp::ResponseObjects::TranslationVersion.new(item) }, err
|
3937
3989
|
end
|
3938
3990
|
|
3991
|
+
# Create a new webhook.
|
3992
|
+
# API Path: /v2/projects/:project_id/webhooks
|
3993
|
+
# == Parameters:
|
3994
|
+
# project_id::
|
3995
|
+
# project_id
|
3996
|
+
# params::
|
3997
|
+
# Parameters of type PhraseApp::RequestParams::WebhookParams
|
3998
|
+
#
|
3999
|
+
# == Returns:
|
4000
|
+
# PhraseApp::ResponseObjects::Webhook
|
4001
|
+
# err
|
4002
|
+
def webhook_create(project_id, params)
|
4003
|
+
path = sprintf("/api/v2/projects/%s/webhooks", project_id)
|
4004
|
+
data_hash = {}
|
4005
|
+
post_body = nil
|
4006
|
+
|
4007
|
+
if params.present?
|
4008
|
+
unless params.kind_of?(PhraseApp::RequestParams::WebhookParams)
|
4009
|
+
raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::WebhookParams")
|
4010
|
+
end
|
4011
|
+
end
|
4012
|
+
|
4013
|
+
data_hash = params.to_h
|
4014
|
+
err = params.validate
|
4015
|
+
if err != nil
|
4016
|
+
return nil, err
|
4017
|
+
end
|
4018
|
+
reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
|
4019
|
+
rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 201)
|
4020
|
+
if err != nil
|
4021
|
+
return nil, err
|
4022
|
+
end
|
4023
|
+
|
4024
|
+
return PhraseApp::ResponseObjects::Webhook.new(JSON.load(rc.body)), err
|
4025
|
+
end
|
4026
|
+
|
4027
|
+
# Delete an existing webhook.
|
4028
|
+
# API Path: /v2/projects/:project_id/webhooks/:id
|
4029
|
+
# == Parameters:
|
4030
|
+
# project_id::
|
4031
|
+
# project_id
|
4032
|
+
# id::
|
4033
|
+
# id
|
4034
|
+
#
|
4035
|
+
# == Returns:
|
4036
|
+
# err
|
4037
|
+
def webhook_delete(project_id, id)
|
4038
|
+
path = sprintf("/api/v2/projects/%s/webhooks/%s", project_id, id)
|
4039
|
+
data_hash = {}
|
4040
|
+
post_body = nil
|
4041
|
+
|
4042
|
+
reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
|
4043
|
+
rc, err = PhraseApp.send_request(@credentials, "DELETE", path, reqHelper.ctype, reqHelper.body, 204)
|
4044
|
+
if err != nil
|
4045
|
+
return nil, err
|
4046
|
+
end
|
4047
|
+
|
4048
|
+
return err
|
4049
|
+
end
|
4050
|
+
|
4051
|
+
# Get details on a single webhook.
|
4052
|
+
# API Path: /v2/projects/:project_id/webhooks/:id
|
4053
|
+
# == Parameters:
|
4054
|
+
# project_id::
|
4055
|
+
# project_id
|
4056
|
+
# id::
|
4057
|
+
# id
|
4058
|
+
#
|
4059
|
+
# == Returns:
|
4060
|
+
# PhraseApp::ResponseObjects::Webhook
|
4061
|
+
# err
|
4062
|
+
def webhook_show(project_id, id)
|
4063
|
+
path = sprintf("/api/v2/projects/%s/webhooks/%s", project_id, id)
|
4064
|
+
data_hash = {}
|
4065
|
+
post_body = nil
|
4066
|
+
|
4067
|
+
reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
|
4068
|
+
rc, err = PhraseApp.send_request(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200)
|
4069
|
+
if err != nil
|
4070
|
+
return nil, err
|
4071
|
+
end
|
4072
|
+
|
4073
|
+
return PhraseApp::ResponseObjects::Webhook.new(JSON.load(rc.body)), err
|
4074
|
+
end
|
4075
|
+
|
4076
|
+
# Perform a test request for a webhook.
|
4077
|
+
# API Path: /v2/projects/:project_id/webhooks/:id/test
|
4078
|
+
# == Parameters:
|
4079
|
+
# project_id::
|
4080
|
+
# project_id
|
4081
|
+
# id::
|
4082
|
+
# id
|
4083
|
+
#
|
4084
|
+
# == Returns:
|
4085
|
+
# err
|
4086
|
+
def webhook_test(project_id, id)
|
4087
|
+
path = sprintf("/api/v2/projects/%s/webhooks/%s/test", project_id, id)
|
4088
|
+
data_hash = {}
|
4089
|
+
post_body = nil
|
4090
|
+
|
4091
|
+
reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
|
4092
|
+
rc, err = PhraseApp.send_request(@credentials, "POST", path, reqHelper.ctype, reqHelper.body, 200)
|
4093
|
+
if err != nil
|
4094
|
+
return nil, err
|
4095
|
+
end
|
4096
|
+
|
4097
|
+
return err
|
4098
|
+
end
|
4099
|
+
|
4100
|
+
# Update an existing webhook.
|
4101
|
+
# API Path: /v2/projects/:project_id/webhooks/:id
|
4102
|
+
# == Parameters:
|
4103
|
+
# project_id::
|
4104
|
+
# project_id
|
4105
|
+
# id::
|
4106
|
+
# id
|
4107
|
+
# params::
|
4108
|
+
# Parameters of type PhraseApp::RequestParams::WebhookParams
|
4109
|
+
#
|
4110
|
+
# == Returns:
|
4111
|
+
# PhraseApp::ResponseObjects::Webhook
|
4112
|
+
# err
|
4113
|
+
def webhook_update(project_id, id, params)
|
4114
|
+
path = sprintf("/api/v2/projects/%s/webhooks/%s", project_id, id)
|
4115
|
+
data_hash = {}
|
4116
|
+
post_body = nil
|
4117
|
+
|
4118
|
+
if params.present?
|
4119
|
+
unless params.kind_of?(PhraseApp::RequestParams::WebhookParams)
|
4120
|
+
raise PhraseApp::ParamsHelpers::ParamsError.new("Expects params to be kind_of PhraseApp::RequestParams::WebhookParams")
|
4121
|
+
end
|
4122
|
+
end
|
4123
|
+
|
4124
|
+
data_hash = params.to_h
|
4125
|
+
err = params.validate
|
4126
|
+
if err != nil
|
4127
|
+
return nil, err
|
4128
|
+
end
|
4129
|
+
reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
|
4130
|
+
rc, err = PhraseApp.send_request(@credentials, "PATCH", path, reqHelper.ctype, reqHelper.body, 200)
|
4131
|
+
if err != nil
|
4132
|
+
return nil, err
|
4133
|
+
end
|
4134
|
+
|
4135
|
+
return PhraseApp::ResponseObjects::Webhook.new(JSON.load(rc.body)), err
|
4136
|
+
end
|
4137
|
+
|
4138
|
+
# List all webhooks for the given project.
|
4139
|
+
# API Path: /v2/projects/:project_id/webhooks
|
4140
|
+
# == Parameters:
|
4141
|
+
# project_id::
|
4142
|
+
# project_id
|
4143
|
+
#
|
4144
|
+
# == Returns:
|
4145
|
+
# PhraseApp::ResponseObjects::Webhook
|
4146
|
+
# err
|
4147
|
+
def webhooks_list(project_id, page, per_page)
|
4148
|
+
path = sprintf("/api/v2/projects/%s/webhooks", project_id)
|
4149
|
+
data_hash = {}
|
4150
|
+
post_body = nil
|
4151
|
+
|
4152
|
+
reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)
|
4153
|
+
rc, err = PhraseApp.send_request_paginated(@credentials, "GET", path, reqHelper.ctype, reqHelper.body, 200, page, per_page)
|
4154
|
+
if err != nil
|
4155
|
+
return nil, err
|
4156
|
+
end
|
4157
|
+
|
4158
|
+
return JSON.load(rc.body).map { |item| PhraseApp::ResponseObjects::Webhook.new(item) }, err
|
4159
|
+
end
|
4160
|
+
|
3939
4161
|
end
|
3940
4162
|
|
3941
4163
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phraseapp-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PhraseApp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PhraseApp API client libary
|
14
14
|
email:
|
@@ -17,10 +17,10 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- lib/auth.rb
|
21
20
|
- lib/phraseapp-ruby.rb
|
22
|
-
- lib/
|
23
|
-
- lib/
|
21
|
+
- lib/phraseapp-ruby/auth.rb
|
22
|
+
- lib/phraseapp-ruby/request_handler.rb
|
23
|
+
- lib/phraseapp-ruby/version.rb
|
24
24
|
homepage: https://github.com/phrase/phraseapp-ruby
|
25
25
|
licenses:
|
26
26
|
- BSD
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.4.
|
44
|
+
rubygems_version: 2.4.5.1
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: Interact with the PhraseApp API
|