tripletex_ruby_client 1.0.4 → 1.0.8
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +5 -1
- data/lib/tripletex_ruby_client/api/invoice_api.rb +19 -13
- data/lib/tripletex_ruby_client/api/reminder_api.rb +55 -3
- data/lib/tripletex_ruby_client/api_client.rb +21 -4
- data/lib/tripletex_ruby_client/api_error.rb +12 -0
- data/lib/tripletex_ruby_client/models/invoice.rb +22 -3
- data/lib/tripletex_ruby_client/models/invoice_remark.rb +229 -0
- data/lib/tripletex_ruby_client/version.rb +1 -1
- data/lib/tripletex_ruby_client.rb +1 -0
- data/spec/api_client_spec.rb +53 -0
- metadata +778 -777
@@ -0,0 +1,229 @@
|
|
1
|
+
=begin
|
2
|
+
#Tripletex API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.70.15
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
Swagger Codegen version: 2.4.30
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
module TripletexRubyClient
|
14
|
+
class InvoiceRemark
|
15
|
+
attr_accessor :id
|
16
|
+
|
17
|
+
attr_accessor :version
|
18
|
+
|
19
|
+
attr_accessor :changes
|
20
|
+
|
21
|
+
attr_accessor :url
|
22
|
+
|
23
|
+
attr_accessor :description
|
24
|
+
|
25
|
+
attr_accessor :postpone_reminders_to
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'id' => :'id',
|
31
|
+
:'version' => :'version',
|
32
|
+
:'changes' => :'changes',
|
33
|
+
:'url' => :'url',
|
34
|
+
:'description' => :'description',
|
35
|
+
:'postpone_reminders_to' => :'postponeRemindersTo'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.swagger_types
|
41
|
+
{
|
42
|
+
:'id' => :'Integer',
|
43
|
+
:'version' => :'Integer',
|
44
|
+
:'changes' => :'Array<Change>',
|
45
|
+
:'url' => :'String',
|
46
|
+
:'description' => :'String',
|
47
|
+
:'postpone_reminders_to' => :'String'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initializes the object
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
53
|
+
def initialize(attributes = {})
|
54
|
+
return unless attributes.is_a?(Hash)
|
55
|
+
|
56
|
+
# convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
58
|
+
|
59
|
+
if attributes.has_key?(:'id')
|
60
|
+
self.id = attributes[:'id']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'version')
|
64
|
+
self.version = attributes[:'version']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'changes')
|
68
|
+
if (value = attributes[:'changes']).is_a?(Array)
|
69
|
+
self.changes = value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.has_key?(:'url')
|
74
|
+
self.url = attributes[:'url']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'description')
|
78
|
+
self.description = attributes[:'description']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'postponeRemindersTo')
|
82
|
+
self.postpone_reminders_to = attributes[:'postponeRemindersTo']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
87
|
+
# @return Array for valid properties with the reasons
|
88
|
+
def list_invalid_properties
|
89
|
+
invalid_properties = Array.new
|
90
|
+
invalid_properties
|
91
|
+
end
|
92
|
+
|
93
|
+
# Check to see if the all the properties in the model are valid
|
94
|
+
# @return true if the model is valid
|
95
|
+
def valid?
|
96
|
+
true
|
97
|
+
end
|
98
|
+
|
99
|
+
# Checks equality by comparing each attribute.
|
100
|
+
# @param [Object] Object to be compared
|
101
|
+
def ==(o)
|
102
|
+
return true if self.equal?(o)
|
103
|
+
self.class == o.class &&
|
104
|
+
id == o.id &&
|
105
|
+
version == o.version &&
|
106
|
+
changes == o.changes &&
|
107
|
+
url == o.url &&
|
108
|
+
description == o.description &&
|
109
|
+
postpone_reminders_to == o.postpone_reminders_to
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Fixnum] Hash code
|
120
|
+
def hash
|
121
|
+
[id, version, changes, url, description, postpone_reminders_to].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def build_from_hash(attributes)
|
128
|
+
return nil unless attributes.is_a?(Hash)
|
129
|
+
self.class.swagger_types.each_pair do |key, type|
|
130
|
+
if type =~ /\AArray<(.*)>/i
|
131
|
+
# check to ensure the input is an array given that the attribute
|
132
|
+
# is documented as an array but the input is not
|
133
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
134
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
135
|
+
end
|
136
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
137
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
138
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
139
|
+
end
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
# Deserializes the data based on type
|
145
|
+
# @param string type Data type
|
146
|
+
# @param string value Value to be deserialized
|
147
|
+
# @return [Object] Deserialized data
|
148
|
+
def _deserialize(type, value)
|
149
|
+
case type.to_sym
|
150
|
+
when :DateTime
|
151
|
+
DateTime.parse(value)
|
152
|
+
when :Date
|
153
|
+
Date.parse(value)
|
154
|
+
when :String
|
155
|
+
value.to_s
|
156
|
+
when :Integer
|
157
|
+
value.to_i
|
158
|
+
when :Float
|
159
|
+
value.to_f
|
160
|
+
when :BOOLEAN
|
161
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
162
|
+
true
|
163
|
+
else
|
164
|
+
false
|
165
|
+
end
|
166
|
+
when :Object
|
167
|
+
# generic object (usually a Hash), return directly
|
168
|
+
value
|
169
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
170
|
+
inner_type = Regexp.last_match[:inner_type]
|
171
|
+
value.map { |v| _deserialize(inner_type, v) }
|
172
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
173
|
+
k_type = Regexp.last_match[:k_type]
|
174
|
+
v_type = Regexp.last_match[:v_type]
|
175
|
+
{}.tap do |hash|
|
176
|
+
value.each do |k, v|
|
177
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
else # model
|
181
|
+
temp_model = TripletexRubyClient.const_get(type).new
|
182
|
+
temp_model.build_from_hash(value)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the string representation of the object
|
187
|
+
# @return [String] String presentation of the object
|
188
|
+
def to_s
|
189
|
+
to_hash.to_s
|
190
|
+
end
|
191
|
+
|
192
|
+
# to_body is an alias to to_hash (backward compatibility)
|
193
|
+
# @return [Hash] Returns the object in the form of hash
|
194
|
+
def to_body
|
195
|
+
to_hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Returns the object in the form of hash
|
199
|
+
# @return [Hash] Returns the object in the form of hash
|
200
|
+
def to_hash
|
201
|
+
hash = {}
|
202
|
+
self.class.attribute_map.each_pair do |attr, param|
|
203
|
+
value = self.send(attr)
|
204
|
+
next if value.nil?
|
205
|
+
hash[param] = _to_hash(value)
|
206
|
+
end
|
207
|
+
hash
|
208
|
+
end
|
209
|
+
|
210
|
+
# Outputs non-array value in the form of hash
|
211
|
+
# For object, use to_hash. Otherwise, just return the value
|
212
|
+
# @param [Object] value Any valid value
|
213
|
+
# @return [Hash] Returns the value in the form of hash
|
214
|
+
def _to_hash(value)
|
215
|
+
if value.is_a?(Array)
|
216
|
+
value.compact.map { |v| _to_hash(v) }
|
217
|
+
elsif value.is_a?(Hash)
|
218
|
+
{}.tap do |hash|
|
219
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
220
|
+
end
|
221
|
+
elsif value.respond_to? :to_hash
|
222
|
+
value.to_hash
|
223
|
+
else
|
224
|
+
value
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
end
|
@@ -136,6 +136,7 @@ require 'tripletex_ruby_client/models/inventory'
|
|
136
136
|
require 'tripletex_ruby_client/models/inventory_location'
|
137
137
|
require 'tripletex_ruby_client/models/invoice'
|
138
138
|
require 'tripletex_ruby_client/models/invoice_field'
|
139
|
+
require 'tripletex_ruby_client/models/invoice_remark'
|
139
140
|
require 'tripletex_ruby_client/models/invoice_send_type_dto'
|
140
141
|
require 'tripletex_ruby_client/models/invoice_settings_dto'
|
141
142
|
require 'tripletex_ruby_client/models/job'
|
data/spec/api_client_spec.rb
CHANGED
@@ -240,4 +240,57 @@ describe TripletexRubyClient::ApiClient do
|
|
240
240
|
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
241
241
|
end
|
242
242
|
end
|
243
|
+
|
244
|
+
describe '#raise_error' do
|
245
|
+
let(:api_client) { TripletexRubyClient::ApiClient.new }
|
246
|
+
let(:response) do
|
247
|
+
instance_double('Response', code: code, headers: {}, body: "", status_message: "")
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'when the response code is 400' do
|
251
|
+
let(:code) { 400 }
|
252
|
+
it 'raises a RateLimitExceededError exception with the response information' do
|
253
|
+
expect { api_client.send(:raise_error, response) }.to raise_error(TripletexRubyClient::ClientError) do |error|
|
254
|
+
expect(error.code).to eq(400)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'when the response code is 401' do
|
260
|
+
let(:code) { 401 }
|
261
|
+
it 'raises an UnauthorizedError exception with the response information' do
|
262
|
+
expect { api_client.send(:raise_error, response) }.to raise_error(TripletexRubyClient::UnauthorizedError) do |error|
|
263
|
+
puts error
|
264
|
+
expect(error.code).to eq(401)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
context 'when the response code is 429' do
|
270
|
+
let(:code) { 429 }
|
271
|
+
it 'raises a RateLimitExceededError exception with the response information' do
|
272
|
+
expect { api_client.send(:raise_error, response) }.to raise_error(TripletexRubyClient::RateLimitExceededError) do |error|
|
273
|
+
expect(error.code).to eq(429)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
context 'when the response code is 500' do
|
279
|
+
let(:code) { 500 }
|
280
|
+
it 'raises a ServerError exception with the response information' do
|
281
|
+
expect { api_client.send(:raise_error, response) }.to raise_error(TripletexRubyClient::ServerError) do |error|
|
282
|
+
expect(error.code).to eq(500)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
context 'when the response code is not handled' do
|
288
|
+
let(:code) { 600 }
|
289
|
+
it 'raises an ApiError exception with the response information' do
|
290
|
+
expect { api_client.send(:raise_error, response) }.to raise_error(TripletexRubyClient::ApiError) do |error|
|
291
|
+
expect(error.code).to eq(600)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
243
296
|
end
|