translationApiClient 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,87 @@
1
+ module TranslationApiClient
2
+ # base class containing fundamental method such as to_hash, build_from_hash and more
3
+ class BaseObject
4
+
5
+ # return the object in the form of hash
6
+ def to_body
7
+ body = {}
8
+ self.class.attribute_map.each_pair do |key, value|
9
+ body[value] = self.send(key) unless self.send(key).nil?
10
+ end
11
+ body
12
+ end
13
+
14
+ # build the object from hash
15
+ def build_from_hash(attributes)
16
+ return nil unless attributes.is_a?(Hash)
17
+ self.class.swagger_types.each_pair do |key, type|
18
+ if type =~ /^array\[(.*)\]/i
19
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
20
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
21
+ else
22
+ #TODO show warning in debug mode
23
+ end
24
+ elsif !attributes[self.class.attribute_map[key]].nil?
25
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
26
+ else
27
+ # data not found in attributes(hash), not an issue as the data can be optional
28
+ end
29
+ end
30
+
31
+ self
32
+ end
33
+
34
+ def _deserialize(type, value)
35
+ case type.to_sym
36
+ when :DateTime
37
+ DateTime.parse(value)
38
+ when :string
39
+ value.to_s
40
+ when :number
41
+ value.to_i
42
+ when :object
43
+ OpenStruct.new(value)
44
+ when :int
45
+ value.to_i
46
+ when :double
47
+ value.to_f
48
+ when :boolean
49
+ if value =~ /^(true|t|yes|y|1)$/i
50
+ true
51
+ else
52
+ false
53
+ end
54
+ else # model
55
+ _model = TranslationApiClient.const_get(type).new
56
+ _model.build_from_hash(value)
57
+ end
58
+ end
59
+
60
+ # to_body is an alias to to_body (backward compatibility)
61
+ def to_hash
62
+ hash = {}
63
+ self.class.attribute_map.each_pair do |key, value|
64
+ if self.send(key).is_a?(Array)
65
+ next if self.send(key).empty?
66
+ hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil?
67
+ else
68
+ unless (_tmp_value = _to_hash self.send(key)).nil?
69
+ hash[value] = _tmp_value
70
+ end
71
+ end
72
+ end
73
+ hash
74
+ end
75
+
76
+ # Method to output non-array value in the form of hash
77
+ # For object, use to_hash. Otherwise, just return the value
78
+ def _to_hash(value)
79
+ if value.respond_to? :to_hash
80
+ value.to_hash
81
+ else
82
+ value
83
+ end
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,54 @@
1
+ module TranslationApiClient
2
+ #
3
+ class LanguagePair < BaseObject
4
+ attr_accessor :source, :target, :profile_ids
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Source language
10
+ :'source' => :'source',
11
+
12
+ # Target language
13
+ :'target' => :'target',
14
+
15
+ # Array of profile identifiers
16
+ :'profile_ids' => :'profileIds'
17
+
18
+ }
19
+ end
20
+
21
+ # attribute type
22
+ def self.swagger_types
23
+ {
24
+ :'source' => :'string',
25
+ :'target' => :'string',
26
+ :'profile_ids' => :'array[ProfileId]'
27
+
28
+ }
29
+ end
30
+
31
+ def initialize(attributes = {})
32
+ return if !attributes.is_a?(Hash) || attributes.empty?
33
+
34
+ # convert string to symbol for hash key
35
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
36
+
37
+
38
+ if attributes[:'source']
39
+ @source = attributes[:'source']
40
+ end
41
+
42
+ if attributes[:'target']
43
+ @target = attributes[:'target']
44
+ end
45
+
46
+ if attributes[:'profileIds']
47
+ if (value = attributes[:'profileIds']).is_a?(Array)
48
+ @profile_ids = value
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,68 @@
1
+ module TranslationApiClient
2
+ #
3
+ class Profile < BaseObject
4
+ attr_accessor :id, :localization, :name, :source, :target
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Profile identifier
10
+ :'id' => :'id',
11
+
12
+ # Localization of the profile name
13
+ :'localization' => :'localization',
14
+
15
+ # Name
16
+ :'name' => :'name',
17
+
18
+ # Source
19
+ :'source' => :'source',
20
+
21
+ # Target
22
+ :'target' => :'target'
23
+
24
+ }
25
+ end
26
+
27
+ # attribute type
28
+ def self.swagger_types
29
+ {
30
+ :'id' => :'int',
31
+ :'localization' => :'object',
32
+ :'name' => :'string',
33
+ :'source' => :'string',
34
+ :'target' => :'string'
35
+
36
+ }
37
+ end
38
+
39
+ def initialize(attributes = {})
40
+ return if !attributes.is_a?(Hash) || attributes.empty?
41
+
42
+ # convert string to symbol for hash key
43
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
44
+
45
+
46
+ if attributes[:'id']
47
+ @id = attributes[:'id']
48
+ end
49
+
50
+ if attributes[:'localization']
51
+ @localization = attributes[:'localization']
52
+ end
53
+
54
+ if attributes[:'name']
55
+ @name = attributes[:'name']
56
+ end
57
+
58
+ if attributes[:'source']
59
+ @source = attributes[:'source']
60
+ end
61
+
62
+ if attributes[:'target']
63
+ @target = attributes[:'target']
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,44 @@
1
+ module TranslationApiClient
2
+ #
3
+ class ProfileId < BaseObject
4
+ attr_accessor :id, :private
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Profile identifier
10
+ :'id' => :'id',
11
+
12
+ # Public or private profile
13
+ :'private' => :'private'
14
+
15
+ }
16
+ end
17
+
18
+ # attribute type
19
+ def self.swagger_types
20
+ {
21
+ :'id' => :'int',
22
+ :'private' => :'boolean'
23
+
24
+ }
25
+ end
26
+
27
+ def initialize(attributes = {})
28
+ return if !attributes.is_a?(Hash) || attributes.empty?
29
+
30
+ # convert string to symbol for hash key
31
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
32
+
33
+
34
+ if attributes[:'id']
35
+ @id = attributes[:'id']
36
+ end
37
+
38
+ if attributes[:'private']
39
+ @private = attributes[:'private']
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,38 @@
1
+ module TranslationApiClient
2
+ #
3
+ class ProfilesResponse < BaseObject
4
+ attr_accessor :profiles
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Array of profiles
10
+ :'profiles' => :'profiles'
11
+
12
+ }
13
+ end
14
+
15
+ # attribute type
16
+ def self.swagger_types
17
+ {
18
+ :'profiles' => :'array[Profile]'
19
+
20
+ }
21
+ end
22
+
23
+ def initialize(attributes = {})
24
+ return if !attributes.is_a?(Hash) || attributes.empty?
25
+
26
+ # convert string to symbol for hash key
27
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
28
+
29
+
30
+ if attributes[:'profiles']
31
+ if (value = attributes[:'profiles']).is_a?(Array)
32
+ @profiles = value
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,54 @@
1
+ module TranslationApiClient
2
+ #
3
+ class SupportedLanguageResponse < BaseObject
4
+ attr_accessor :warning, :error, :language_pairs
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Warning at request level
10
+ :'warning' => :'warning',
11
+
12
+ # Error at request level
13
+ :'error' => :'error',
14
+
15
+ # Array of language pairs
16
+ :'language_pairs' => :'languagePairs'
17
+
18
+ }
19
+ end
20
+
21
+ # attribute type
22
+ def self.swagger_types
23
+ {
24
+ :'warning' => :'string',
25
+ :'error' => :'string',
26
+ :'language_pairs' => :'array[LanguagePair]'
27
+
28
+ }
29
+ end
30
+
31
+ def initialize(attributes = {})
32
+ return if !attributes.is_a?(Hash) || attributes.empty?
33
+
34
+ # convert string to symbol for hash key
35
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
36
+
37
+
38
+ if attributes[:'warning']
39
+ @warning = attributes[:'warning']
40
+ end
41
+
42
+ if attributes[:'error']
43
+ @error = attributes[:'error']
44
+ end
45
+
46
+ if attributes[:'languagePairs']
47
+ if (value = attributes[:'languagePairs']).is_a?(Array)
48
+ @language_pairs = value
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,36 @@
1
+ module TranslationApiClient
2
+ #
3
+ class TranslationCancel < BaseObject
4
+ attr_accessor :error
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Error of the request
10
+ :'error' => :'error'
11
+
12
+ }
13
+ end
14
+
15
+ # attribute type
16
+ def self.swagger_types
17
+ {
18
+ :'error' => :'string'
19
+
20
+ }
21
+ end
22
+
23
+ def initialize(attributes = {})
24
+ return if !attributes.is_a?(Hash) || attributes.empty?
25
+
26
+ # convert string to symbol for hash key
27
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
28
+
29
+
30
+ if attributes[:'error']
31
+ @error = attributes[:'error']
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,84 @@
1
+ module TranslationApiClient
2
+ #
3
+ class TranslationOutput < BaseObject
4
+ attr_accessor :warning, :error, :detected_language, :detected_language_confidence, :output, :back_translation, :source
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Warning at output level
10
+ :'warning' => :'warning',
11
+
12
+ # Error at output level
13
+ :'error' => :'error',
14
+
15
+ # Result of the automatic language detection if `auto` was specified as source language
16
+ :'detected_language' => :'detectedLanguage',
17
+
18
+ # Automatic language detection confidence
19
+ :'detected_language_confidence' => :'detectedLanguageConfidence',
20
+
21
+ # Translated text
22
+ :'output' => :'output',
23
+
24
+ # Retranslation of output in source language, if backTranslation was specified
25
+ :'back_translation' => :'backTranslation',
26
+
27
+ # Source text, if withSource was specified
28
+ :'source' => :'source'
29
+
30
+ }
31
+ end
32
+
33
+ # attribute type
34
+ def self.swagger_types
35
+ {
36
+ :'warning' => :'string',
37
+ :'error' => :'string',
38
+ :'detected_language' => :'string',
39
+ :'detected_language_confidence' => :'double',
40
+ :'output' => :'string',
41
+ :'back_translation' => :'string',
42
+ :'source' => :'string'
43
+
44
+ }
45
+ end
46
+
47
+ def initialize(attributes = {})
48
+ return if !attributes.is_a?(Hash) || attributes.empty?
49
+
50
+ # convert string to symbol for hash key
51
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
52
+
53
+
54
+ if attributes[:'warning']
55
+ @warning = attributes[:'warning']
56
+ end
57
+
58
+ if attributes[:'error']
59
+ @error = attributes[:'error']
60
+ end
61
+
62
+ if attributes[:'detectedLanguage']
63
+ @detected_language = attributes[:'detectedLanguage']
64
+ end
65
+
66
+ if attributes[:'detectedLanguageConfidence']
67
+ @detected_language_confidence = attributes[:'detectedLanguageConfidence']
68
+ end
69
+
70
+ if attributes[:'output']
71
+ @output = attributes[:'output']
72
+ end
73
+
74
+ if attributes[:'backTranslation']
75
+ @back_translation = attributes[:'backTranslation']
76
+ end
77
+
78
+ if attributes[:'source']
79
+ @source = attributes[:'source']
80
+ end
81
+
82
+ end
83
+ end
84
+ end