sendx-ruby-sdk 1.0.2 → 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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +226 -75
  3. data/lib/sendx-ruby-sdk/api/campaign_api.rb +96 -144
  4. data/lib/sendx-ruby-sdk/api/contact_api.rb +130 -97
  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 +192 -0
  8. data/lib/sendx-ruby-sdk/api/events_api.rb +158 -0
  9. data/lib/sendx-ruby-sdk/api/getting_started_api.rb +158 -0
  10. data/lib/sendx-ruby-sdk/api/list_api.rb +127 -92
  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 +5 -5
  16. data/lib/sendx-ruby-sdk/api/sender_api.rb +29 -38
  17. data/lib/sendx-ruby-sdk/api/tag_api.rb +380 -0
  18. data/lib/sendx-ruby-sdk/api/tags_api.rb +9 -9
  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 +11 -12
  24. data/lib/sendx-ruby-sdk/api_error.rb +4 -4
  25. data/lib/sendx-ruby-sdk/configuration.rb +7 -11
  26. data/lib/sendx-ruby-sdk/models/campaign.rb +24 -8
  27. data/lib/sendx-ruby-sdk/models/campaign_dashboard_data.rb +12 -6
  28. data/lib/sendx-ruby-sdk/models/campaign_request.rb +14 -42
  29. data/lib/sendx-ruby-sdk/models/contact.rb +12 -6
  30. data/lib/sendx-ruby-sdk/models/contact_request.rb +12 -6
  31. data/lib/sendx-ruby-sdk/models/create_response.rb +12 -6
  32. data/lib/sendx-ruby-sdk/models/custom_event_request.rb +270 -0
  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 +12 -6
  36. data/lib/sendx-ruby-sdk/models/delete_campaign200_response.rb +12 -6
  37. data/lib/sendx-ruby-sdk/models/delete_request.rb +12 -6
  38. data/lib/sendx-ruby-sdk/models/delete_response.rb +78 -14
  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 +229 -0
  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 +296 -0
  47. data/lib/sendx-ruby-sdk/models/identify_response.rb +229 -0
  48. data/lib/sendx-ruby-sdk/models/last_sent_campaign_stat.rb +12 -6
  49. data/lib/sendx-ruby-sdk/models/link_stat.rb +232 -0
  50. data/lib/sendx-ruby-sdk/models/list_model.rb +12 -7
  51. data/lib/sendx-ruby-sdk/models/list_request.rb +12 -6
  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 +12 -6
  56. data/lib/sendx-ruby-sdk/models/response.rb +12 -6
  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 +285 -0
  82. data/lib/sendx-ruby-sdk/models/sender.rb +42 -6
  83. data/lib/sendx-ruby-sdk/models/sender_request.rb +32 -6
  84. data/lib/sendx-ruby-sdk/models/sender_response.rb +52 -6
  85. data/lib/sendx-ruby-sdk/models/tag.rb +12 -6
  86. data/lib/sendx-ruby-sdk/models/tag_request.rb +12 -6
  87. data/lib/sendx-ruby-sdk/models/template_email_message.rb +337 -0
  88. data/lib/sendx-ruby-sdk/models/track_request.rb +245 -0
  89. data/lib/sendx-ruby-sdk/models/track_response.rb +229 -0
  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 +5 -5
  100. data/lib/sendx-ruby-sdk.rb +62 -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/event_api_spec.rb +59 -0
  104. data/spec/api/events_api_spec.rb +59 -0
  105. data/spec/api/getting_started_api_spec.rb +59 -0
  106. data/spec/api/post_api_spec.rb +97 -0
  107. data/spec/api/post_category_api_spec.rb +95 -0
  108. data/spec/api/post_tag_api_spec.rb +95 -0
  109. data/spec/api/report_api_spec.rb +47 -0
  110. data/spec/api/tag_api_spec.rb +97 -0
  111. data/spec/api/team_member_api_spec.rb +58 -0
  112. data/spec/api/template_api_spec.rb +98 -0
  113. data/spec/api/tracking_api_spec.rb +59 -0
  114. data/spec/api/webhook_api_spec.rb +95 -0
  115. data/spec/models/custom_event_request_spec.rb +54 -0
  116. data/spec/models/custom_field_spec.rb +58 -0
  117. data/spec/models/customfield_customfield_id_delete200_response_spec.rb +36 -0
  118. data/spec/models/e_custom_field_spec.rb +64 -0
  119. data/spec/models/error_response_spec.rb +46 -0
  120. data/spec/models/event_response_spec.rb +48 -0
  121. data/spec/models/events_revenue_postback_get200_response_spec.rb +42 -0
  122. data/spec/models/events_revenue_postback_get400_response_spec.rb +36 -0
  123. data/spec/models/events_revenue_postback_get500_response_spec.rb +36 -0
  124. data/spec/models/identify_error_response_spec.rb +36 -0
  125. data/spec/models/identify_request_spec.rb +72 -0
  126. data/spec/models/identify_response_spec.rb +48 -0
  127. data/spec/models/link_stat_spec.rb +42 -0
  128. data/spec/models/message_response_spec.rb +42 -0
  129. data/spec/models/operation_response_spec.rb +48 -0
  130. data/spec/models/postback_response_spec.rb +42 -0
  131. data/spec/models/rest_e_campaign_spec.rb +154 -0
  132. data/spec/models/rest_e_contact_spec.rb +78 -0
  133. data/spec/models/rest_e_custom_field_spec.rb +52 -0
  134. data/spec/models/rest_e_list_spec.rb +36 -0
  135. data/spec/models/rest_e_post_category_spec.rb +36 -0
  136. data/spec/models/rest_e_post_spec.rb +144 -0
  137. data/spec/models/rest_e_post_tag_spec.rb +36 -0
  138. data/spec/models/rest_e_sender_spec.rb +42 -0
  139. data/spec/models/rest_e_tag_spec.rb +36 -0
  140. data/spec/models/rest_e_template_spec.rb +66 -0
  141. data/spec/models/rest_e_webhook_spec.rb +84 -0
  142. data/spec/models/rest_r_campaign_spec.rb +178 -0
  143. data/spec/models/rest_r_contact_spec.rb +150 -0
  144. data/spec/models/rest_r_custom_field_spec.rb +58 -0
  145. data/spec/models/rest_r_list_spec.rb +64 -0
  146. data/spec/models/rest_r_member_spec.rb +72 -0
  147. data/spec/models/rest_r_post_category_spec.rb +54 -0
  148. data/spec/models/rest_r_post_spec.rb +144 -0
  149. data/spec/models/rest_r_post_tag_spec.rb +54 -0
  150. data/spec/models/rest_r_sender_spec.rb +54 -0
  151. data/spec/models/rest_r_tag_spec.rb +54 -0
  152. data/spec/models/rest_r_template_spec.rb +94 -0
  153. data/spec/models/rest_r_webhook_spec.rb +90 -0
  154. data/spec/models/rest_report_data_spec.rb +90 -0
  155. data/spec/models/revenue_event_request_spec.rb +60 -0
  156. data/spec/models/template_email_message_spec.rb +72 -0
  157. data/spec/models/track_request_spec.rb +48 -0
  158. data/spec/models/track_response_spec.rb +42 -0
  159. data/spec/models/webhook_object_spec.rb +180 -0
  160. data/spec/models/webhook_request_spec.rb +78 -0
  161. data/spec/models/webhook_spec.rb +90 -0
  162. data/spec/models/x_attachment_spec.rb +42 -0
  163. data/spec/models/x_email_message_spec.rb +90 -0
  164. data/spec/models/x_email_response_spec.rb +60 -0
  165. data/spec/models/x_from_spec.rb +42 -0
  166. data/spec/models/x_reply_to_spec.rb +42 -0
  167. data/spec/models/xto_spec.rb +60 -0
  168. data/spec/spec_helper.rb +4 -4
  169. metadata +221 -20
@@ -0,0 +1,539 @@
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 RestECampaign
18
+ # Campaign name for internal organization
19
+ attr_accessor :name
20
+
21
+ # Email subject line with personalization support. **Features:** - Supports template variables ({{contact.firstName}}) - Emoji support for better engagement - A/B testing variations supported
22
+ attr_accessor :subject
23
+
24
+ # Sender identifier. **Note:** Sender must be verified before use
25
+ attr_accessor :sender
26
+
27
+ # HTML content of the email campaign
28
+ attr_accessor :html_code
29
+
30
+ # Preview text shown in email clients
31
+ attr_accessor :preview_text
32
+
33
+ # Plain text version for better deliverability
34
+ attr_accessor :plain_text
35
+
36
+ # Campaign scheduling type. **Values:** - `0` - Schedule for specific date/time - `1` - Send immediately
37
+ attr_accessor :schedule_type
38
+
39
+ # datetime for scheduled campaigns (required if scheduleType=0)
40
+ attr_accessor :schedule_condition
41
+
42
+ # Time condition for scheduled campaigns in HH:MM PM/AM format
43
+ attr_accessor :time_condition
44
+
45
+ # Timezone for scheduled campaigns (IANA format)
46
+ attr_accessor :timezone
47
+
48
+ # Preferred timezone for smart send optimization (required for smartSend and sendInContactsTimezone)
49
+ attr_accessor :preferred_timezone
50
+
51
+ # Preferred time optimization setting (required for smartSend and sendInContactsTimezone)
52
+ attr_accessor :preferred_time_condition
53
+
54
+ # Send at specified time in each contact's timezone
55
+ attr_accessor :send_in_contacts_timezone
56
+
57
+ # Enable AI-powered send time optimization
58
+ attr_accessor :smart_send
59
+
60
+ # Segment IDs to include
61
+ attr_accessor :included_segments
62
+
63
+ # List IDs to include
64
+ attr_accessor :included_lists
65
+
66
+ # Tag IDs to include
67
+ attr_accessor :included_tags
68
+
69
+ # Segment IDs to exclude
70
+ attr_accessor :excluded_segments
71
+
72
+ # List IDs to exclude
73
+ attr_accessor :excluded_lists
74
+
75
+ # Tag IDs to exclude (prefix automatically stripped)
76
+ attr_accessor :excluded_tags
77
+
78
+ # Attribute mapping from ruby-style variable name to JSON key.
79
+ def self.attribute_map
80
+ {
81
+ :'name' => :'name',
82
+ :'subject' => :'subject',
83
+ :'sender' => :'sender',
84
+ :'html_code' => :'htmlCode',
85
+ :'preview_text' => :'previewText',
86
+ :'plain_text' => :'plainText',
87
+ :'schedule_type' => :'scheduleType',
88
+ :'schedule_condition' => :'scheduleCondition',
89
+ :'time_condition' => :'timeCondition',
90
+ :'timezone' => :'timezone',
91
+ :'preferred_timezone' => :'preferredTimezone',
92
+ :'preferred_time_condition' => :'preferredTimeCondition',
93
+ :'send_in_contacts_timezone' => :'sendInContactsTimezone',
94
+ :'smart_send' => :'smartSend',
95
+ :'included_segments' => :'includedSegments',
96
+ :'included_lists' => :'includedLists',
97
+ :'included_tags' => :'includedTags',
98
+ :'excluded_segments' => :'excludedSegments',
99
+ :'excluded_lists' => :'excludedLists',
100
+ :'excluded_tags' => :'excludedTags'
101
+ }
102
+ end
103
+
104
+ # Returns attribute mapping this model knows about
105
+ def self.acceptable_attribute_map
106
+ attribute_map
107
+ end
108
+
109
+ # Returns all the JSON keys this model knows about
110
+ def self.acceptable_attributes
111
+ acceptable_attribute_map.values
112
+ end
113
+
114
+ # Attribute type mapping.
115
+ def self.openapi_types
116
+ {
117
+ :'name' => :'String',
118
+ :'subject' => :'String',
119
+ :'sender' => :'String',
120
+ :'html_code' => :'String',
121
+ :'preview_text' => :'String',
122
+ :'plain_text' => :'String',
123
+ :'schedule_type' => :'Integer',
124
+ :'schedule_condition' => :'String',
125
+ :'time_condition' => :'String',
126
+ :'timezone' => :'String',
127
+ :'preferred_timezone' => :'String',
128
+ :'preferred_time_condition' => :'String',
129
+ :'send_in_contacts_timezone' => :'Boolean',
130
+ :'smart_send' => :'Boolean',
131
+ :'included_segments' => :'Array<String>',
132
+ :'included_lists' => :'Array<String>',
133
+ :'included_tags' => :'Array<String>',
134
+ :'excluded_segments' => :'Array<String>',
135
+ :'excluded_lists' => :'Array<String>',
136
+ :'excluded_tags' => :'Array<String>'
137
+ }
138
+ end
139
+
140
+ # List of attributes with nullable: true
141
+ def self.openapi_nullable
142
+ Set.new([
143
+ ])
144
+ end
145
+
146
+ # Initializes the object
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ def initialize(attributes = {})
149
+ if (!attributes.is_a?(Hash))
150
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::RestECampaign` initialize method"
151
+ end
152
+
153
+ # check to see if the attribute exists and convert string to symbol for hash key
154
+ acceptable_attribute_map = self.class.acceptable_attribute_map
155
+ attributes = attributes.each_with_object({}) { |(k, v), h|
156
+ if (!acceptable_attribute_map.key?(k.to_sym))
157
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::RestECampaign`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
158
+ end
159
+ h[k.to_sym] = v
160
+ }
161
+
162
+ if attributes.key?(:'name')
163
+ self.name = attributes[:'name']
164
+ else
165
+ self.name = nil
166
+ end
167
+
168
+ if attributes.key?(:'subject')
169
+ self.subject = attributes[:'subject']
170
+ else
171
+ self.subject = nil
172
+ end
173
+
174
+ if attributes.key?(:'sender')
175
+ self.sender = attributes[:'sender']
176
+ else
177
+ self.sender = nil
178
+ end
179
+
180
+ if attributes.key?(:'html_code')
181
+ self.html_code = attributes[:'html_code']
182
+ else
183
+ self.html_code = nil
184
+ end
185
+
186
+ if attributes.key?(:'preview_text')
187
+ self.preview_text = attributes[:'preview_text']
188
+ end
189
+
190
+ if attributes.key?(:'plain_text')
191
+ self.plain_text = attributes[:'plain_text']
192
+ end
193
+
194
+ if attributes.key?(:'schedule_type')
195
+ self.schedule_type = attributes[:'schedule_type']
196
+ end
197
+
198
+ if attributes.key?(:'schedule_condition')
199
+ self.schedule_condition = attributes[:'schedule_condition']
200
+ end
201
+
202
+ if attributes.key?(:'time_condition')
203
+ self.time_condition = attributes[:'time_condition']
204
+ end
205
+
206
+ if attributes.key?(:'timezone')
207
+ self.timezone = attributes[:'timezone']
208
+ end
209
+
210
+ if attributes.key?(:'preferred_timezone')
211
+ self.preferred_timezone = attributes[:'preferred_timezone']
212
+ end
213
+
214
+ if attributes.key?(:'preferred_time_condition')
215
+ self.preferred_time_condition = attributes[:'preferred_time_condition']
216
+ end
217
+
218
+ if attributes.key?(:'send_in_contacts_timezone')
219
+ self.send_in_contacts_timezone = attributes[:'send_in_contacts_timezone']
220
+ end
221
+
222
+ if attributes.key?(:'smart_send')
223
+ self.smart_send = attributes[:'smart_send']
224
+ end
225
+
226
+ if attributes.key?(:'included_segments')
227
+ if (value = attributes[:'included_segments']).is_a?(Array)
228
+ self.included_segments = value
229
+ end
230
+ end
231
+
232
+ if attributes.key?(:'included_lists')
233
+ if (value = attributes[:'included_lists']).is_a?(Array)
234
+ self.included_lists = value
235
+ end
236
+ end
237
+
238
+ if attributes.key?(:'included_tags')
239
+ if (value = attributes[:'included_tags']).is_a?(Array)
240
+ self.included_tags = value
241
+ end
242
+ end
243
+
244
+ if attributes.key?(:'excluded_segments')
245
+ if (value = attributes[:'excluded_segments']).is_a?(Array)
246
+ self.excluded_segments = value
247
+ end
248
+ end
249
+
250
+ if attributes.key?(:'excluded_lists')
251
+ if (value = attributes[:'excluded_lists']).is_a?(Array)
252
+ self.excluded_lists = value
253
+ end
254
+ end
255
+
256
+ if attributes.key?(:'excluded_tags')
257
+ if (value = attributes[:'excluded_tags']).is_a?(Array)
258
+ self.excluded_tags = value
259
+ end
260
+ end
261
+ end
262
+
263
+ # Show invalid properties with the reasons. Usually used together with valid?
264
+ # @return Array for valid properties with the reasons
265
+ def list_invalid_properties
266
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
267
+ invalid_properties = Array.new
268
+ if @name.nil?
269
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
270
+ end
271
+
272
+ if @name.to_s.length > 255
273
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 255.')
274
+ end
275
+
276
+ if @subject.nil?
277
+ invalid_properties.push('invalid value for "subject", subject cannot be nil.')
278
+ end
279
+
280
+ if @subject.to_s.length > 255
281
+ invalid_properties.push('invalid value for "subject", the character length must be smaller than or equal to 255.')
282
+ end
283
+
284
+ if @sender.nil?
285
+ invalid_properties.push('invalid value for "sender", sender cannot be nil.')
286
+ end
287
+
288
+ pattern = Regexp.new(/^(sender_)?[a-zA-Z0-9]{22}$/)
289
+ if @sender !~ pattern
290
+ invalid_properties.push("invalid value for \"sender\", must conform to the pattern #{pattern}.")
291
+ end
292
+
293
+ if @html_code.nil?
294
+ invalid_properties.push('invalid value for "html_code", html_code cannot be nil.')
295
+ end
296
+
297
+ if !@preview_text.nil? && @preview_text.to_s.length > 255
298
+ invalid_properties.push('invalid value for "preview_text", the character length must be smaller than or equal to 255.')
299
+ end
300
+
301
+ invalid_properties
302
+ end
303
+
304
+ # Check to see if the all the properties in the model are valid
305
+ # @return true if the model is valid
306
+ def valid?
307
+ warn '[DEPRECATED] the `valid?` method is obsolete'
308
+ return false if @name.nil?
309
+ return false if @name.to_s.length > 255
310
+ return false if @subject.nil?
311
+ return false if @subject.to_s.length > 255
312
+ return false if @sender.nil?
313
+ return false if @sender !~ Regexp.new(/^(sender_)?[a-zA-Z0-9]{22}$/)
314
+ return false if @html_code.nil?
315
+ return false if !@preview_text.nil? && @preview_text.to_s.length > 255
316
+ true
317
+ end
318
+
319
+ # Custom attribute writer method with validation
320
+ # @param [Object] name Value to be assigned
321
+ def name=(name)
322
+ if name.nil?
323
+ fail ArgumentError, 'name cannot be nil'
324
+ end
325
+
326
+ if name.to_s.length > 255
327
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.'
328
+ end
329
+
330
+ @name = name
331
+ end
332
+
333
+ # Custom attribute writer method with validation
334
+ # @param [Object] subject Value to be assigned
335
+ def subject=(subject)
336
+ if subject.nil?
337
+ fail ArgumentError, 'subject cannot be nil'
338
+ end
339
+
340
+ if subject.to_s.length > 255
341
+ fail ArgumentError, 'invalid value for "subject", the character length must be smaller than or equal to 255.'
342
+ end
343
+
344
+ @subject = subject
345
+ end
346
+
347
+ # Custom attribute writer method with validation
348
+ # @param [Object] sender Value to be assigned
349
+ def sender=(sender)
350
+ if sender.nil?
351
+ fail ArgumentError, 'sender cannot be nil'
352
+ end
353
+
354
+ pattern = Regexp.new(/^(sender_)?[a-zA-Z0-9]{22}$/)
355
+ if sender !~ pattern
356
+ fail ArgumentError, "invalid value for \"sender\", must conform to the pattern #{pattern}."
357
+ end
358
+
359
+ @sender = sender
360
+ end
361
+
362
+ # Custom attribute writer method with validation
363
+ # @param [Object] html_code Value to be assigned
364
+ def html_code=(html_code)
365
+ if html_code.nil?
366
+ fail ArgumentError, 'html_code cannot be nil'
367
+ end
368
+
369
+ @html_code = html_code
370
+ end
371
+
372
+ # Custom attribute writer method with validation
373
+ # @param [Object] preview_text Value to be assigned
374
+ def preview_text=(preview_text)
375
+ if preview_text.nil?
376
+ fail ArgumentError, 'preview_text cannot be nil'
377
+ end
378
+
379
+ if preview_text.to_s.length > 255
380
+ fail ArgumentError, 'invalid value for "preview_text", the character length must be smaller than or equal to 255.'
381
+ end
382
+
383
+ @preview_text = preview_text
384
+ end
385
+
386
+ # Checks equality by comparing each attribute.
387
+ # @param [Object] Object to be compared
388
+ def ==(o)
389
+ return true if self.equal?(o)
390
+ self.class == o.class &&
391
+ name == o.name &&
392
+ subject == o.subject &&
393
+ sender == o.sender &&
394
+ html_code == o.html_code &&
395
+ preview_text == o.preview_text &&
396
+ plain_text == o.plain_text &&
397
+ schedule_type == o.schedule_type &&
398
+ schedule_condition == o.schedule_condition &&
399
+ time_condition == o.time_condition &&
400
+ timezone == o.timezone &&
401
+ preferred_timezone == o.preferred_timezone &&
402
+ preferred_time_condition == o.preferred_time_condition &&
403
+ send_in_contacts_timezone == o.send_in_contacts_timezone &&
404
+ smart_send == o.smart_send &&
405
+ included_segments == o.included_segments &&
406
+ included_lists == o.included_lists &&
407
+ included_tags == o.included_tags &&
408
+ excluded_segments == o.excluded_segments &&
409
+ excluded_lists == o.excluded_lists &&
410
+ excluded_tags == o.excluded_tags
411
+ end
412
+
413
+ # @see the `==` method
414
+ # @param [Object] Object to be compared
415
+ def eql?(o)
416
+ self == o
417
+ end
418
+
419
+ # Calculates hash code according to all attributes.
420
+ # @return [Integer] Hash code
421
+ def hash
422
+ [name, subject, sender, html_code, preview_text, plain_text, schedule_type, schedule_condition, time_condition, timezone, preferred_timezone, preferred_time_condition, send_in_contacts_timezone, smart_send, included_segments, included_lists, included_tags, excluded_segments, excluded_lists, excluded_tags].hash
423
+ end
424
+
425
+ # Builds the object from hash
426
+ # @param [Hash] attributes Model attributes in the form of hash
427
+ # @return [Object] Returns the model itself
428
+ def self.build_from_hash(attributes)
429
+ return nil unless attributes.is_a?(Hash)
430
+ attributes = attributes.transform_keys(&:to_sym)
431
+ transformed_hash = {}
432
+ openapi_types.each_pair do |key, type|
433
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
434
+ transformed_hash["#{key}"] = nil
435
+ elsif type =~ /\AArray<(.*)>/i
436
+ # check to ensure the input is an array given that the attribute
437
+ # is documented as an array but the input is not
438
+ if attributes[attribute_map[key]].is_a?(Array)
439
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
440
+ end
441
+ elsif !attributes[attribute_map[key]].nil?
442
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
443
+ end
444
+ end
445
+ new(transformed_hash)
446
+ end
447
+
448
+ # Deserializes the data based on type
449
+ # @param string type Data type
450
+ # @param string value Value to be deserialized
451
+ # @return [Object] Deserialized data
452
+ def self._deserialize(type, value)
453
+ case type.to_sym
454
+ when :Time
455
+ Time.parse(value)
456
+ when :Date
457
+ Date.parse(value)
458
+ when :String
459
+ value.to_s
460
+ when :Integer
461
+ value.to_i
462
+ when :Float
463
+ value.to_f
464
+ when :Boolean
465
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
466
+ true
467
+ else
468
+ false
469
+ end
470
+ when :Object
471
+ # generic object (usually a Hash), return directly
472
+ value
473
+ when /\AArray<(?<inner_type>.+)>\z/
474
+ inner_type = Regexp.last_match[:inner_type]
475
+ value.map { |v| _deserialize(inner_type, v) }
476
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
477
+ k_type = Regexp.last_match[:k_type]
478
+ v_type = Regexp.last_match[:v_type]
479
+ {}.tap do |hash|
480
+ value.each do |k, v|
481
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
482
+ end
483
+ end
484
+ else # model
485
+ # models (e.g. Pet) or oneOf
486
+ klass = SendX.const_get(type)
487
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
488
+ end
489
+ end
490
+
491
+ # Returns the string representation of the object
492
+ # @return [String] String presentation of the object
493
+ def to_s
494
+ to_hash.to_s
495
+ end
496
+
497
+ # to_body is an alias to to_hash (backward compatibility)
498
+ # @return [Hash] Returns the object in the form of hash
499
+ def to_body
500
+ to_hash
501
+ end
502
+
503
+ # Returns the object in the form of hash
504
+ # @return [Hash] Returns the object in the form of hash
505
+ def to_hash
506
+ hash = {}
507
+ self.class.attribute_map.each_pair do |attr, param|
508
+ value = self.send(attr)
509
+ if value.nil?
510
+ is_nullable = self.class.openapi_nullable.include?(attr)
511
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
512
+ end
513
+
514
+ hash[param] = _to_hash(value)
515
+ end
516
+ hash
517
+ end
518
+
519
+ # Outputs non-array value in the form of hash
520
+ # For object, use to_hash. Otherwise, just return the value
521
+ # @param [Object] value Any valid value
522
+ # @return [Hash] Returns the value in the form of hash
523
+ def _to_hash(value)
524
+ if value.is_a?(Array)
525
+ value.compact.map { |v| _to_hash(v) }
526
+ elsif value.is_a?(Hash)
527
+ {}.tap do |hash|
528
+ value.each { |k, v| hash[k] = _to_hash(v) }
529
+ end
530
+ elsif value.respond_to? :to_hash
531
+ value.to_hash
532
+ else
533
+ value
534
+ end
535
+ end
536
+
537
+ end
538
+
539
+ end