dyspatch_client 2.0.0 → 5.0.1
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 +3 -1
- data/README.md +50 -34
- data/Rakefile +2 -0
- data/docs/APIError.md +12 -1
- data/docs/CompiledRead.md +13 -0
- data/docs/Cursor.md +11 -1
- data/docs/DraftMetaRead.md +27 -0
- data/docs/DraftRead.md +31 -0
- data/docs/DraftsApi.md +476 -0
- data/docs/DraftsRead.md +19 -0
- data/docs/InlineObject.md +17 -0
- data/docs/LocalizationKeyRead.md +19 -0
- data/docs/LocalizationMetaRead.md +15 -1
- data/docs/LocalizationRead.md +19 -1
- data/docs/LocalizationsApi.md +16 -18
- data/docs/TemplateMetaRead.md +15 -0
- data/docs/TemplateRead.md +16 -0
- data/docs/TemplatesApi.md +39 -40
- data/docs/TemplatesRead.md +10 -0
- data/dyspatch_client.gemspec +10 -16
- data/lib/dyspatch_client.rb +10 -4
- data/lib/dyspatch_client/api/drafts_api.rb +620 -0
- data/lib/dyspatch_client/api/localizations_api.rb +52 -34
- data/lib/dyspatch_client/api/templates_api.rb +100 -69
- data/lib/dyspatch_client/api_client.rb +54 -55
- data/lib/dyspatch_client/api_error.rb +23 -4
- data/lib/dyspatch_client/configuration.rb +49 -10
- data/lib/dyspatch_client/models/api_error.rb +50 -30
- data/lib/dyspatch_client/models/compiled_read.rb +49 -78
- data/lib/dyspatch_client/models/cursor.rb +47 -28
- data/lib/dyspatch_client/models/draft_meta_read.rb +258 -0
- data/lib/dyspatch_client/models/draft_read.rb +279 -0
- data/lib/dyspatch_client/models/drafts_read.rb +219 -0
- data/lib/dyspatch_client/models/inline_object.rb +206 -0
- data/lib/dyspatch_client/models/localization_key_read.rb +216 -0
- data/lib/dyspatch_client/models/localization_meta_read.rb +70 -39
- data/lib/dyspatch_client/models/localization_read.rb +73 -42
- data/lib/dyspatch_client/models/template_meta_read.rb +52 -33
- data/lib/dyspatch_client/models/template_read.rb +53 -34
- data/lib/dyspatch_client/models/templates_read.rb +45 -26
- data/lib/dyspatch_client/version.rb +5 -5
- data/pkg/dyspatch_client-5.0.0.gem +0 -0
- data/pkg/dyspatch_client-5.0.1.gem +0 -0
- data/spec/api/drafts_api_spec.rb +146 -0
- data/spec/api/localizations_api_spec.rb +12 -12
- data/spec/api/templates_api_spec.rb +24 -24
- data/spec/api_client_spec.rb +39 -39
- data/spec/configuration_spec.rb +12 -12
- data/spec/integration_spec.rb +41 -0
- data/spec/models/api_error_spec.rb +12 -13
- data/spec/models/compiled_read_spec.rb +10 -11
- data/spec/models/cursor_spec.rb +7 -8
- data/spec/models/draft_meta_read_spec.rb +77 -0
- data/spec/models/draft_read_spec.rb +83 -0
- data/spec/models/drafts_read_spec.rb +47 -0
- data/spec/models/inline_object_spec.rb +41 -0
- data/spec/models/localization_key_read_spec.rb +47 -0
- data/spec/models/localization_meta_read_spec.rb +18 -13
- data/spec/models/localization_read_spec.rb +20 -15
- data/spec/models/template_meta_read_spec.rb +12 -13
- data/spec/models/template_read_spec.rb +13 -14
- data/spec/models/templates_read_spec.rb +7 -8
- data/spec/spec_helper.rb +4 -4
- metadata +34 -128
- data/git_push.sh +0 -55
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
2
|
#Dyspatch API
|
3
3
|
|
4
|
-
## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries
|
4
|
+
## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 2020.04
|
7
7
|
Contact: support@dyspatch.io
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -21,7 +21,6 @@ module DyspatchClient
|
|
21
21
|
# Whether there is a next page of results
|
22
22
|
attr_accessor :has_more
|
23
23
|
|
24
|
-
|
25
24
|
# Attribute mapping from ruby-style variable name to JSON key.
|
26
25
|
def self.attribute_map
|
27
26
|
{
|
@@ -31,42 +30,54 @@ module DyspatchClient
|
|
31
30
|
end
|
32
31
|
|
33
32
|
# Attribute type mapping.
|
34
|
-
def self.
|
33
|
+
def self.openapi_types
|
35
34
|
{
|
36
35
|
:'_next' => :'String',
|
37
|
-
:'has_more' => :'
|
36
|
+
:'has_more' => :'Boolean'
|
38
37
|
}
|
39
38
|
end
|
40
39
|
|
40
|
+
# List of attributes with nullable: true
|
41
|
+
def self.openapi_nullable
|
42
|
+
Set.new([
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
41
46
|
# Initializes the object
|
42
47
|
# @param [Hash] attributes Model attributes in the form of hash
|
43
48
|
def initialize(attributes = {})
|
44
|
-
|
49
|
+
if (!attributes.is_a?(Hash))
|
50
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DyspatchClient::Cursor` initialize method"
|
51
|
+
end
|
45
52
|
|
46
|
-
# convert string to symbol for hash key
|
47
|
-
attributes = attributes.each_with_object({}){|(k,v), h|
|
53
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
55
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
56
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DyspatchClient::Cursor`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
57
|
+
end
|
58
|
+
h[k.to_sym] = v
|
59
|
+
}
|
48
60
|
|
49
|
-
if attributes.
|
50
|
-
self._next = attributes[:'
|
61
|
+
if attributes.key?(:'_next')
|
62
|
+
self._next = attributes[:'_next']
|
51
63
|
end
|
52
64
|
|
53
|
-
if attributes.
|
54
|
-
self.has_more = attributes[:'
|
65
|
+
if attributes.key?(:'has_more')
|
66
|
+
self.has_more = attributes[:'has_more']
|
55
67
|
end
|
56
|
-
|
57
68
|
end
|
58
69
|
|
59
70
|
# Show invalid properties with the reasons. Usually used together with valid?
|
60
71
|
# @return Array for valid properties with the reasons
|
61
72
|
def list_invalid_properties
|
62
73
|
invalid_properties = Array.new
|
63
|
-
|
74
|
+
invalid_properties
|
64
75
|
end
|
65
76
|
|
66
77
|
# Check to see if the all the properties in the model are valid
|
67
78
|
# @return true if the model is valid
|
68
79
|
def valid?
|
69
|
-
|
80
|
+
true
|
70
81
|
end
|
71
82
|
|
72
83
|
# Checks equality by comparing each attribute.
|
@@ -85,22 +96,29 @@ module DyspatchClient
|
|
85
96
|
end
|
86
97
|
|
87
98
|
# Calculates hash code according to all attributes.
|
88
|
-
# @return [
|
99
|
+
# @return [Integer] Hash code
|
89
100
|
def hash
|
90
101
|
[_next, has_more].hash
|
91
102
|
end
|
92
103
|
|
104
|
+
# Builds the object from hash
|
105
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
106
|
+
# @return [Object] Returns the model itself
|
107
|
+
def self.build_from_hash(attributes)
|
108
|
+
new.build_from_hash(attributes)
|
109
|
+
end
|
110
|
+
|
93
111
|
# Builds the object from hash
|
94
112
|
# @param [Hash] attributes Model attributes in the form of hash
|
95
113
|
# @return [Object] Returns the model itself
|
96
114
|
def build_from_hash(attributes)
|
97
115
|
return nil unless attributes.is_a?(Hash)
|
98
|
-
self.class.
|
116
|
+
self.class.openapi_types.each_pair do |key, type|
|
99
117
|
if type =~ /\AArray<(.*)>/i
|
100
|
-
# check to ensure the input is an array given that the
|
118
|
+
# check to ensure the input is an array given that the attribute
|
101
119
|
# is documented as an array but the input is not
|
102
120
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
103
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
121
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
104
122
|
end
|
105
123
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
106
124
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -126,7 +144,7 @@ module DyspatchClient
|
|
126
144
|
value.to_i
|
127
145
|
when :Float
|
128
146
|
value.to_f
|
129
|
-
when :
|
147
|
+
when :Boolean
|
130
148
|
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
131
149
|
true
|
132
150
|
else
|
@@ -147,8 +165,7 @@ module DyspatchClient
|
|
147
165
|
end
|
148
166
|
end
|
149
167
|
else # model
|
150
|
-
|
151
|
-
temp_model.build_from_hash(value)
|
168
|
+
DyspatchClient.const_get(type).build_from_hash(value)
|
152
169
|
end
|
153
170
|
end
|
154
171
|
|
@@ -170,7 +187,11 @@ module DyspatchClient
|
|
170
187
|
hash = {}
|
171
188
|
self.class.attribute_map.each_pair do |attr, param|
|
172
189
|
value = self.send(attr)
|
173
|
-
|
190
|
+
if value.nil?
|
191
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
192
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
193
|
+
end
|
194
|
+
|
174
195
|
hash[param] = _to_hash(value)
|
175
196
|
end
|
176
197
|
hash
|
@@ -182,7 +203,7 @@ module DyspatchClient
|
|
182
203
|
# @return [Hash] Returns the value in the form of hash
|
183
204
|
def _to_hash(value)
|
184
205
|
if value.is_a?(Array)
|
185
|
-
value.compact.map{ |v| _to_hash(v) }
|
206
|
+
value.compact.map { |v| _to_hash(v) }
|
186
207
|
elsif value.is_a?(Hash)
|
187
208
|
{}.tap do |hash|
|
188
209
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -193,7 +214,5 @@ module DyspatchClient
|
|
193
214
|
value
|
194
215
|
end
|
195
216
|
end
|
196
|
-
|
197
217
|
end
|
198
|
-
|
199
218
|
end
|
@@ -0,0 +1,258 @@
|
|
1
|
+
=begin
|
2
|
+
#Dyspatch API
|
3
|
+
|
4
|
+
## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2020.04
|
7
|
+
Contact: support@dyspatch.io
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DyspatchClient
|
16
|
+
# draft metadata
|
17
|
+
class DraftMetaRead
|
18
|
+
# An opaque, unique identifier for a draft
|
19
|
+
attr_accessor :id
|
20
|
+
|
21
|
+
# An opaque, unique identifier for a template
|
22
|
+
attr_accessor :template_id
|
23
|
+
|
24
|
+
# The name of a draft
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
# The API url for a specific draft
|
28
|
+
attr_accessor :url
|
29
|
+
|
30
|
+
# The time of initial creation
|
31
|
+
attr_accessor :created_at
|
32
|
+
|
33
|
+
# The time of last update
|
34
|
+
attr_accessor :updated_at
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'id' => :'id',
|
40
|
+
:'template_id' => :'templateId',
|
41
|
+
:'name' => :'name',
|
42
|
+
:'url' => :'url',
|
43
|
+
:'created_at' => :'createdAt',
|
44
|
+
:'updated_at' => :'updatedAt'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute type mapping.
|
49
|
+
def self.openapi_types
|
50
|
+
{
|
51
|
+
:'id' => :'String',
|
52
|
+
:'template_id' => :'String',
|
53
|
+
:'name' => :'String',
|
54
|
+
:'url' => :'String',
|
55
|
+
:'created_at' => :'DateTime',
|
56
|
+
:'updated_at' => :'DateTime'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
# List of attributes with nullable: true
|
61
|
+
def self.openapi_nullable
|
62
|
+
Set.new([
|
63
|
+
])
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes the object
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
+
def initialize(attributes = {})
|
69
|
+
if (!attributes.is_a?(Hash))
|
70
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DyspatchClient::DraftMetaRead` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DyspatchClient::DraftMetaRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
77
|
+
end
|
78
|
+
h[k.to_sym] = v
|
79
|
+
}
|
80
|
+
|
81
|
+
if attributes.key?(:'id')
|
82
|
+
self.id = attributes[:'id']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'template_id')
|
86
|
+
self.template_id = attributes[:'template_id']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'name')
|
90
|
+
self.name = attributes[:'name']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'url')
|
94
|
+
self.url = attributes[:'url']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'created_at')
|
98
|
+
self.created_at = attributes[:'created_at']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'updated_at')
|
102
|
+
self.updated_at = attributes[:'updated_at']
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
107
|
+
# @return Array for valid properties with the reasons
|
108
|
+
def list_invalid_properties
|
109
|
+
invalid_properties = Array.new
|
110
|
+
invalid_properties
|
111
|
+
end
|
112
|
+
|
113
|
+
# Check to see if the all the properties in the model are valid
|
114
|
+
# @return true if the model is valid
|
115
|
+
def valid?
|
116
|
+
true
|
117
|
+
end
|
118
|
+
|
119
|
+
# Checks equality by comparing each attribute.
|
120
|
+
# @param [Object] Object to be compared
|
121
|
+
def ==(o)
|
122
|
+
return true if self.equal?(o)
|
123
|
+
self.class == o.class &&
|
124
|
+
id == o.id &&
|
125
|
+
template_id == o.template_id &&
|
126
|
+
name == o.name &&
|
127
|
+
url == o.url &&
|
128
|
+
created_at == o.created_at &&
|
129
|
+
updated_at == o.updated_at
|
130
|
+
end
|
131
|
+
|
132
|
+
# @see the `==` method
|
133
|
+
# @param [Object] Object to be compared
|
134
|
+
def eql?(o)
|
135
|
+
self == o
|
136
|
+
end
|
137
|
+
|
138
|
+
# Calculates hash code according to all attributes.
|
139
|
+
# @return [Integer] Hash code
|
140
|
+
def hash
|
141
|
+
[id, template_id, name, url, created_at, updated_at].hash
|
142
|
+
end
|
143
|
+
|
144
|
+
# Builds the object from hash
|
145
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
146
|
+
# @return [Object] Returns the model itself
|
147
|
+
def self.build_from_hash(attributes)
|
148
|
+
new.build_from_hash(attributes)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Builds the object from hash
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
153
|
+
# @return [Object] Returns the model itself
|
154
|
+
def build_from_hash(attributes)
|
155
|
+
return nil unless attributes.is_a?(Hash)
|
156
|
+
self.class.openapi_types.each_pair do |key, type|
|
157
|
+
if type =~ /\AArray<(.*)>/i
|
158
|
+
# check to ensure the input is an array given that the attribute
|
159
|
+
# is documented as an array but the input is not
|
160
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
161
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
162
|
+
end
|
163
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
164
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
165
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
166
|
+
end
|
167
|
+
|
168
|
+
self
|
169
|
+
end
|
170
|
+
|
171
|
+
# Deserializes the data based on type
|
172
|
+
# @param string type Data type
|
173
|
+
# @param string value Value to be deserialized
|
174
|
+
# @return [Object] Deserialized data
|
175
|
+
def _deserialize(type, value)
|
176
|
+
case type.to_sym
|
177
|
+
when :DateTime
|
178
|
+
DateTime.parse(value)
|
179
|
+
when :Date
|
180
|
+
Date.parse(value)
|
181
|
+
when :String
|
182
|
+
value.to_s
|
183
|
+
when :Integer
|
184
|
+
value.to_i
|
185
|
+
when :Float
|
186
|
+
value.to_f
|
187
|
+
when :Boolean
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
189
|
+
true
|
190
|
+
else
|
191
|
+
false
|
192
|
+
end
|
193
|
+
when :Object
|
194
|
+
# generic object (usually a Hash), return directly
|
195
|
+
value
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each do |k, v|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else # model
|
208
|
+
DyspatchClient.const_get(type).build_from_hash(value)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the string representation of the object
|
213
|
+
# @return [String] String presentation of the object
|
214
|
+
def to_s
|
215
|
+
to_hash.to_s
|
216
|
+
end
|
217
|
+
|
218
|
+
# to_body is an alias to to_hash (backward compatibility)
|
219
|
+
# @return [Hash] Returns the object in the form of hash
|
220
|
+
def to_body
|
221
|
+
to_hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Returns the object in the form of hash
|
225
|
+
# @return [Hash] Returns the object in the form of hash
|
226
|
+
def to_hash
|
227
|
+
hash = {}
|
228
|
+
self.class.attribute_map.each_pair do |attr, param|
|
229
|
+
value = self.send(attr)
|
230
|
+
if value.nil?
|
231
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
232
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
233
|
+
end
|
234
|
+
|
235
|
+
hash[param] = _to_hash(value)
|
236
|
+
end
|
237
|
+
hash
|
238
|
+
end
|
239
|
+
|
240
|
+
# Outputs non-array value in the form of hash
|
241
|
+
# For object, use to_hash. Otherwise, just return the value
|
242
|
+
# @param [Object] value Any valid value
|
243
|
+
# @return [Hash] Returns the value in the form of hash
|
244
|
+
def _to_hash(value)
|
245
|
+
if value.is_a?(Array)
|
246
|
+
value.compact.map { |v| _to_hash(v) }
|
247
|
+
elsif value.is_a?(Hash)
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
250
|
+
end
|
251
|
+
elsif value.respond_to? :to_hash
|
252
|
+
value.to_hash
|
253
|
+
else
|
254
|
+
value
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
@@ -0,0 +1,279 @@
|
|
1
|
+
=begin
|
2
|
+
#Dyspatch API
|
3
|
+
|
4
|
+
## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2020.04
|
7
|
+
Contact: support@dyspatch.io
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DyspatchClient
|
16
|
+
# template draft metadata included latest draft revision
|
17
|
+
class DraftRead
|
18
|
+
# An opaque, unique identifier for a draft
|
19
|
+
attr_accessor :id
|
20
|
+
|
21
|
+
# An opaque, unique identifier for a template
|
22
|
+
attr_accessor :template
|
23
|
+
|
24
|
+
# The name of a draft
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
# The API url for a specific draft
|
28
|
+
attr_accessor :url
|
29
|
+
|
30
|
+
attr_accessor :compiled
|
31
|
+
|
32
|
+
# The time of initial creation
|
33
|
+
attr_accessor :created_at
|
34
|
+
|
35
|
+
# The time of last update
|
36
|
+
attr_accessor :updated_at
|
37
|
+
|
38
|
+
# A list of the Template's available localizations
|
39
|
+
attr_accessor :localizations
|
40
|
+
|
41
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
42
|
+
def self.attribute_map
|
43
|
+
{
|
44
|
+
:'id' => :'id',
|
45
|
+
:'template' => :'template',
|
46
|
+
:'name' => :'name',
|
47
|
+
:'url' => :'url',
|
48
|
+
:'compiled' => :'compiled',
|
49
|
+
:'created_at' => :'createdAt',
|
50
|
+
:'updated_at' => :'updatedAt',
|
51
|
+
:'localizations' => :'localizations'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute type mapping.
|
56
|
+
def self.openapi_types
|
57
|
+
{
|
58
|
+
:'id' => :'String',
|
59
|
+
:'template' => :'String',
|
60
|
+
:'name' => :'String',
|
61
|
+
:'url' => :'String',
|
62
|
+
:'compiled' => :'CompiledRead',
|
63
|
+
:'created_at' => :'DateTime',
|
64
|
+
:'updated_at' => :'DateTime',
|
65
|
+
:'localizations' => :'Array<LocalizationMetaRead>'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
# List of attributes with nullable: true
|
70
|
+
def self.openapi_nullable
|
71
|
+
Set.new([
|
72
|
+
])
|
73
|
+
end
|
74
|
+
|
75
|
+
# Initializes the object
|
76
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
77
|
+
def initialize(attributes = {})
|
78
|
+
if (!attributes.is_a?(Hash))
|
79
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DyspatchClient::DraftRead` initialize method"
|
80
|
+
end
|
81
|
+
|
82
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
83
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
84
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
85
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DyspatchClient::DraftRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
86
|
+
end
|
87
|
+
h[k.to_sym] = v
|
88
|
+
}
|
89
|
+
|
90
|
+
if attributes.key?(:'id')
|
91
|
+
self.id = attributes[:'id']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'template')
|
95
|
+
self.template = attributes[:'template']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'name')
|
99
|
+
self.name = attributes[:'name']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'url')
|
103
|
+
self.url = attributes[:'url']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'compiled')
|
107
|
+
self.compiled = attributes[:'compiled']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'created_at')
|
111
|
+
self.created_at = attributes[:'created_at']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.key?(:'updated_at')
|
115
|
+
self.updated_at = attributes[:'updated_at']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'localizations')
|
119
|
+
if (value = attributes[:'localizations']).is_a?(Array)
|
120
|
+
self.localizations = value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
126
|
+
# @return Array for valid properties with the reasons
|
127
|
+
def list_invalid_properties
|
128
|
+
invalid_properties = Array.new
|
129
|
+
invalid_properties
|
130
|
+
end
|
131
|
+
|
132
|
+
# Check to see if the all the properties in the model are valid
|
133
|
+
# @return true if the model is valid
|
134
|
+
def valid?
|
135
|
+
true
|
136
|
+
end
|
137
|
+
|
138
|
+
# Checks equality by comparing each attribute.
|
139
|
+
# @param [Object] Object to be compared
|
140
|
+
def ==(o)
|
141
|
+
return true if self.equal?(o)
|
142
|
+
self.class == o.class &&
|
143
|
+
id == o.id &&
|
144
|
+
template == o.template &&
|
145
|
+
name == o.name &&
|
146
|
+
url == o.url &&
|
147
|
+
compiled == o.compiled &&
|
148
|
+
created_at == o.created_at &&
|
149
|
+
updated_at == o.updated_at &&
|
150
|
+
localizations == o.localizations
|
151
|
+
end
|
152
|
+
|
153
|
+
# @see the `==` method
|
154
|
+
# @param [Object] Object to be compared
|
155
|
+
def eql?(o)
|
156
|
+
self == o
|
157
|
+
end
|
158
|
+
|
159
|
+
# Calculates hash code according to all attributes.
|
160
|
+
# @return [Integer] Hash code
|
161
|
+
def hash
|
162
|
+
[id, template, name, url, compiled, created_at, updated_at, localizations].hash
|
163
|
+
end
|
164
|
+
|
165
|
+
# Builds the object from hash
|
166
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
167
|
+
# @return [Object] Returns the model itself
|
168
|
+
def self.build_from_hash(attributes)
|
169
|
+
new.build_from_hash(attributes)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Builds the object from hash
|
173
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
174
|
+
# @return [Object] Returns the model itself
|
175
|
+
def build_from_hash(attributes)
|
176
|
+
return nil unless attributes.is_a?(Hash)
|
177
|
+
self.class.openapi_types.each_pair do |key, type|
|
178
|
+
if type =~ /\AArray<(.*)>/i
|
179
|
+
# check to ensure the input is an array given that the attribute
|
180
|
+
# is documented as an array but the input is not
|
181
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
182
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
183
|
+
end
|
184
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
185
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
186
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
187
|
+
end
|
188
|
+
|
189
|
+
self
|
190
|
+
end
|
191
|
+
|
192
|
+
# Deserializes the data based on type
|
193
|
+
# @param string type Data type
|
194
|
+
# @param string value Value to be deserialized
|
195
|
+
# @return [Object] Deserialized data
|
196
|
+
def _deserialize(type, value)
|
197
|
+
case type.to_sym
|
198
|
+
when :DateTime
|
199
|
+
DateTime.parse(value)
|
200
|
+
when :Date
|
201
|
+
Date.parse(value)
|
202
|
+
when :String
|
203
|
+
value.to_s
|
204
|
+
when :Integer
|
205
|
+
value.to_i
|
206
|
+
when :Float
|
207
|
+
value.to_f
|
208
|
+
when :Boolean
|
209
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
210
|
+
true
|
211
|
+
else
|
212
|
+
false
|
213
|
+
end
|
214
|
+
when :Object
|
215
|
+
# generic object (usually a Hash), return directly
|
216
|
+
value
|
217
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
218
|
+
inner_type = Regexp.last_match[:inner_type]
|
219
|
+
value.map { |v| _deserialize(inner_type, v) }
|
220
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
221
|
+
k_type = Regexp.last_match[:k_type]
|
222
|
+
v_type = Regexp.last_match[:v_type]
|
223
|
+
{}.tap do |hash|
|
224
|
+
value.each do |k, v|
|
225
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
else # model
|
229
|
+
DyspatchClient.const_get(type).build_from_hash(value)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# Returns the string representation of the object
|
234
|
+
# @return [String] String presentation of the object
|
235
|
+
def to_s
|
236
|
+
to_hash.to_s
|
237
|
+
end
|
238
|
+
|
239
|
+
# to_body is an alias to to_hash (backward compatibility)
|
240
|
+
# @return [Hash] Returns the object in the form of hash
|
241
|
+
def to_body
|
242
|
+
to_hash
|
243
|
+
end
|
244
|
+
|
245
|
+
# Returns the object in the form of hash
|
246
|
+
# @return [Hash] Returns the object in the form of hash
|
247
|
+
def to_hash
|
248
|
+
hash = {}
|
249
|
+
self.class.attribute_map.each_pair do |attr, param|
|
250
|
+
value = self.send(attr)
|
251
|
+
if value.nil?
|
252
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
253
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
254
|
+
end
|
255
|
+
|
256
|
+
hash[param] = _to_hash(value)
|
257
|
+
end
|
258
|
+
hash
|
259
|
+
end
|
260
|
+
|
261
|
+
# Outputs non-array value in the form of hash
|
262
|
+
# For object, use to_hash. Otherwise, just return the value
|
263
|
+
# @param [Object] value Any valid value
|
264
|
+
# @return [Hash] Returns the value in the form of hash
|
265
|
+
def _to_hash(value)
|
266
|
+
if value.is_a?(Array)
|
267
|
+
value.compact.map { |v| _to_hash(v) }
|
268
|
+
elsif value.is_a?(Hash)
|
269
|
+
{}.tap do |hash|
|
270
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
271
|
+
end
|
272
|
+
elsif value.respond_to? :to_hash
|
273
|
+
value.to_hash
|
274
|
+
else
|
275
|
+
value
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|