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,366 @@
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 RestRTemplate
18
+ # Unique template identifier with template_ prefix
19
+ attr_accessor :id
20
+
21
+ # Name of the template
22
+ attr_accessor :name
23
+
24
+ # Email subject line (if applicable)
25
+ attr_accessor :subject
26
+
27
+ # HTML content of the template
28
+ attr_accessor :html_code
29
+
30
+ # Template code for visual editors (JSON structure)
31
+ attr_accessor :template_code
32
+
33
+ # Template type. **Values:** - `0` - Email template - `1` - Other types
34
+ attr_accessor :type
35
+
36
+ # URL to template thumbnail image
37
+ attr_accessor :thumbnail
38
+
39
+ # Editor type used to create the template. **Values:** - `0` - PlainText - `1` - DragDrop - `2` - SendxEditor
40
+ attr_accessor :editor_type
41
+
42
+ # Template creation timestamp
43
+ attr_accessor :created
44
+
45
+ # Template last update timestamp
46
+ attr_accessor :updated
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'id' => :'id',
74
+ :'name' => :'name',
75
+ :'subject' => :'subject',
76
+ :'html_code' => :'htmlCode',
77
+ :'template_code' => :'templateCode',
78
+ :'type' => :'type',
79
+ :'thumbnail' => :'thumbnail',
80
+ :'editor_type' => :'editorType',
81
+ :'created' => :'created',
82
+ :'updated' => :'updated'
83
+ }
84
+ end
85
+
86
+ # Returns attribute mapping this model knows about
87
+ def self.acceptable_attribute_map
88
+ attribute_map
89
+ end
90
+
91
+ # Returns all the JSON keys this model knows about
92
+ def self.acceptable_attributes
93
+ acceptable_attribute_map.values
94
+ end
95
+
96
+ # Attribute type mapping.
97
+ def self.openapi_types
98
+ {
99
+ :'id' => :'String',
100
+ :'name' => :'String',
101
+ :'subject' => :'String',
102
+ :'html_code' => :'String',
103
+ :'template_code' => :'String',
104
+ :'type' => :'Integer',
105
+ :'thumbnail' => :'String',
106
+ :'editor_type' => :'Integer',
107
+ :'created' => :'Time',
108
+ :'updated' => :'Time'
109
+ }
110
+ end
111
+
112
+ # List of attributes with nullable: true
113
+ def self.openapi_nullable
114
+ Set.new([
115
+ ])
116
+ end
117
+
118
+ # Initializes the object
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ def initialize(attributes = {})
121
+ if (!attributes.is_a?(Hash))
122
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::RestRTemplate` initialize method"
123
+ end
124
+
125
+ # check to see if the attribute exists and convert string to symbol for hash key
126
+ acceptable_attribute_map = self.class.acceptable_attribute_map
127
+ attributes = attributes.each_with_object({}) { |(k, v), h|
128
+ if (!acceptable_attribute_map.key?(k.to_sym))
129
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::RestRTemplate`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
130
+ end
131
+ h[k.to_sym] = v
132
+ }
133
+
134
+ if attributes.key?(:'id')
135
+ self.id = attributes[:'id']
136
+ end
137
+
138
+ if attributes.key?(:'name')
139
+ self.name = attributes[:'name']
140
+ end
141
+
142
+ if attributes.key?(:'subject')
143
+ self.subject = attributes[:'subject']
144
+ end
145
+
146
+ if attributes.key?(:'html_code')
147
+ self.html_code = attributes[:'html_code']
148
+ end
149
+
150
+ if attributes.key?(:'template_code')
151
+ self.template_code = attributes[:'template_code']
152
+ end
153
+
154
+ if attributes.key?(:'type')
155
+ self.type = attributes[:'type']
156
+ end
157
+
158
+ if attributes.key?(:'thumbnail')
159
+ self.thumbnail = attributes[:'thumbnail']
160
+ end
161
+
162
+ if attributes.key?(:'editor_type')
163
+ self.editor_type = attributes[:'editor_type']
164
+ end
165
+
166
+ if attributes.key?(:'created')
167
+ self.created = attributes[:'created']
168
+ end
169
+
170
+ if attributes.key?(:'updated')
171
+ self.updated = attributes[:'updated']
172
+ end
173
+ end
174
+
175
+ # Show invalid properties with the reasons. Usually used together with valid?
176
+ # @return Array for valid properties with the reasons
177
+ def list_invalid_properties
178
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
179
+ invalid_properties = Array.new
180
+ pattern = Regexp.new(/^template_[a-zA-Z0-9]{22}$/)
181
+ if !@id.nil? && @id !~ pattern
182
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
183
+ end
184
+
185
+ invalid_properties
186
+ end
187
+
188
+ # Check to see if the all the properties in the model are valid
189
+ # @return true if the model is valid
190
+ def valid?
191
+ warn '[DEPRECATED] the `valid?` method is obsolete'
192
+ return false if !@id.nil? && @id !~ Regexp.new(/^template_[a-zA-Z0-9]{22}$/)
193
+ editor_type_validator = EnumAttributeValidator.new('Integer', [0, 1, 2])
194
+ return false unless editor_type_validator.valid?(@editor_type)
195
+ true
196
+ end
197
+
198
+ # Custom attribute writer method with validation
199
+ # @param [Object] id Value to be assigned
200
+ def id=(id)
201
+ if id.nil?
202
+ fail ArgumentError, 'id cannot be nil'
203
+ end
204
+
205
+ pattern = Regexp.new(/^template_[a-zA-Z0-9]{22}$/)
206
+ if id !~ pattern
207
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
208
+ end
209
+
210
+ @id = id
211
+ end
212
+
213
+ # Custom attribute writer method checking allowed values (enum).
214
+ # @param [Object] editor_type Object to be assigned
215
+ def editor_type=(editor_type)
216
+ validator = EnumAttributeValidator.new('Integer', [0, 1, 2])
217
+ unless validator.valid?(editor_type)
218
+ fail ArgumentError, "invalid value for \"editor_type\", must be one of #{validator.allowable_values}."
219
+ end
220
+ @editor_type = editor_type
221
+ end
222
+
223
+ # Checks equality by comparing each attribute.
224
+ # @param [Object] Object to be compared
225
+ def ==(o)
226
+ return true if self.equal?(o)
227
+ self.class == o.class &&
228
+ id == o.id &&
229
+ name == o.name &&
230
+ subject == o.subject &&
231
+ html_code == o.html_code &&
232
+ template_code == o.template_code &&
233
+ type == o.type &&
234
+ thumbnail == o.thumbnail &&
235
+ editor_type == o.editor_type &&
236
+ created == o.created &&
237
+ updated == o.updated
238
+ end
239
+
240
+ # @see the `==` method
241
+ # @param [Object] Object to be compared
242
+ def eql?(o)
243
+ self == o
244
+ end
245
+
246
+ # Calculates hash code according to all attributes.
247
+ # @return [Integer] Hash code
248
+ def hash
249
+ [id, name, subject, html_code, template_code, type, thumbnail, editor_type, created, updated].hash
250
+ end
251
+
252
+ # Builds the object from hash
253
+ # @param [Hash] attributes Model attributes in the form of hash
254
+ # @return [Object] Returns the model itself
255
+ def self.build_from_hash(attributes)
256
+ return nil unless attributes.is_a?(Hash)
257
+ attributes = attributes.transform_keys(&:to_sym)
258
+ transformed_hash = {}
259
+ openapi_types.each_pair do |key, type|
260
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
261
+ transformed_hash["#{key}"] = nil
262
+ elsif type =~ /\AArray<(.*)>/i
263
+ # check to ensure the input is an array given that the attribute
264
+ # is documented as an array but the input is not
265
+ if attributes[attribute_map[key]].is_a?(Array)
266
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
267
+ end
268
+ elsif !attributes[attribute_map[key]].nil?
269
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
270
+ end
271
+ end
272
+ new(transformed_hash)
273
+ end
274
+
275
+ # Deserializes the data based on type
276
+ # @param string type Data type
277
+ # @param string value Value to be deserialized
278
+ # @return [Object] Deserialized data
279
+ def self._deserialize(type, value)
280
+ case type.to_sym
281
+ when :Time
282
+ Time.parse(value)
283
+ when :Date
284
+ Date.parse(value)
285
+ when :String
286
+ value.to_s
287
+ when :Integer
288
+ value.to_i
289
+ when :Float
290
+ value.to_f
291
+ when :Boolean
292
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
293
+ true
294
+ else
295
+ false
296
+ end
297
+ when :Object
298
+ # generic object (usually a Hash), return directly
299
+ value
300
+ when /\AArray<(?<inner_type>.+)>\z/
301
+ inner_type = Regexp.last_match[:inner_type]
302
+ value.map { |v| _deserialize(inner_type, v) }
303
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
304
+ k_type = Regexp.last_match[:k_type]
305
+ v_type = Regexp.last_match[:v_type]
306
+ {}.tap do |hash|
307
+ value.each do |k, v|
308
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
309
+ end
310
+ end
311
+ else # model
312
+ # models (e.g. Pet) or oneOf
313
+ klass = SendX.const_get(type)
314
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
315
+ end
316
+ end
317
+
318
+ # Returns the string representation of the object
319
+ # @return [String] String presentation of the object
320
+ def to_s
321
+ to_hash.to_s
322
+ end
323
+
324
+ # to_body is an alias to to_hash (backward compatibility)
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_body
327
+ to_hash
328
+ end
329
+
330
+ # Returns the object in the form of hash
331
+ # @return [Hash] Returns the object in the form of hash
332
+ def to_hash
333
+ hash = {}
334
+ self.class.attribute_map.each_pair do |attr, param|
335
+ value = self.send(attr)
336
+ if value.nil?
337
+ is_nullable = self.class.openapi_nullable.include?(attr)
338
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
339
+ end
340
+
341
+ hash[param] = _to_hash(value)
342
+ end
343
+ hash
344
+ end
345
+
346
+ # Outputs non-array value in the form of hash
347
+ # For object, use to_hash. Otherwise, just return the value
348
+ # @param [Object] value Any valid value
349
+ # @return [Hash] Returns the value in the form of hash
350
+ def _to_hash(value)
351
+ if value.is_a?(Array)
352
+ value.compact.map { |v| _to_hash(v) }
353
+ elsif value.is_a?(Hash)
354
+ {}.tap do |hash|
355
+ value.each { |k, v| hash[k] = _to_hash(v) }
356
+ end
357
+ elsif value.respond_to? :to_hash
358
+ value.to_hash
359
+ else
360
+ value
361
+ end
362
+ end
363
+
364
+ end
365
+
366
+ end
@@ -0,0 +1,326 @@
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 RestRWebhook
18
+ attr_accessor :id
19
+
20
+ # Webhook endpoint URL
21
+ attr_accessor :url
22
+
23
+ # Whether webhook is enabled
24
+ attr_accessor :enabled
25
+
26
+ # Trigger webhook when a contact unsubscribes
27
+ attr_accessor :unsubscribed
28
+
29
+ # Trigger webhook when an email is dropped
30
+ attr_accessor :dropped
31
+
32
+ # Trigger webhook when an email bounces
33
+ attr_accessor :bounced
34
+
35
+ # Trigger webhook when an email is marked as spam
36
+ attr_accessor :marked_spam
37
+
38
+ # Trigger webhook when a link in the email is clicked
39
+ attr_accessor :clicked
40
+
41
+ # Trigger webhook when an email is opened
42
+ attr_accessor :opened
43
+
44
+ # Trigger webhook when a new contact is created
45
+ attr_accessor :contact_created
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'id' => :'id',
51
+ :'url' => :'url',
52
+ :'enabled' => :'enabled',
53
+ :'unsubscribed' => :'unsubscribed',
54
+ :'dropped' => :'dropped',
55
+ :'bounced' => :'bounced',
56
+ :'marked_spam' => :'markedSpam',
57
+ :'clicked' => :'clicked',
58
+ :'opened' => :'opened',
59
+ :'contact_created' => :'contactCreated'
60
+ }
61
+ end
62
+
63
+ # Returns attribute mapping this model knows about
64
+ def self.acceptable_attribute_map
65
+ attribute_map
66
+ end
67
+
68
+ # Returns all the JSON keys this model knows about
69
+ def self.acceptable_attributes
70
+ acceptable_attribute_map.values
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.openapi_types
75
+ {
76
+ :'id' => :'String',
77
+ :'url' => :'String',
78
+ :'enabled' => :'Boolean',
79
+ :'unsubscribed' => :'Boolean',
80
+ :'dropped' => :'Boolean',
81
+ :'bounced' => :'Boolean',
82
+ :'marked_spam' => :'Boolean',
83
+ :'clicked' => :'Boolean',
84
+ :'opened' => :'Boolean',
85
+ :'contact_created' => :'Boolean'
86
+ }
87
+ end
88
+
89
+ # List of attributes with nullable: true
90
+ def self.openapi_nullable
91
+ Set.new([
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::RestRWebhook` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ acceptable_attribute_map = self.class.acceptable_attribute_map
104
+ attributes = attributes.each_with_object({}) { |(k, v), h|
105
+ if (!acceptable_attribute_map.key?(k.to_sym))
106
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::RestRWebhook`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
107
+ end
108
+ h[k.to_sym] = v
109
+ }
110
+
111
+ if attributes.key?(:'id')
112
+ self.id = attributes[:'id']
113
+ end
114
+
115
+ if attributes.key?(:'url')
116
+ self.url = attributes[:'url']
117
+ end
118
+
119
+ if attributes.key?(:'enabled')
120
+ self.enabled = attributes[:'enabled']
121
+ else
122
+ self.enabled = true
123
+ end
124
+
125
+ if attributes.key?(:'unsubscribed')
126
+ self.unsubscribed = attributes[:'unsubscribed']
127
+ else
128
+ self.unsubscribed = false
129
+ end
130
+
131
+ if attributes.key?(:'dropped')
132
+ self.dropped = attributes[:'dropped']
133
+ else
134
+ self.dropped = false
135
+ end
136
+
137
+ if attributes.key?(:'bounced')
138
+ self.bounced = attributes[:'bounced']
139
+ else
140
+ self.bounced = false
141
+ end
142
+
143
+ if attributes.key?(:'marked_spam')
144
+ self.marked_spam = attributes[:'marked_spam']
145
+ else
146
+ self.marked_spam = false
147
+ end
148
+
149
+ if attributes.key?(:'clicked')
150
+ self.clicked = attributes[:'clicked']
151
+ else
152
+ self.clicked = false
153
+ end
154
+
155
+ if attributes.key?(:'opened')
156
+ self.opened = attributes[:'opened']
157
+ else
158
+ self.opened = false
159
+ end
160
+
161
+ if attributes.key?(:'contact_created')
162
+ self.contact_created = attributes[:'contact_created']
163
+ else
164
+ self.contact_created = false
165
+ end
166
+ end
167
+
168
+ # Show invalid properties with the reasons. Usually used together with valid?
169
+ # @return Array for valid properties with the reasons
170
+ def list_invalid_properties
171
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
172
+ invalid_properties = Array.new
173
+ invalid_properties
174
+ end
175
+
176
+ # Check to see if the all the properties in the model are valid
177
+ # @return true if the model is valid
178
+ def valid?
179
+ warn '[DEPRECATED] the `valid?` method is obsolete'
180
+ true
181
+ end
182
+
183
+ # Checks equality by comparing each attribute.
184
+ # @param [Object] Object to be compared
185
+ def ==(o)
186
+ return true if self.equal?(o)
187
+ self.class == o.class &&
188
+ id == o.id &&
189
+ url == o.url &&
190
+ enabled == o.enabled &&
191
+ unsubscribed == o.unsubscribed &&
192
+ dropped == o.dropped &&
193
+ bounced == o.bounced &&
194
+ marked_spam == o.marked_spam &&
195
+ clicked == o.clicked &&
196
+ opened == o.opened &&
197
+ contact_created == o.contact_created
198
+ end
199
+
200
+ # @see the `==` method
201
+ # @param [Object] Object to be compared
202
+ def eql?(o)
203
+ self == o
204
+ end
205
+
206
+ # Calculates hash code according to all attributes.
207
+ # @return [Integer] Hash code
208
+ def hash
209
+ [id, url, enabled, unsubscribed, dropped, bounced, marked_spam, clicked, opened, contact_created].hash
210
+ end
211
+
212
+ # Builds the object from hash
213
+ # @param [Hash] attributes Model attributes in the form of hash
214
+ # @return [Object] Returns the model itself
215
+ def self.build_from_hash(attributes)
216
+ return nil unless attributes.is_a?(Hash)
217
+ attributes = attributes.transform_keys(&:to_sym)
218
+ transformed_hash = {}
219
+ openapi_types.each_pair do |key, type|
220
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
221
+ transformed_hash["#{key}"] = nil
222
+ elsif type =~ /\AArray<(.*)>/i
223
+ # check to ensure the input is an array given that the attribute
224
+ # is documented as an array but the input is not
225
+ if attributes[attribute_map[key]].is_a?(Array)
226
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
227
+ end
228
+ elsif !attributes[attribute_map[key]].nil?
229
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
230
+ end
231
+ end
232
+ new(transformed_hash)
233
+ end
234
+
235
+ # Deserializes the data based on type
236
+ # @param string type Data type
237
+ # @param string value Value to be deserialized
238
+ # @return [Object] Deserialized data
239
+ def self._deserialize(type, value)
240
+ case type.to_sym
241
+ when :Time
242
+ Time.parse(value)
243
+ when :Date
244
+ Date.parse(value)
245
+ when :String
246
+ value.to_s
247
+ when :Integer
248
+ value.to_i
249
+ when :Float
250
+ value.to_f
251
+ when :Boolean
252
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
253
+ true
254
+ else
255
+ false
256
+ end
257
+ when :Object
258
+ # generic object (usually a Hash), return directly
259
+ value
260
+ when /\AArray<(?<inner_type>.+)>\z/
261
+ inner_type = Regexp.last_match[:inner_type]
262
+ value.map { |v| _deserialize(inner_type, v) }
263
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
264
+ k_type = Regexp.last_match[:k_type]
265
+ v_type = Regexp.last_match[:v_type]
266
+ {}.tap do |hash|
267
+ value.each do |k, v|
268
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
269
+ end
270
+ end
271
+ else # model
272
+ # models (e.g. Pet) or oneOf
273
+ klass = SendX.const_get(type)
274
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
275
+ end
276
+ end
277
+
278
+ # Returns the string representation of the object
279
+ # @return [String] String presentation of the object
280
+ def to_s
281
+ to_hash.to_s
282
+ end
283
+
284
+ # to_body is an alias to to_hash (backward compatibility)
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_body
287
+ to_hash
288
+ end
289
+
290
+ # Returns the object in the form of hash
291
+ # @return [Hash] Returns the object in the form of hash
292
+ def to_hash
293
+ hash = {}
294
+ self.class.attribute_map.each_pair do |attr, param|
295
+ value = self.send(attr)
296
+ if value.nil?
297
+ is_nullable = self.class.openapi_nullable.include?(attr)
298
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
299
+ end
300
+
301
+ hash[param] = _to_hash(value)
302
+ end
303
+ hash
304
+ end
305
+
306
+ # Outputs non-array value in the form of hash
307
+ # For object, use to_hash. Otherwise, just return the value
308
+ # @param [Object] value Any valid value
309
+ # @return [Hash] Returns the value in the form of hash
310
+ def _to_hash(value)
311
+ if value.is_a?(Array)
312
+ value.compact.map { |v| _to_hash(v) }
313
+ elsif value.is_a?(Hash)
314
+ {}.tap do |hash|
315
+ value.each { |k, v| hash[k] = _to_hash(v) }
316
+ end
317
+ elsif value.respond_to? :to_hash
318
+ value.to_hash
319
+ else
320
+ value
321
+ end
322
+ end
323
+
324
+ end
325
+
326
+ end