sendx-ruby-sdk 1.1.0 → 2.0.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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +220 -81
  3. data/lib/sendx-ruby-sdk/api/campaign_api.rb +95 -143
  4. data/lib/sendx-ruby-sdk/api/contact_api.rb +129 -96
  5. data/lib/sendx-ruby-sdk/api/custom_field_api.rb +391 -0
  6. data/lib/sendx-ruby-sdk/api/email_sending_api.rb +158 -0
  7. data/lib/sendx-ruby-sdk/api/event_api.rb +91 -57
  8. data/lib/sendx-ruby-sdk/api/events_api.rb +158 -0
  9. data/lib/sendx-ruby-sdk/api/getting_started_api.rb +2 -2
  10. data/lib/sendx-ruby-sdk/api/list_api.rb +126 -91
  11. data/lib/sendx-ruby-sdk/api/post_api.rb +380 -0
  12. data/lib/sendx-ruby-sdk/api/post_category_api.rb +362 -0
  13. data/lib/sendx-ruby-sdk/api/post_tag_api.rb +362 -0
  14. data/lib/sendx-ruby-sdk/api/report_api.rb +90 -0
  15. data/lib/sendx-ruby-sdk/api/reports_api.rb +4 -4
  16. data/lib/sendx-ruby-sdk/api/sender_api.rb +28 -37
  17. data/lib/sendx-ruby-sdk/api/tag_api.rb +380 -0
  18. data/lib/sendx-ruby-sdk/api/tags_api.rb +8 -8
  19. data/lib/sendx-ruby-sdk/api/team_member_api.rb +147 -0
  20. data/lib/sendx-ruby-sdk/api/template_api.rb +391 -0
  21. data/lib/sendx-ruby-sdk/api/tracking_api.rb +158 -0
  22. data/lib/sendx-ruby-sdk/api/webhook_api.rb +362 -0
  23. data/lib/sendx-ruby-sdk/api_client.rb +10 -11
  24. data/lib/sendx-ruby-sdk/api_error.rb +3 -3
  25. data/lib/sendx-ruby-sdk/configuration.rb +6 -10
  26. data/lib/sendx-ruby-sdk/models/campaign.rb +23 -7
  27. data/lib/sendx-ruby-sdk/models/campaign_dashboard_data.rb +11 -5
  28. data/lib/sendx-ruby-sdk/models/campaign_request.rb +13 -41
  29. data/lib/sendx-ruby-sdk/models/contact.rb +11 -5
  30. data/lib/sendx-ruby-sdk/models/contact_request.rb +11 -5
  31. data/lib/sendx-ruby-sdk/models/create_response.rb +11 -5
  32. data/lib/sendx-ruby-sdk/models/custom_event_request.rb +37 -42
  33. data/lib/sendx-ruby-sdk/models/custom_field.rb +285 -0
  34. data/lib/sendx-ruby-sdk/models/customfield_customfield_id_delete200_response.rb +220 -0
  35. data/lib/sendx-ruby-sdk/models/dashboard_stats.rb +11 -5
  36. data/lib/sendx-ruby-sdk/models/delete_campaign200_response.rb +11 -5
  37. data/lib/sendx-ruby-sdk/models/delete_request.rb +11 -5
  38. data/lib/sendx-ruby-sdk/models/delete_response.rb +77 -13
  39. data/lib/sendx-ruby-sdk/models/e_custom_field.rb +295 -0
  40. data/lib/sendx-ruby-sdk/models/error_response.rb +288 -0
  41. data/lib/sendx-ruby-sdk/models/event_response.rb +13 -19
  42. data/lib/sendx-ruby-sdk/models/events_revenue_postback_get200_response.rb +229 -0
  43. data/lib/sendx-ruby-sdk/models/events_revenue_postback_get400_response.rb +220 -0
  44. data/lib/sendx-ruby-sdk/models/events_revenue_postback_get500_response.rb +220 -0
  45. data/lib/sendx-ruby-sdk/models/identify_error_response.rb +220 -0
  46. data/lib/sendx-ruby-sdk/models/identify_request.rb +52 -40
  47. data/lib/sendx-ruby-sdk/models/identify_response.rb +16 -19
  48. data/lib/sendx-ruby-sdk/models/last_sent_campaign_stat.rb +11 -5
  49. data/lib/sendx-ruby-sdk/models/link_stat.rb +232 -0
  50. data/lib/sendx-ruby-sdk/models/list_model.rb +11 -6
  51. data/lib/sendx-ruby-sdk/models/list_request.rb +11 -5
  52. data/lib/sendx-ruby-sdk/models/message_response.rb +229 -0
  53. data/lib/sendx-ruby-sdk/models/operation_response.rb +241 -0
  54. data/lib/sendx-ruby-sdk/models/postback_response.rb +229 -0
  55. data/lib/sendx-ruby-sdk/models/report_data.rb +11 -5
  56. data/lib/sendx-ruby-sdk/models/response.rb +11 -5
  57. data/lib/sendx-ruby-sdk/models/rest_e_campaign.rb +539 -0
  58. data/lib/sendx-ruby-sdk/models/rest_e_contact.rb +380 -0
  59. data/lib/sendx-ruby-sdk/models/rest_e_custom_field.rb +299 -0
  60. data/lib/sendx-ruby-sdk/models/rest_e_list.rb +238 -0
  61. data/lib/sendx-ruby-sdk/models/rest_e_post.rb +443 -0
  62. data/lib/sendx-ruby-sdk/models/rest_e_post_category.rb +238 -0
  63. data/lib/sendx-ruby-sdk/models/rest_e_post_tag.rb +238 -0
  64. data/lib/sendx-ruby-sdk/models/rest_e_sender.rb +265 -0
  65. data/lib/sendx-ruby-sdk/models/rest_e_tag.rb +238 -0
  66. data/lib/sendx-ruby-sdk/models/rest_e_template.rb +307 -0
  67. data/lib/sendx-ruby-sdk/models/rest_e_webhook.rb +349 -0
  68. data/lib/sendx-ruby-sdk/models/rest_r_campaign.rb +580 -0
  69. data/lib/sendx-ruby-sdk/models/rest_r_contact.rb +438 -0
  70. data/lib/sendx-ruby-sdk/models/rest_r_custom_field.rb +306 -0
  71. data/lib/sendx-ruby-sdk/models/rest_r_list.rb +291 -0
  72. data/lib/sendx-ruby-sdk/models/rest_r_member.rb +274 -0
  73. data/lib/sendx-ruby-sdk/models/rest_r_post.rb +384 -0
  74. data/lib/sendx-ruby-sdk/models/rest_r_post_category.rb +251 -0
  75. data/lib/sendx-ruby-sdk/models/rest_r_post_tag.rb +250 -0
  76. data/lib/sendx-ruby-sdk/models/rest_r_sender.rb +272 -0
  77. data/lib/sendx-ruby-sdk/models/rest_r_tag.rb +272 -0
  78. data/lib/sendx-ruby-sdk/models/rest_r_template.rb +366 -0
  79. data/lib/sendx-ruby-sdk/models/rest_r_webhook.rb +326 -0
  80. data/lib/sendx-ruby-sdk/models/rest_report_data.rb +312 -0
  81. data/lib/sendx-ruby-sdk/models/revenue_event_request.rb +37 -42
  82. data/lib/sendx-ruby-sdk/models/sender.rb +41 -5
  83. data/lib/sendx-ruby-sdk/models/sender_request.rb +31 -5
  84. data/lib/sendx-ruby-sdk/models/sender_response.rb +51 -5
  85. data/lib/sendx-ruby-sdk/models/tag.rb +11 -5
  86. data/lib/sendx-ruby-sdk/models/tag_request.rb +11 -5
  87. data/lib/sendx-ruby-sdk/models/template_email_message.rb +337 -0
  88. data/lib/sendx-ruby-sdk/models/track_request.rb +28 -20
  89. data/lib/sendx-ruby-sdk/models/track_response.rb +12 -6
  90. data/lib/sendx-ruby-sdk/models/webhook.rb +311 -0
  91. data/lib/sendx-ruby-sdk/models/webhook_object.rb +451 -0
  92. data/lib/sendx-ruby-sdk/models/webhook_request.rb +291 -0
  93. data/lib/sendx-ruby-sdk/models/x_attachment.rb +263 -0
  94. data/lib/sendx-ruby-sdk/models/x_email_message.rb +356 -0
  95. data/lib/sendx-ruby-sdk/models/x_email_response.rb +261 -0
  96. data/lib/sendx-ruby-sdk/models/x_from.rb +246 -0
  97. data/lib/sendx-ruby-sdk/models/x_reply_to.rb +246 -0
  98. data/lib/sendx-ruby-sdk/models/xto.rb +279 -0
  99. data/lib/sendx-ruby-sdk/version.rb +4 -4
  100. data/lib/sendx-ruby-sdk.rb +53 -25
  101. data/spec/api/custom_field_api_spec.rb +98 -0
  102. data/spec/api/email_sending_api_spec.rb +59 -0
  103. data/spec/api/events_api_spec.rb +59 -0
  104. data/spec/api/post_api_spec.rb +97 -0
  105. data/spec/api/post_category_api_spec.rb +95 -0
  106. data/spec/api/post_tag_api_spec.rb +95 -0
  107. data/spec/api/report_api_spec.rb +47 -0
  108. data/spec/api/tag_api_spec.rb +97 -0
  109. data/spec/api/team_member_api_spec.rb +58 -0
  110. data/spec/api/template_api_spec.rb +98 -0
  111. data/spec/api/tracking_api_spec.rb +59 -0
  112. data/spec/api/webhook_api_spec.rb +95 -0
  113. data/spec/models/custom_field_spec.rb +58 -0
  114. data/spec/models/customfield_customfield_id_delete200_response_spec.rb +36 -0
  115. data/spec/models/e_custom_field_spec.rb +64 -0
  116. data/spec/models/error_response_spec.rb +46 -0
  117. data/spec/models/events_revenue_postback_get200_response_spec.rb +42 -0
  118. data/spec/models/events_revenue_postback_get400_response_spec.rb +36 -0
  119. data/spec/models/events_revenue_postback_get500_response_spec.rb +36 -0
  120. data/spec/models/identify_error_response_spec.rb +36 -0
  121. data/spec/models/link_stat_spec.rb +42 -0
  122. data/spec/models/message_response_spec.rb +42 -0
  123. data/spec/models/operation_response_spec.rb +48 -0
  124. data/spec/models/postback_response_spec.rb +42 -0
  125. data/spec/models/rest_e_campaign_spec.rb +154 -0
  126. data/spec/models/rest_e_contact_spec.rb +78 -0
  127. data/spec/models/rest_e_custom_field_spec.rb +52 -0
  128. data/spec/models/rest_e_list_spec.rb +36 -0
  129. data/spec/models/rest_e_post_category_spec.rb +36 -0
  130. data/spec/models/rest_e_post_spec.rb +144 -0
  131. data/spec/models/rest_e_post_tag_spec.rb +36 -0
  132. data/spec/models/rest_e_sender_spec.rb +42 -0
  133. data/spec/models/rest_e_tag_spec.rb +36 -0
  134. data/spec/models/rest_e_template_spec.rb +66 -0
  135. data/spec/models/rest_e_webhook_spec.rb +84 -0
  136. data/spec/models/rest_r_campaign_spec.rb +178 -0
  137. data/spec/models/rest_r_contact_spec.rb +150 -0
  138. data/spec/models/rest_r_custom_field_spec.rb +58 -0
  139. data/spec/models/rest_r_list_spec.rb +64 -0
  140. data/spec/models/rest_r_member_spec.rb +72 -0
  141. data/spec/models/rest_r_post_category_spec.rb +54 -0
  142. data/spec/models/rest_r_post_spec.rb +144 -0
  143. data/spec/models/rest_r_post_tag_spec.rb +54 -0
  144. data/spec/models/rest_r_sender_spec.rb +54 -0
  145. data/spec/models/rest_r_tag_spec.rb +54 -0
  146. data/spec/models/rest_r_template_spec.rb +94 -0
  147. data/spec/models/rest_r_webhook_spec.rb +90 -0
  148. data/spec/models/rest_report_data_spec.rb +90 -0
  149. data/spec/models/template_email_message_spec.rb +72 -0
  150. data/spec/models/webhook_object_spec.rb +180 -0
  151. data/spec/models/webhook_request_spec.rb +78 -0
  152. data/spec/models/webhook_spec.rb +90 -0
  153. data/spec/models/x_attachment_spec.rb +42 -0
  154. data/spec/models/x_email_message_spec.rb +90 -0
  155. data/spec/models/x_email_response_spec.rb +60 -0
  156. data/spec/models/x_from_spec.rb +42 -0
  157. data/spec/models/x_reply_to_spec.rb +42 -0
  158. data/spec/models/xto_spec.rb +60 -0
  159. data/spec/spec_helper.rb +3 -3
  160. metadata +202 -28
@@ -0,0 +1,580 @@
1
+ =begin
2
+ #SendX REST API
3
+
4
+ ## SendX REST API Documentation ## 🚀 Introduction The SendX API is organized around REST principles. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. **Key Features:** - 🔒 **Security**: Team-based authentication with optional member-level access - 🎯 **Resource-Oriented**: RESTful design with clear resource boundaries - 📊 **Rich Data Models**: Three-layer model system (Input/Output/Internal) - 🔗 **Relationships**: Automatic prefix handling for resource relationships - 📈 **Scalable**: Built for high-volume email marketing operations ## 🏗️ Architecture Overview SendX uses a three-layer model architecture: 1. **Input Models** (`RestE*`): For API requests 2. **Output Models** (`RestR*`): For API responses with prefixed IDs 3. **Internal Models**: Core business logic (not exposed in API) ## 🔐 Security & Authentication SendX uses API key authentication: ### Team API Key ```http X-Team-ApiKey: YOUR_TEAM_API_KEY ``` - **Required for all requests** - Team-level access to resources - Available in SendX Settings → Team API Key ## 🆔 Encrypted ID System SendX uses encrypted IDs for security and better developer experience: - **Internal IDs**: Sequential integers (not exposed) - **Encrypted IDs**: 22-character alphanumeric strings - **Prefixed IDs**: Resource-type prefixes in API responses (`contact_<22-char-id>`) ### ID Format **All resource IDs follow this pattern:** ``` <resource_prefix>_<22_character_alphanumeric_string> ``` **Example:** ```json { \"id\": \"contact_BnKjkbBBS500CoBCP0oChQ\", \"lists\": [\"list_OcuxJHdiAvujmwQVJfd3ss\", \"list_0tOFLp5RgV7s3LNiHrjGYs\"], \"tags\": [\"tag_UhsDkjL772Qbj5lWtT62VK\", \"tag_fL7t9lsnZ9swvx2HrtQ9wM\"] } ``` ## 📚 Resource Prefixes | Resource | Prefix | Example | |----------|--------|---------| | Contact | `contact_` | `contact_BnKjkbBBS500CoBCP0oChQ` | | Campaign | `campaign_` | `campaign_LUE9BTxmksSmqHWbh96zsn` | | List | `list_` | `list_OcuxJHdiAvujmwQVJfd3ss` | | Tag | `tag_` | `tag_UhsDkjL772Qbj5lWtT62VK` | | Sender | `sender_` | `sender_4vK3WFhMgvOwUNyaL4QxCD` | | Template | `template_` | `template_f3lJvTEhSjKGVb5Lwc5SWS` | | Custom Field | `field_` | `field_MnuqBAG2NPLm7PZMWbjQxt` | | Webhook | `webhook_` | `webhook_9l154iiXlZoPo7vngmamee` | | Post | `post_` | `post_XyZ123aBc456DeF789GhI` | | Post Category | `post_category_` | `post_category_YzS1wOU20yw87UUHKxMzwn` | | Post Tag | `post_tag_` | `post_tag_123XyZ456AbC` | | Member | `member_` | `member_JkL012MnO345PqR678` | ## 🎯 Best Practices ### Error Handling - **Always check status codes**: 2xx = success, 4xx = client error, 5xx = server error - **Read error messages**: Descriptive messages help debug issues - **Handle rate limits**: Respect API rate limits for optimal performance ### Data Validation - **Email format**: Must be valid email addresses - **Required fields**: Check documentation for mandatory fields - **Field lengths**: Respect maximum length constraints ### Performance - **Pagination**: Use offset/limit for large datasets - **Batch operations**: Process multiple items when supported - **Caching**: Cache responses when appropriate ## 🛠️ SDKs & Integration Official SDKs available for: - [Golang](https://github.com/sendx/sendx-go-sdk) - [Python](https://github.com/sendx/sendx-python-sdk) - [Ruby](https://github.com/sendx/sendx-ruby-sdk) - [Java](https://github.com/sendx/sendx-java-sdk) - [PHP](https://github.com/sendx/sendx-php-sdk) - [JavaScript](https://github.com/sendx/sendx-javascript-sdk) ## 📞 Support Need help? Contact us: - 💬 **Website Chat**: Available on sendx.io - 📧 **Email**: hello@sendx.io - 📚 **Documentation**: Full guides at help.sendx.io --- **API Endpoint:** `https://api.sendx.io/api/v1/rest` [<img src=\"https://run.pstmn.io/button.svg\" alt=\"Run In Postman\" style=\"width: 128px; height: 32px;\">](https://god.gw.postman.com/run-collection/33476323-44b198b0-5219-4619-a01f-cfc24d573885?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D33476323-44b198b0-5219-4619-a01f-cfc24d573885%26entityType%3Dcollection%26workspaceId%3D6b1e4f65-96a9-4136-9512-6266c852517e)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: hello@sendx.io
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SendX
17
+ class RestRCampaign
18
+ # Encrypted ID of the campaign
19
+ attr_accessor :id
20
+
21
+ # Internal campaign name
22
+ attr_accessor :name
23
+
24
+ # Email subject line
25
+ attr_accessor :subject
26
+
27
+ # Email preview text
28
+ attr_accessor :preheader
29
+
30
+ # Sender id
31
+ attr_accessor :sender
32
+
33
+ # HTML email content
34
+ attr_accessor :html_content
35
+
36
+ # Plain text email content
37
+ attr_accessor :text_content
38
+
39
+ # Campaign scheduling type. **Values:** - `0` - Schedule later - `1` - Send Now
40
+ attr_accessor :schedule_type
41
+
42
+ # datetime for scheduled campaigns (required if scheduleType=1)
43
+ attr_accessor :schedule_condition
44
+
45
+ # Time-related condition for the campaign
46
+ attr_accessor :time_condition
47
+
48
+ # Campaign timezone
49
+ attr_accessor :timezone
50
+
51
+ # Timezone for the scheduled send
52
+ attr_accessor :smart_send
53
+
54
+ # Send at specified time in each contact's timezone
55
+ attr_accessor :send_in_contacts_timezone
56
+
57
+ # Preferred time condition, in case of smartSend and sendInContactTimeZone
58
+ attr_accessor :preferred_time_condition
59
+
60
+ # Preferred timezone for smart send optimization
61
+ attr_accessor :preferred_timezone
62
+
63
+ # Campaign delivery strategy
64
+ attr_accessor :strategy
65
+
66
+ # Included segment IDs
67
+ attr_accessor :included_segments
68
+
69
+ # Included list IDs with prefix
70
+ attr_accessor :included_lists
71
+
72
+ # Included tag IDs with prefix
73
+ attr_accessor :included_tags
74
+
75
+ # Excluded segment IDs
76
+ attr_accessor :excluded_segments
77
+
78
+ # Excluded list IDs with prefix
79
+ attr_accessor :excluded_lists
80
+
81
+ # Excluded tag IDs with prefix
82
+ attr_accessor :excluded_tags
83
+
84
+ attr_accessor :created
85
+
86
+ attr_accessor :updated
87
+
88
+ # Attribute mapping from ruby-style variable name to JSON key.
89
+ def self.attribute_map
90
+ {
91
+ :'id' => :'id',
92
+ :'name' => :'name',
93
+ :'subject' => :'subject',
94
+ :'preheader' => :'preheader',
95
+ :'sender' => :'sender',
96
+ :'html_content' => :'htmlContent',
97
+ :'text_content' => :'textContent',
98
+ :'schedule_type' => :'scheduleType',
99
+ :'schedule_condition' => :'scheduleCondition',
100
+ :'time_condition' => :'timeCondition',
101
+ :'timezone' => :'timezone',
102
+ :'smart_send' => :'smartSend',
103
+ :'send_in_contacts_timezone' => :'sendInContactsTimezone',
104
+ :'preferred_time_condition' => :'preferredTimeCondition',
105
+ :'preferred_timezone' => :'preferredTimezone',
106
+ :'strategy' => :'strategy',
107
+ :'included_segments' => :'includedSegments',
108
+ :'included_lists' => :'includedLists',
109
+ :'included_tags' => :'includedTags',
110
+ :'excluded_segments' => :'excludedSegments',
111
+ :'excluded_lists' => :'excludedLists',
112
+ :'excluded_tags' => :'excludedTags',
113
+ :'created' => :'created',
114
+ :'updated' => :'updated'
115
+ }
116
+ end
117
+
118
+ # Returns attribute mapping this model knows about
119
+ def self.acceptable_attribute_map
120
+ attribute_map
121
+ end
122
+
123
+ # Returns all the JSON keys this model knows about
124
+ def self.acceptable_attributes
125
+ acceptable_attribute_map.values
126
+ end
127
+
128
+ # Attribute type mapping.
129
+ def self.openapi_types
130
+ {
131
+ :'id' => :'String',
132
+ :'name' => :'String',
133
+ :'subject' => :'String',
134
+ :'preheader' => :'String',
135
+ :'sender' => :'String',
136
+ :'html_content' => :'String',
137
+ :'text_content' => :'String',
138
+ :'schedule_type' => :'Integer',
139
+ :'schedule_condition' => :'String',
140
+ :'time_condition' => :'String',
141
+ :'timezone' => :'String',
142
+ :'smart_send' => :'Boolean',
143
+ :'send_in_contacts_timezone' => :'Boolean',
144
+ :'preferred_time_condition' => :'String',
145
+ :'preferred_timezone' => :'String',
146
+ :'strategy' => :'String',
147
+ :'included_segments' => :'Array<String>',
148
+ :'included_lists' => :'Array<String>',
149
+ :'included_tags' => :'Array<String>',
150
+ :'excluded_segments' => :'Array<String>',
151
+ :'excluded_lists' => :'Array<String>',
152
+ :'excluded_tags' => :'Array<String>',
153
+ :'created' => :'Time',
154
+ :'updated' => :'Time'
155
+ }
156
+ end
157
+
158
+ # List of attributes with nullable: true
159
+ def self.openapi_nullable
160
+ Set.new([
161
+ ])
162
+ end
163
+
164
+ # Initializes the object
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ def initialize(attributes = {})
167
+ if (!attributes.is_a?(Hash))
168
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::RestRCampaign` initialize method"
169
+ end
170
+
171
+ # check to see if the attribute exists and convert string to symbol for hash key
172
+ acceptable_attribute_map = self.class.acceptable_attribute_map
173
+ attributes = attributes.each_with_object({}) { |(k, v), h|
174
+ if (!acceptable_attribute_map.key?(k.to_sym))
175
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::RestRCampaign`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
176
+ end
177
+ h[k.to_sym] = v
178
+ }
179
+
180
+ if attributes.key?(:'id')
181
+ self.id = attributes[:'id']
182
+ end
183
+
184
+ if attributes.key?(:'name')
185
+ self.name = attributes[:'name']
186
+ else
187
+ self.name = nil
188
+ end
189
+
190
+ if attributes.key?(:'subject')
191
+ self.subject = attributes[:'subject']
192
+ else
193
+ self.subject = nil
194
+ end
195
+
196
+ if attributes.key?(:'preheader')
197
+ self.preheader = attributes[:'preheader']
198
+ end
199
+
200
+ if attributes.key?(:'sender')
201
+ self.sender = attributes[:'sender']
202
+ else
203
+ self.sender = nil
204
+ end
205
+
206
+ if attributes.key?(:'html_content')
207
+ self.html_content = attributes[:'html_content']
208
+ end
209
+
210
+ if attributes.key?(:'text_content')
211
+ self.text_content = attributes[:'text_content']
212
+ end
213
+
214
+ if attributes.key?(:'schedule_type')
215
+ self.schedule_type = attributes[:'schedule_type']
216
+ else
217
+ self.schedule_type = 0
218
+ end
219
+
220
+ if attributes.key?(:'schedule_condition')
221
+ self.schedule_condition = attributes[:'schedule_condition']
222
+ else
223
+ self.schedule_condition = nil
224
+ end
225
+
226
+ if attributes.key?(:'time_condition')
227
+ self.time_condition = attributes[:'time_condition']
228
+ end
229
+
230
+ if attributes.key?(:'timezone')
231
+ self.timezone = attributes[:'timezone']
232
+ end
233
+
234
+ if attributes.key?(:'smart_send')
235
+ self.smart_send = attributes[:'smart_send']
236
+ end
237
+
238
+ if attributes.key?(:'send_in_contacts_timezone')
239
+ self.send_in_contacts_timezone = attributes[:'send_in_contacts_timezone']
240
+ end
241
+
242
+ if attributes.key?(:'preferred_time_condition')
243
+ self.preferred_time_condition = attributes[:'preferred_time_condition']
244
+ end
245
+
246
+ if attributes.key?(:'preferred_timezone')
247
+ self.preferred_timezone = attributes[:'preferred_timezone']
248
+ end
249
+
250
+ if attributes.key?(:'strategy')
251
+ self.strategy = attributes[:'strategy']
252
+ end
253
+
254
+ if attributes.key?(:'included_segments')
255
+ if (value = attributes[:'included_segments']).is_a?(Array)
256
+ self.included_segments = value
257
+ end
258
+ end
259
+
260
+ if attributes.key?(:'included_lists')
261
+ if (value = attributes[:'included_lists']).is_a?(Array)
262
+ self.included_lists = value
263
+ end
264
+ else
265
+ self.included_lists = nil
266
+ end
267
+
268
+ if attributes.key?(:'included_tags')
269
+ if (value = attributes[:'included_tags']).is_a?(Array)
270
+ self.included_tags = value
271
+ end
272
+ end
273
+
274
+ if attributes.key?(:'excluded_segments')
275
+ if (value = attributes[:'excluded_segments']).is_a?(Array)
276
+ self.excluded_segments = value
277
+ end
278
+ end
279
+
280
+ if attributes.key?(:'excluded_lists')
281
+ if (value = attributes[:'excluded_lists']).is_a?(Array)
282
+ self.excluded_lists = value
283
+ end
284
+ else
285
+ self.excluded_lists = nil
286
+ end
287
+
288
+ if attributes.key?(:'excluded_tags')
289
+ if (value = attributes[:'excluded_tags']).is_a?(Array)
290
+ self.excluded_tags = value
291
+ end
292
+ end
293
+
294
+ if attributes.key?(:'created')
295
+ self.created = attributes[:'created']
296
+ end
297
+
298
+ if attributes.key?(:'updated')
299
+ self.updated = attributes[:'updated']
300
+ end
301
+ end
302
+
303
+ # Show invalid properties with the reasons. Usually used together with valid?
304
+ # @return Array for valid properties with the reasons
305
+ def list_invalid_properties
306
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
307
+ invalid_properties = Array.new
308
+ if @name.nil?
309
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
310
+ end
311
+
312
+ if @subject.nil?
313
+ invalid_properties.push('invalid value for "subject", subject cannot be nil.')
314
+ end
315
+
316
+ if @sender.nil?
317
+ invalid_properties.push('invalid value for "sender", sender cannot be nil.')
318
+ end
319
+
320
+ if @schedule_type.nil?
321
+ invalid_properties.push('invalid value for "schedule_type", schedule_type cannot be nil.')
322
+ end
323
+
324
+ if @schedule_condition.nil?
325
+ invalid_properties.push('invalid value for "schedule_condition", schedule_condition cannot be nil.')
326
+ end
327
+
328
+ if @included_lists.nil?
329
+ invalid_properties.push('invalid value for "included_lists", included_lists cannot be nil.')
330
+ end
331
+
332
+ if @excluded_lists.nil?
333
+ invalid_properties.push('invalid value for "excluded_lists", excluded_lists cannot be nil.')
334
+ end
335
+
336
+ invalid_properties
337
+ end
338
+
339
+ # Check to see if the all the properties in the model are valid
340
+ # @return true if the model is valid
341
+ def valid?
342
+ warn '[DEPRECATED] the `valid?` method is obsolete'
343
+ return false if @name.nil?
344
+ return false if @subject.nil?
345
+ return false if @sender.nil?
346
+ return false if @schedule_type.nil?
347
+ return false if @schedule_condition.nil?
348
+ return false if @included_lists.nil?
349
+ return false if @excluded_lists.nil?
350
+ true
351
+ end
352
+
353
+ # Custom attribute writer method with validation
354
+ # @param [Object] name Value to be assigned
355
+ def name=(name)
356
+ if name.nil?
357
+ fail ArgumentError, 'name cannot be nil'
358
+ end
359
+
360
+ @name = name
361
+ end
362
+
363
+ # Custom attribute writer method with validation
364
+ # @param [Object] subject Value to be assigned
365
+ def subject=(subject)
366
+ if subject.nil?
367
+ fail ArgumentError, 'subject cannot be nil'
368
+ end
369
+
370
+ @subject = subject
371
+ end
372
+
373
+ # Custom attribute writer method with validation
374
+ # @param [Object] sender Value to be assigned
375
+ def sender=(sender)
376
+ if sender.nil?
377
+ fail ArgumentError, 'sender cannot be nil'
378
+ end
379
+
380
+ @sender = sender
381
+ end
382
+
383
+ # Custom attribute writer method with validation
384
+ # @param [Object] schedule_type Value to be assigned
385
+ def schedule_type=(schedule_type)
386
+ if schedule_type.nil?
387
+ fail ArgumentError, 'schedule_type cannot be nil'
388
+ end
389
+
390
+ @schedule_type = schedule_type
391
+ end
392
+
393
+ # Custom attribute writer method with validation
394
+ # @param [Object] schedule_condition Value to be assigned
395
+ def schedule_condition=(schedule_condition)
396
+ if schedule_condition.nil?
397
+ fail ArgumentError, 'schedule_condition cannot be nil'
398
+ end
399
+
400
+ @schedule_condition = schedule_condition
401
+ end
402
+
403
+ # Custom attribute writer method with validation
404
+ # @param [Object] included_lists Value to be assigned
405
+ def included_lists=(included_lists)
406
+ if included_lists.nil?
407
+ fail ArgumentError, 'included_lists cannot be nil'
408
+ end
409
+
410
+ @included_lists = included_lists
411
+ end
412
+
413
+ # Custom attribute writer method with validation
414
+ # @param [Object] excluded_lists Value to be assigned
415
+ def excluded_lists=(excluded_lists)
416
+ if excluded_lists.nil?
417
+ fail ArgumentError, 'excluded_lists cannot be nil'
418
+ end
419
+
420
+ @excluded_lists = excluded_lists
421
+ end
422
+
423
+ # Checks equality by comparing each attribute.
424
+ # @param [Object] Object to be compared
425
+ def ==(o)
426
+ return true if self.equal?(o)
427
+ self.class == o.class &&
428
+ id == o.id &&
429
+ name == o.name &&
430
+ subject == o.subject &&
431
+ preheader == o.preheader &&
432
+ sender == o.sender &&
433
+ html_content == o.html_content &&
434
+ text_content == o.text_content &&
435
+ schedule_type == o.schedule_type &&
436
+ schedule_condition == o.schedule_condition &&
437
+ time_condition == o.time_condition &&
438
+ timezone == o.timezone &&
439
+ smart_send == o.smart_send &&
440
+ send_in_contacts_timezone == o.send_in_contacts_timezone &&
441
+ preferred_time_condition == o.preferred_time_condition &&
442
+ preferred_timezone == o.preferred_timezone &&
443
+ strategy == o.strategy &&
444
+ included_segments == o.included_segments &&
445
+ included_lists == o.included_lists &&
446
+ included_tags == o.included_tags &&
447
+ excluded_segments == o.excluded_segments &&
448
+ excluded_lists == o.excluded_lists &&
449
+ excluded_tags == o.excluded_tags &&
450
+ created == o.created &&
451
+ updated == o.updated
452
+ end
453
+
454
+ # @see the `==` method
455
+ # @param [Object] Object to be compared
456
+ def eql?(o)
457
+ self == o
458
+ end
459
+
460
+ # Calculates hash code according to all attributes.
461
+ # @return [Integer] Hash code
462
+ def hash
463
+ [id, name, subject, preheader, sender, html_content, text_content, schedule_type, schedule_condition, time_condition, timezone, smart_send, send_in_contacts_timezone, preferred_time_condition, preferred_timezone, strategy, included_segments, included_lists, included_tags, excluded_segments, excluded_lists, excluded_tags, created, updated].hash
464
+ end
465
+
466
+ # Builds the object from hash
467
+ # @param [Hash] attributes Model attributes in the form of hash
468
+ # @return [Object] Returns the model itself
469
+ def self.build_from_hash(attributes)
470
+ return nil unless attributes.is_a?(Hash)
471
+ attributes = attributes.transform_keys(&:to_sym)
472
+ transformed_hash = {}
473
+ openapi_types.each_pair do |key, type|
474
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
475
+ transformed_hash["#{key}"] = nil
476
+ elsif type =~ /\AArray<(.*)>/i
477
+ # check to ensure the input is an array given that the attribute
478
+ # is documented as an array but the input is not
479
+ if attributes[attribute_map[key]].is_a?(Array)
480
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
481
+ end
482
+ elsif !attributes[attribute_map[key]].nil?
483
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
484
+ end
485
+ end
486
+ new(transformed_hash)
487
+ end
488
+
489
+ # Deserializes the data based on type
490
+ # @param string type Data type
491
+ # @param string value Value to be deserialized
492
+ # @return [Object] Deserialized data
493
+ def self._deserialize(type, value)
494
+ case type.to_sym
495
+ when :Time
496
+ Time.parse(value)
497
+ when :Date
498
+ Date.parse(value)
499
+ when :String
500
+ value.to_s
501
+ when :Integer
502
+ value.to_i
503
+ when :Float
504
+ value.to_f
505
+ when :Boolean
506
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
507
+ true
508
+ else
509
+ false
510
+ end
511
+ when :Object
512
+ # generic object (usually a Hash), return directly
513
+ value
514
+ when /\AArray<(?<inner_type>.+)>\z/
515
+ inner_type = Regexp.last_match[:inner_type]
516
+ value.map { |v| _deserialize(inner_type, v) }
517
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
518
+ k_type = Regexp.last_match[:k_type]
519
+ v_type = Regexp.last_match[:v_type]
520
+ {}.tap do |hash|
521
+ value.each do |k, v|
522
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
523
+ end
524
+ end
525
+ else # model
526
+ # models (e.g. Pet) or oneOf
527
+ klass = SendX.const_get(type)
528
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
529
+ end
530
+ end
531
+
532
+ # Returns the string representation of the object
533
+ # @return [String] String presentation of the object
534
+ def to_s
535
+ to_hash.to_s
536
+ end
537
+
538
+ # to_body is an alias to to_hash (backward compatibility)
539
+ # @return [Hash] Returns the object in the form of hash
540
+ def to_body
541
+ to_hash
542
+ end
543
+
544
+ # Returns the object in the form of hash
545
+ # @return [Hash] Returns the object in the form of hash
546
+ def to_hash
547
+ hash = {}
548
+ self.class.attribute_map.each_pair do |attr, param|
549
+ value = self.send(attr)
550
+ if value.nil?
551
+ is_nullable = self.class.openapi_nullable.include?(attr)
552
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
553
+ end
554
+
555
+ hash[param] = _to_hash(value)
556
+ end
557
+ hash
558
+ end
559
+
560
+ # Outputs non-array value in the form of hash
561
+ # For object, use to_hash. Otherwise, just return the value
562
+ # @param [Object] value Any valid value
563
+ # @return [Hash] Returns the value in the form of hash
564
+ def _to_hash(value)
565
+ if value.is_a?(Array)
566
+ value.compact.map { |v| _to_hash(v) }
567
+ elsif value.is_a?(Hash)
568
+ {}.tap do |hash|
569
+ value.each { |k, v| hash[k] = _to_hash(v) }
570
+ end
571
+ elsif value.respond_to? :to_hash
572
+ value.to_hash
573
+ else
574
+ value
575
+ end
576
+ end
577
+
578
+ end
579
+
580
+ end