phrase 2.7.2 → 2.8.0

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,248 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class WebhookDelivery
5
+ attr_accessor :id
6
+
7
+ attr_accessor :webhook_id
8
+
9
+ attr_accessor :response_status_code
10
+
11
+ attr_accessor :delivered_at
12
+
13
+ attr_accessor :duration_ms
14
+
15
+ attr_accessor :created_at
16
+
17
+ attr_accessor :updated_at
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'id' => :'id',
23
+ :'webhook_id' => :'webhook_id',
24
+ :'response_status_code' => :'response_status_code',
25
+ :'delivered_at' => :'delivered_at',
26
+ :'duration_ms' => :'duration_ms',
27
+ :'created_at' => :'created_at',
28
+ :'updated_at' => :'updated_at'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'id' => :'String',
36
+ :'webhook_id' => :'String',
37
+ :'response_status_code' => :'Integer',
38
+ :'delivered_at' => :'DateTime',
39
+ :'duration_ms' => :'Integer',
40
+ :'created_at' => :'DateTime',
41
+ :'updated_at' => :'DateTime'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::WebhookDelivery` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::WebhookDelivery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'id')
67
+ self.id = attributes[:'id']
68
+ end
69
+
70
+ if attributes.key?(:'webhook_id')
71
+ self.webhook_id = attributes[:'webhook_id']
72
+ end
73
+
74
+ if attributes.key?(:'response_status_code')
75
+ self.response_status_code = attributes[:'response_status_code']
76
+ end
77
+
78
+ if attributes.key?(:'delivered_at')
79
+ self.delivered_at = attributes[:'delivered_at']
80
+ end
81
+
82
+ if attributes.key?(:'duration_ms')
83
+ self.duration_ms = attributes[:'duration_ms']
84
+ end
85
+
86
+ if attributes.key?(:'created_at')
87
+ self.created_at = attributes[:'created_at']
88
+ end
89
+
90
+ if attributes.key?(:'updated_at')
91
+ self.updated_at = attributes[:'updated_at']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ invalid_properties = Array.new
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ id == o.id &&
114
+ webhook_id == o.webhook_id &&
115
+ response_status_code == o.response_status_code &&
116
+ delivered_at == o.delivered_at &&
117
+ duration_ms == o.duration_ms &&
118
+ created_at == o.created_at &&
119
+ updated_at == o.updated_at
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [id, webhook_id, response_status_code, delivered_at, duration_ms, created_at, updated_at].hash
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 self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.openapi_types.each_pair do |key, type|
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :DateTime
168
+ DateTime.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ Phrase.const_get(type).build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+ end
248
+ end
@@ -1,3 +1,3 @@
1
1
  module Phrase
2
- VERSION = '2.7.2'
2
+ VERSION = '2.8.0'
3
3
  end
data/lib/phrase.rb CHANGED
@@ -199,6 +199,7 @@ require 'phrase/models/variable_create_parameters'
199
199
  require 'phrase/models/variable_update_parameters'
200
200
  require 'phrase/models/webhook'
201
201
  require 'phrase/models/webhook_create_parameters'
202
+ require 'phrase/models/webhook_delivery'
202
203
  require 'phrase/models/webhook_update_parameters'
203
204
 
204
205
  # APIs
@@ -243,6 +244,7 @@ require 'phrase/api/uploads_api'
243
244
  require 'phrase/api/users_api'
244
245
  require 'phrase/api/variables_api'
245
246
  require 'phrase/api/versions_history_api'
247
+ require 'phrase/api/webhook_deliveries_api'
246
248
  require 'phrase/api/webhooks_api'
247
249
 
248
250
  module Phrase
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ # Unit tests for Phrase::WebhookDeliveriesApi
5
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
6
+ # Please update as you see appropriate
7
+ describe 'WebhookDeliveriesApi' do
8
+ before do
9
+ # run before each test
10
+ @api_instance = Phrase::WebhookDeliveriesApi.new
11
+ end
12
+
13
+ after do
14
+ # run after each test
15
+ end
16
+
17
+ describe 'test an instance of WebhookDeliveriesApi' do
18
+ it 'should create an instance of WebhookDeliveriesApi' do
19
+ expect(@api_instance).to be_instance_of(Phrase::WebhookDeliveriesApi)
20
+ end
21
+ end
22
+
23
+ # unit tests for webhook_deliveries_list
24
+ # List webhook deliveries
25
+ # List all webhook deliveries for the given webhook_id.
26
+ # @param project_id Project ID
27
+ # @param webhook_id Webhook ID
28
+ # @param [Hash] opts the optional parameters
29
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
30
+ # @option opts [String] :response_status_codes List of Response Status Codes
31
+ # @return [Array<WebhookDelivery>]
32
+ describe 'webhook_deliveries_list test' do
33
+ it 'should work' do
34
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
35
+ end
36
+ end
37
+
38
+ # unit tests for webhook_deliveries_redeliver
39
+ # Redeliver a single webhook delivery
40
+ # Trigger an individual webhook delivery to be redelivered.
41
+ # @param project_id Project ID
42
+ # @param webhook_id Webhook ID
43
+ # @param id ID
44
+ # @param [Hash] opts the optional parameters
45
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
46
+ # @return [WebhookDelivery]
47
+ describe 'webhook_deliveries_redeliver test' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ # unit tests for webhook_deliveries_show
54
+ # Get a single webhook delivery
55
+ # Get all information about a single webhook delivery for the given ID.
56
+ # @param project_id Project ID
57
+ # @param webhook_id Webhook ID
58
+ # @param id ID
59
+ # @param [Hash] opts the optional parameters
60
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
61
+ # @return [WebhookDelivery]
62
+ describe 'webhook_deliveries_show test' do
63
+ it 'should work' do
64
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ # Unit tests for Phrase::WebhookDelivery
6
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
7
+ # Please update as you see appropriate
8
+ describe 'WebhookDelivery' do
9
+ before do
10
+ # run before each test
11
+ @instance = Phrase::WebhookDelivery.new
12
+ end
13
+
14
+ after do
15
+ # run after each test
16
+ end
17
+
18
+ describe 'test an instance of WebhookDelivery' do
19
+ it 'should create an instance of WebhookDelivery' do
20
+ expect(@instance).to be_instance_of(Phrase::WebhookDelivery)
21
+ end
22
+ end
23
+ describe 'test attribute "id"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ describe 'test attribute "webhook_id"' do
30
+ it 'should work' do
31
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
32
+ end
33
+ end
34
+
35
+ describe 'test attribute "response_status_code"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "delivered_at"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "duration_ms"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ describe 'test attribute "created_at"' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ end
57
+ end
58
+
59
+ describe 'test attribute "updated_at"' do
60
+ it 'should work' do
61
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
62
+ end
63
+ end
64
+
65
+ end