zyphr 0.1.39 → 0.1.41

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -14
  3. data/docs/AddWorkflowStep201Response.md +20 -0
  4. data/docs/AddWorkflowStepRequest.md +30 -0
  5. data/docs/AuthRegistrationApi.md +1 -1
  6. data/docs/CreateWorkflow201Response.md +20 -0
  7. data/docs/CreateWorkflowRequest.md +26 -0
  8. data/docs/DeleteWorkflow200Response.md +20 -0
  9. data/docs/{TopicDeleteResponseData.md → DeleteWorkflow200ResponseData.md} +2 -2
  10. data/docs/DeleteWorkflowStep200Response.md +20 -0
  11. data/docs/DeleteWorkflowStep200ResponseData.md +22 -0
  12. data/docs/ListWorkflowExecutions200Response.md +20 -0
  13. data/docs/{SmsListResponseMeta.md → ListWorkflowExecutions200ResponseMeta.md} +2 -2
  14. data/docs/ListWorkflows200Response.md +20 -0
  15. data/docs/ListWorkflows200ResponseMeta.md +32 -0
  16. data/docs/ReorderWorkflowStepsRequest.md +18 -0
  17. data/docs/SignInWithGameCenterRequest.md +1 -1
  18. data/docs/SmsListResponse.md +1 -1
  19. data/docs/TopicDeleteResponse.md +1 -1
  20. data/docs/TriggerWorkflow202Response.md +20 -0
  21. data/docs/TriggerWorkflow202ResponseData.md +22 -0
  22. data/docs/TriggerWorkflowRequest.md +24 -0
  23. data/docs/UpdateWorkflowRequest.md +24 -0
  24. data/docs/UpdateWorkflowStatusRequest.md +18 -0
  25. data/docs/UpdateWorkflowStepRequest.md +20 -0
  26. data/docs/Workflow.md +42 -0
  27. data/docs/WorkflowStatus.md +15 -0
  28. data/docs/WorkflowStep.md +38 -0
  29. data/docs/WorkflowStepType.md +15 -0
  30. data/docs/WorkflowsApi.md +901 -0
  31. data/lib/zyphr/api/auth_registration_api.rb +2 -2
  32. data/lib/zyphr/api/workflows_api.rb +897 -0
  33. data/lib/zyphr/models/add_workflow_step201_response.rb +229 -0
  34. data/lib/zyphr/models/add_workflow_step_request.rb +384 -0
  35. data/lib/zyphr/models/create_workflow201_response.rb +229 -0
  36. data/lib/zyphr/models/create_workflow_request.rb +292 -0
  37. data/lib/zyphr/models/delete_workflow200_response.rb +229 -0
  38. data/lib/zyphr/models/{topic_delete_response_data.rb → delete_workflow200_response_data.rb} +3 -3
  39. data/lib/zyphr/models/delete_workflow_step200_response.rb +229 -0
  40. data/lib/zyphr/models/delete_workflow_step200_response_data.rb +238 -0
  41. data/lib/zyphr/models/list_workflow_executions200_response.rb +231 -0
  42. data/lib/zyphr/models/{sms_list_response_meta.rb → list_workflow_executions200_response_meta.rb} +3 -3
  43. data/lib/zyphr/models/list_workflows200_response.rb +231 -0
  44. data/lib/zyphr/models/list_workflows200_response_meta.rb +284 -0
  45. data/lib/zyphr/models/reorder_workflow_steps_request.rb +249 -0
  46. data/lib/zyphr/models/sign_in_with_game_center_request.rb +1 -1
  47. data/lib/zyphr/models/sms_list_response.rb +1 -1
  48. data/lib/zyphr/models/topic_delete_response.rb +1 -1
  49. data/lib/zyphr/models/trigger_workflow202_response.rb +229 -0
  50. data/lib/zyphr/models/trigger_workflow202_response_data.rb +240 -0
  51. data/lib/zyphr/models/trigger_workflow_request.rb +272 -0
  52. data/lib/zyphr/models/update_workflow_request.rb +269 -0
  53. data/lib/zyphr/models/{v1_muse_subjects_suggest_post_request.rb → update_workflow_status_request.rb} +19 -86
  54. data/lib/zyphr/models/update_workflow_step_request.rb +232 -0
  55. data/lib/zyphr/models/workflow.rb +514 -0
  56. data/lib/zyphr/models/workflow_status.rb +42 -0
  57. data/lib/zyphr/models/workflow_step.rb +505 -0
  58. data/lib/zyphr/models/workflow_step_type.rb +47 -0
  59. data/lib/zyphr.rb +24 -4
  60. data/spec/api/auth_registration_api_spec.rb +1 -1
  61. data/spec/api/workflows_api_spec.rb +192 -0
  62. data/spec/models/add_workflow_step201_response_spec.rb +42 -0
  63. data/spec/models/add_workflow_step_request_spec.rb +76 -0
  64. data/spec/models/create_workflow201_response_spec.rb +42 -0
  65. data/spec/models/{v1_muse_subjects_suggest_post_request_spec.rb → create_workflow_request_spec.rb} +16 -14
  66. data/spec/models/{topic_delete_response_data_spec.rb → delete_workflow200_response_data_spec.rb} +6 -6
  67. data/spec/models/delete_workflow200_response_spec.rb +42 -0
  68. data/spec/models/delete_workflow_step200_response_data_spec.rb +48 -0
  69. data/spec/models/delete_workflow_step200_response_spec.rb +42 -0
  70. data/spec/models/{sms_list_response_meta_spec.rb → list_workflow_executions200_response_meta_spec.rb} +6 -6
  71. data/spec/models/list_workflow_executions200_response_spec.rb +42 -0
  72. data/spec/models/list_workflows200_response_meta_spec.rb +78 -0
  73. data/spec/models/list_workflows200_response_spec.rb +42 -0
  74. data/spec/models/reorder_workflow_steps_request_spec.rb +36 -0
  75. data/spec/models/trigger_workflow202_response_data_spec.rb +48 -0
  76. data/spec/models/trigger_workflow202_response_spec.rb +42 -0
  77. data/spec/models/trigger_workflow_request_spec.rb +54 -0
  78. data/spec/models/update_workflow_request_spec.rb +54 -0
  79. data/spec/models/update_workflow_status_request_spec.rb +36 -0
  80. data/spec/models/update_workflow_step_request_spec.rb +42 -0
  81. data/spec/models/workflow_spec.rb +108 -0
  82. data/spec/models/workflow_status_spec.rb +30 -0
  83. data/spec/models/workflow_step_spec.rb +100 -0
  84. data/spec/models/workflow_step_type_spec.rb +30 -0
  85. data/zyphr.gemspec +1 -1
  86. metadata +97 -17
  87. data/docs/MuseApi.md +0 -681
  88. data/docs/V1MuseSubjectsSuggestPostRequest.md +0 -24
  89. data/lib/zyphr/api/muse_api.rb +0 -644
  90. data/spec/api/muse_api_spec.rb +0 -156
@@ -0,0 +1,229 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class AddWorkflowStep201Response
18
+ attr_accessor :data
19
+
20
+ attr_accessor :meta
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'data' => :'data',
26
+ :'meta' => :'meta'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'data' => :'WorkflowStep',
44
+ :'meta' => :'RequestMeta'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AddWorkflowStep201Response` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AddWorkflowStep201Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'data')
71
+ self.data = attributes[:'data']
72
+ end
73
+
74
+ if attributes.key?(:'meta')
75
+ self.meta = attributes[:'meta']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ warn '[DEPRECATED] the `valid?` method is obsolete'
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ data == o.data &&
100
+ meta == o.meta
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [data, meta].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ transformed_hash = {}
122
+ openapi_types.each_pair do |key, type|
123
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = nil
125
+ elsif type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[attribute_map[key]].is_a?(Array)
129
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
130
+ end
131
+ elsif !attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
133
+ end
134
+ end
135
+ new(transformed_hash)
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def self._deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Zyphr.const_get(type)
177
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end
@@ -0,0 +1,384 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class AddWorkflowStepRequest
18
+ # Unique step identifier within the workflow.
19
+ attr_accessor :step_key
20
+
21
+ # Human-readable step name.
22
+ attr_accessor :name
23
+
24
+ attr_accessor :type
25
+
26
+ # Optional ordering position; appended to the end when omitted.
27
+ attr_accessor :position
28
+
29
+ # Step configuration whose shape depends on `type`.
30
+ attr_accessor :config
31
+
32
+ # Parent step id (used for branch children).
33
+ attr_accessor :parent_step_id
34
+
35
+ # Which branch path this step belongs to (branch children only).
36
+ attr_accessor :branch_path
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'step_key' => :'step_key',
64
+ :'name' => :'name',
65
+ :'type' => :'type',
66
+ :'position' => :'position',
67
+ :'config' => :'config',
68
+ :'parent_step_id' => :'parent_step_id',
69
+ :'branch_path' => :'branch_path'
70
+ }
71
+ end
72
+
73
+ # Returns attribute mapping this model knows about
74
+ def self.acceptable_attribute_map
75
+ attribute_map
76
+ end
77
+
78
+ # Returns all the JSON keys this model knows about
79
+ def self.acceptable_attributes
80
+ acceptable_attribute_map.values
81
+ end
82
+
83
+ # Attribute type mapping.
84
+ def self.openapi_types
85
+ {
86
+ :'step_key' => :'String',
87
+ :'name' => :'String',
88
+ :'type' => :'WorkflowStepType',
89
+ :'position' => :'Integer',
90
+ :'config' => :'Hash<String, Object>',
91
+ :'parent_step_id' => :'String',
92
+ :'branch_path' => :'String'
93
+ }
94
+ end
95
+
96
+ # List of attributes with nullable: true
97
+ def self.openapi_nullable
98
+ Set.new([
99
+ ])
100
+ end
101
+
102
+ # Initializes the object
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ def initialize(attributes = {})
105
+ if (!attributes.is_a?(Hash))
106
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AddWorkflowStepRequest` initialize method"
107
+ end
108
+
109
+ # check to see if the attribute exists and convert string to symbol for hash key
110
+ acceptable_attribute_map = self.class.acceptable_attribute_map
111
+ attributes = attributes.each_with_object({}) { |(k, v), h|
112
+ if (!acceptable_attribute_map.key?(k.to_sym))
113
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AddWorkflowStepRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
114
+ end
115
+ h[k.to_sym] = v
116
+ }
117
+
118
+ if attributes.key?(:'step_key')
119
+ self.step_key = attributes[:'step_key']
120
+ else
121
+ self.step_key = nil
122
+ end
123
+
124
+ if attributes.key?(:'name')
125
+ self.name = attributes[:'name']
126
+ else
127
+ self.name = nil
128
+ end
129
+
130
+ if attributes.key?(:'type')
131
+ self.type = attributes[:'type']
132
+ else
133
+ self.type = nil
134
+ end
135
+
136
+ if attributes.key?(:'position')
137
+ self.position = attributes[:'position']
138
+ end
139
+
140
+ if attributes.key?(:'config')
141
+ if (value = attributes[:'config']).is_a?(Hash)
142
+ self.config = value
143
+ end
144
+ else
145
+ self.config = nil
146
+ end
147
+
148
+ if attributes.key?(:'parent_step_id')
149
+ self.parent_step_id = attributes[:'parent_step_id']
150
+ end
151
+
152
+ if attributes.key?(:'branch_path')
153
+ self.branch_path = attributes[:'branch_path']
154
+ end
155
+ end
156
+
157
+ # Show invalid properties with the reasons. Usually used together with valid?
158
+ # @return Array for valid properties with the reasons
159
+ def list_invalid_properties
160
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
161
+ invalid_properties = Array.new
162
+ if @step_key.nil?
163
+ invalid_properties.push('invalid value for "step_key", step_key cannot be nil.')
164
+ end
165
+
166
+ if @name.nil?
167
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
168
+ end
169
+
170
+ if @type.nil?
171
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
172
+ end
173
+
174
+ if @config.nil?
175
+ invalid_properties.push('invalid value for "config", config cannot be nil.')
176
+ end
177
+
178
+ invalid_properties
179
+ end
180
+
181
+ # Check to see if the all the properties in the model are valid
182
+ # @return true if the model is valid
183
+ def valid?
184
+ warn '[DEPRECATED] the `valid?` method is obsolete'
185
+ return false if @step_key.nil?
186
+ return false if @name.nil?
187
+ return false if @type.nil?
188
+ return false if @config.nil?
189
+ branch_path_validator = EnumAttributeValidator.new('String', ["true", "false"])
190
+ return false unless branch_path_validator.valid?(@branch_path)
191
+ true
192
+ end
193
+
194
+ # Custom attribute writer method with validation
195
+ # @param [Object] step_key Value to be assigned
196
+ def step_key=(step_key)
197
+ if step_key.nil?
198
+ fail ArgumentError, 'step_key cannot be nil'
199
+ end
200
+
201
+ @step_key = step_key
202
+ end
203
+
204
+ # Custom attribute writer method with validation
205
+ # @param [Object] name Value to be assigned
206
+ def name=(name)
207
+ if name.nil?
208
+ fail ArgumentError, 'name cannot be nil'
209
+ end
210
+
211
+ @name = name
212
+ end
213
+
214
+ # Custom attribute writer method with validation
215
+ # @param [Object] type Value to be assigned
216
+ def type=(type)
217
+ if type.nil?
218
+ fail ArgumentError, 'type cannot be nil'
219
+ end
220
+
221
+ @type = type
222
+ end
223
+
224
+ # Custom attribute writer method with validation
225
+ # @param [Object] config Value to be assigned
226
+ def config=(config)
227
+ if config.nil?
228
+ fail ArgumentError, 'config cannot be nil'
229
+ end
230
+
231
+ @config = config
232
+ end
233
+
234
+ # Custom attribute writer method checking allowed values (enum).
235
+ # @param [Object] branch_path Object to be assigned
236
+ def branch_path=(branch_path)
237
+ validator = EnumAttributeValidator.new('String', ["true", "false"])
238
+ unless validator.valid?(branch_path)
239
+ fail ArgumentError, "invalid value for \"branch_path\", must be one of #{validator.allowable_values}."
240
+ end
241
+ @branch_path = branch_path
242
+ end
243
+
244
+ # Checks equality by comparing each attribute.
245
+ # @param [Object] Object to be compared
246
+ def ==(o)
247
+ return true if self.equal?(o)
248
+ self.class == o.class &&
249
+ step_key == o.step_key &&
250
+ name == o.name &&
251
+ type == o.type &&
252
+ position == o.position &&
253
+ config == o.config &&
254
+ parent_step_id == o.parent_step_id &&
255
+ branch_path == o.branch_path
256
+ end
257
+
258
+ # @see the `==` method
259
+ # @param [Object] Object to be compared
260
+ def eql?(o)
261
+ self == o
262
+ end
263
+
264
+ # Calculates hash code according to all attributes.
265
+ # @return [Integer] Hash code
266
+ def hash
267
+ [step_key, name, type, position, config, parent_step_id, branch_path].hash
268
+ end
269
+
270
+ # Builds the object from hash
271
+ # @param [Hash] attributes Model attributes in the form of hash
272
+ # @return [Object] Returns the model itself
273
+ def self.build_from_hash(attributes)
274
+ return nil unless attributes.is_a?(Hash)
275
+ attributes = attributes.transform_keys(&:to_sym)
276
+ transformed_hash = {}
277
+ openapi_types.each_pair do |key, type|
278
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
279
+ transformed_hash["#{key}"] = nil
280
+ elsif type =~ /\AArray<(.*)>/i
281
+ # check to ensure the input is an array given that the attribute
282
+ # is documented as an array but the input is not
283
+ if attributes[attribute_map[key]].is_a?(Array)
284
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
285
+ end
286
+ elsif !attributes[attribute_map[key]].nil?
287
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
288
+ end
289
+ end
290
+ new(transformed_hash)
291
+ end
292
+
293
+ # Deserializes the data based on type
294
+ # @param string type Data type
295
+ # @param string value Value to be deserialized
296
+ # @return [Object] Deserialized data
297
+ def self._deserialize(type, value)
298
+ case type.to_sym
299
+ when :Time
300
+ Time.parse(value)
301
+ when :Date
302
+ Date.parse(value)
303
+ when :String
304
+ value.to_s
305
+ when :Integer
306
+ value.to_i
307
+ when :Float
308
+ value.to_f
309
+ when :Boolean
310
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
311
+ true
312
+ else
313
+ false
314
+ end
315
+ when :Object
316
+ # generic object (usually a Hash), return directly
317
+ value
318
+ when /\AArray<(?<inner_type>.+)>\z/
319
+ inner_type = Regexp.last_match[:inner_type]
320
+ value.map { |v| _deserialize(inner_type, v) }
321
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
322
+ k_type = Regexp.last_match[:k_type]
323
+ v_type = Regexp.last_match[:v_type]
324
+ {}.tap do |hash|
325
+ value.each do |k, v|
326
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
327
+ end
328
+ end
329
+ else # model
330
+ # models (e.g. Pet) or oneOf
331
+ klass = Zyphr.const_get(type)
332
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
333
+ end
334
+ end
335
+
336
+ # Returns the string representation of the object
337
+ # @return [String] String presentation of the object
338
+ def to_s
339
+ to_hash.to_s
340
+ end
341
+
342
+ # to_body is an alias to to_hash (backward compatibility)
343
+ # @return [Hash] Returns the object in the form of hash
344
+ def to_body
345
+ to_hash
346
+ end
347
+
348
+ # Returns the object in the form of hash
349
+ # @return [Hash] Returns the object in the form of hash
350
+ def to_hash
351
+ hash = {}
352
+ self.class.attribute_map.each_pair do |attr, param|
353
+ value = self.send(attr)
354
+ if value.nil?
355
+ is_nullable = self.class.openapi_nullable.include?(attr)
356
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
357
+ end
358
+
359
+ hash[param] = _to_hash(value)
360
+ end
361
+ hash
362
+ end
363
+
364
+ # Outputs non-array value in the form of hash
365
+ # For object, use to_hash. Otherwise, just return the value
366
+ # @param [Object] value Any valid value
367
+ # @return [Hash] Returns the value in the form of hash
368
+ def _to_hash(value)
369
+ if value.is_a?(Array)
370
+ value.compact.map { |v| _to_hash(v) }
371
+ elsif value.is_a?(Hash)
372
+ {}.tap do |hash|
373
+ value.each { |k, v| hash[k] = _to_hash(v) }
374
+ end
375
+ elsif value.respond_to? :to_hash
376
+ value.to_hash
377
+ else
378
+ value
379
+ end
380
+ end
381
+
382
+ end
383
+
384
+ end