Skip to content

Commit 18ffce1

Browse files
committed
Updated sources
1 parent 9c767ef commit 18ffce1

File tree

10 files changed

+482
-16
lines changed

10 files changed

+482
-16
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
groupdocs_conversion_cloud (23.7)
4+
groupdocs_conversion_cloud (23.8)
55
addressable (~> 2.8.0, >= 2.8.0)
66
faraday (~> 0.14.0)
77

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem install groupdocs_conversion_cloud
1212
To add dependency to your app copy following into your Gemfile and run `bundle install`:
1313

1414
```
15-
gem "groupdocs_conversion_cloud", "~> 23.7"
15+
gem "groupdocs_conversion_cloud", "~> 23.8"
1616
```
1717

1818
## Getting Started

lib/groupdocs_conversion_cloud.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525

2626
# Common files
2727
require_relative 'groupdocs_conversion_cloud/api_client'
28-
require_relative 'groupdocs_conversion_cloud/api_error'
28+
require_relative 'groupdocs_conversion_cloud/api_client_error'
2929
require_relative 'groupdocs_conversion_cloud/version'
3030
require_relative 'groupdocs_conversion_cloud/configuration'
3131

3232
# Models
33+
require_relative 'groupdocs_conversion_cloud/models/api_error'
34+
require_relative 'groupdocs_conversion_cloud/models/api_error_response'
3335
require_relative 'groupdocs_conversion_cloud/models/consumption_result'
3436
require_relative 'groupdocs_conversion_cloud/models/convert_options'
3537
require_relative 'groupdocs_conversion_cloud/models/convert_settings'

lib/groupdocs_conversion_cloud/api_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
require 'mimemagic'
3232
require 'addressable'
3333
require_relative 'version'
34-
require_relative 'api_error'
34+
require_relative 'api_client_error'
3535

3636
module GroupDocsConversionCloud
3737
#
@@ -69,7 +69,7 @@ def call_api(http_method, path, opts = {})
6969
end
7070

7171
unless response.success?
72-
raise ApiError.new(:code => response.status, :response_body => response.body)
72+
raise ApiClientError.new(:code => response.status, :response_body => response.body)
7373
end
7474

7575
data = deserialize(response, opts[:return_type]) if opts[:return_type]

lib/groupdocs_conversion_cloud/api_error.rb renamed to lib/groupdocs_conversion_cloud/api_client_error.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@
2525

2626
module GroupDocsConversionCloud
2727
#
28-
# ApiError class for error handling
28+
# ApiClientError class for error handling
2929
#
30-
class ApiError < StandardError
30+
class ApiClientError < StandardError
3131
attr_reader :code
3232
attr_reader :message
3333

3434
# Usage examples:
35-
# ApiError.new
36-
# ApiError.new(:code => 500, :response_body => "")
37-
def initialize(arg = nil)
38-
if arg.is_a? Hash
39-
35+
# ApiClientError.new
36+
# ApiClientError.new(:code => 500, :response_body => "")
37+
def initialize(arg = nil)
38+
if arg.is_a? Hash
4039
if arg.key?(:response_body) then
4140
data = JSON.parse(arg[:response_body], :symbolize_names => true)
4241
if !data.nil? then
@@ -69,3 +68,4 @@ def initialize(arg = nil)
6968
end
7069
end
7170
end
71+
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
#
2+
# --------------------------------------------------------------------------------------------------------------------
3+
# <copyright company="Aspose Pty Ltd" file="api_error.rb">
4+
# Copyright (c) 2003-2023 Aspose Pty Ltd
5+
# </copyright>
6+
# <summary>
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
# </summary>
25+
# --------------------------------------------------------------------------------------------------------------------
26+
#
27+
28+
require 'date'
29+
30+
module GroupDocsConversionCloud
31+
32+
class ApiError
33+
attr_accessor :code
34+
attr_accessor :message
35+
attr_accessor :description
36+
attr_accessor :date_time
37+
attr_accessor :inner_error
38+
39+
# Attribute mapping from ruby-style variable name to JSON key.
40+
def self.attribute_map
41+
{
42+
:'code' => :'Code',
43+
:'message' => :'Message',
44+
:'description' => :'Description',
45+
:'date_time' => :'DateTime',
46+
:'inner_error' => :'InnerError'
47+
}
48+
end
49+
50+
# Attribute type mapping.
51+
def self.swagger_types
52+
{
53+
:'code' => :'String',
54+
:'message' => :'String',
55+
:'description' => :'String',
56+
:'date_time' => :'DateTime',
57+
:'inner_error' => :'ApiError'
58+
}
59+
end
60+
61+
# Initializes the object
62+
# @param [Hash] attributes Model attributes in the form of hash
63+
def initialize(attributes = {})
64+
return unless attributes.is_a?(Hash)
65+
66+
# convert string to symbol for hash key
67+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
68+
69+
if attributes.key?(:'Code')
70+
self.code = attributes[:'Code']
71+
end
72+
73+
if attributes.key?(:'Message')
74+
self.message = attributes[:'Message']
75+
end
76+
77+
if attributes.key?(:'Description')
78+
self.description = attributes[:'Description']
79+
end
80+
81+
if attributes.key?(:'DateTime')
82+
self.date_time = attributes[:'DateTime']
83+
end
84+
85+
if attributes.key?(:'InnerError')
86+
self.inner_error = attributes[:'InnerError']
87+
end
88+
89+
end
90+
91+
# Show invalid properties with the reasons. Usually used together with valid?
92+
# @return Array for valid properies with the reasons
93+
def list_invalid_properties
94+
invalid_properties = []
95+
return invalid_properties
96+
end
97+
98+
# Check to see if the all the properties in the model are valid
99+
# @return true if the model is valid
100+
def valid?
101+
return true
102+
end
103+
104+
# Checks equality by comparing each attribute.
105+
# @param [Object] Object to be compared
106+
def ==(other)
107+
return true if self.equal?(other)
108+
self.class == other.class &&
109+
code == other.code &&
110+
message == other.message &&
111+
description == other.description &&
112+
date_time == other.date_time &&
113+
inner_error == other.inner_error
114+
end
115+
116+
# @see the `==` method
117+
# @param [Object] Object to be compared
118+
def eql?(other)
119+
self == other
120+
end
121+
122+
# Calculates hash code according to all attributes.
123+
# @return [Fixnum] Hash code
124+
def hash
125+
[code, message, description, date_time, inner_error].hash
126+
end
127+
128+
# Downcases first letter.
129+
# @return downcased string
130+
def uncap(str)
131+
str[0, 1].downcase + str[1..-1]
132+
end
133+
134+
# Builds the object from hash
135+
# @param [Hash] attributes Model attributes in the form of hash
136+
# @return [Object] Returns the model itself
137+
def build_from_hash(attributes)
138+
return nil unless attributes.is_a?(Hash)
139+
self.class.swagger_types.each_pair do |key, type|
140+
pname = uncap(self.class.attribute_map[key]).intern
141+
value = attributes[pname]
142+
if type =~ /\AArray<(.*)>/i
143+
# check to ensure the input is an array given that the the attribute
144+
# is documented as an array but the input is not
145+
if value.is_a?(Array)
146+
self.send("#{key}=", value.map { |v| _deserialize($1, v) })
147+
end
148+
elsif !value.nil?
149+
self.send("#{key}=", _deserialize(type, value))
150+
end
151+
# or else data not found in attributes(hash), not an issue as the data can be optional
152+
end
153+
154+
self
155+
end
156+
157+
# Deserializes the data based on type
158+
# @param string type Data type
159+
# @param string value Value to be deserialized
160+
# @return [Object] Deserialized data
161+
def _deserialize(type, value)
162+
case type.to_sym
163+
when :DateTime
164+
Date.parse value
165+
when :Date
166+
Date.parse value
167+
when :String
168+
value.to_s
169+
when :Integer
170+
value.to_i
171+
when :Float
172+
value.to_f
173+
when :BOOLEAN
174+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
175+
true
176+
else
177+
false
178+
end
179+
when :Object
180+
# generic object (usually a Hash), return directly
181+
value
182+
when /\AArray<(?<inner_type>.+)>\z/
183+
inner_type = Regexp.last_match[:inner_type]
184+
value.map { |v| _deserialize(inner_type, v) }
185+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
186+
k_type = Regexp.last_match[:k_type]
187+
v_type = Regexp.last_match[:v_type]
188+
{}.tap do |hash|
189+
value.each do |k, v|
190+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
191+
end
192+
end
193+
else
194+
# model
195+
temp_model = GroupDocsConversionCloud.const_get(type).new
196+
temp_model.build_from_hash(value)
197+
end
198+
end
199+
200+
# Returns the string representation of the object
201+
# @return [String] String presentation of the object
202+
def to_s
203+
to_hash.to_s
204+
end
205+
206+
# to_body is an alias to to_hash (backward compatibility)
207+
# @return [Hash] Returns the object in the form of hash
208+
def to_body
209+
to_hash
210+
end
211+
212+
# Returns the object in the form of hash
213+
# @return [Hash] Returns the object in the form of hash
214+
def to_hash
215+
hash = {}
216+
self.class.attribute_map.each_pair do |attr, param|
217+
value = self.send(attr)
218+
next if value.nil?
219+
hash[param] = _to_hash(value)
220+
end
221+
hash
222+
end
223+
224+
# Outputs non-array value in the form of hash
225+
# For object, use to_hash. Otherwise, just return the value
226+
# @param [Object] value Any valid value
227+
# @return [Hash] Returns the value in the form of hash
228+
def _to_hash(value)
229+
if value.is_a?(Array)
230+
value.compact.map { |v| _to_hash(v) }
231+
elsif value.is_a?(Hash)
232+
{}.tap do |hash|
233+
value.each { |k, v| hash[k] = _to_hash(v) }
234+
end
235+
elsif value.respond_to? :to_hash
236+
value.to_hash
237+
else
238+
value
239+
end
240+
end
241+
242+
end
243+
244+
end

0 commit comments

Comments
 (0)