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,312 @@
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 RestReportData
18
+ # Unique identifier of the campaign
19
+ attr_accessor :campaign_id
20
+
21
+ attr_accessor :link_stats
22
+
23
+ # Total number of unique contacts who clicked on the link
24
+ attr_accessor :clicked_unique_contact_count
25
+
26
+ # Total number of unique contacts who opened the link
27
+ attr_accessor :opened_unique_contact_count
28
+
29
+ # Total number of contacts who sent the link
30
+ attr_accessor :sent_contact_count
31
+
32
+ # Total number of contacts who unsubscribed from the link
33
+ attr_accessor :unsubscribe_contact_count
34
+
35
+ # Total number of contacts who bounced the link
36
+ attr_accessor :bounce_contact_count
37
+
38
+ # Total number of contacts who marked the link as spam
39
+ attr_accessor :spam_contact_count
40
+
41
+ # Total number of contacts who clicked on the link
42
+ attr_accessor :clicked_contact_count
43
+
44
+ # Total number of contacts who opened the link
45
+ attr_accessor :opened_contact_count
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'campaign_id' => :'campaignId',
51
+ :'link_stats' => :'linkStats',
52
+ :'clicked_unique_contact_count' => :'clickedUniqueContactCount',
53
+ :'opened_unique_contact_count' => :'openedUniqueContactCount',
54
+ :'sent_contact_count' => :'sentContactCount',
55
+ :'unsubscribe_contact_count' => :'unsubscribeContactCount',
56
+ :'bounce_contact_count' => :'bounceContactCount',
57
+ :'spam_contact_count' => :'spamContactCount',
58
+ :'clicked_contact_count' => :'clickedContactCount',
59
+ :'opened_contact_count' => :'openedContactCount'
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
+ :'campaign_id' => :'String',
77
+ :'link_stats' => :'Array<LinkStat>',
78
+ :'clicked_unique_contact_count' => :'Integer',
79
+ :'opened_unique_contact_count' => :'Integer',
80
+ :'sent_contact_count' => :'Integer',
81
+ :'unsubscribe_contact_count' => :'Integer',
82
+ :'bounce_contact_count' => :'Integer',
83
+ :'spam_contact_count' => :'Integer',
84
+ :'clicked_contact_count' => :'Integer',
85
+ :'opened_contact_count' => :'Integer'
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::RestReportData` 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::RestReportData`. 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?(:'campaign_id')
112
+ self.campaign_id = attributes[:'campaign_id']
113
+ end
114
+
115
+ if attributes.key?(:'link_stats')
116
+ if (value = attributes[:'link_stats']).is_a?(Array)
117
+ self.link_stats = value
118
+ end
119
+ end
120
+
121
+ if attributes.key?(:'clicked_unique_contact_count')
122
+ self.clicked_unique_contact_count = attributes[:'clicked_unique_contact_count']
123
+ end
124
+
125
+ if attributes.key?(:'opened_unique_contact_count')
126
+ self.opened_unique_contact_count = attributes[:'opened_unique_contact_count']
127
+ end
128
+
129
+ if attributes.key?(:'sent_contact_count')
130
+ self.sent_contact_count = attributes[:'sent_contact_count']
131
+ end
132
+
133
+ if attributes.key?(:'unsubscribe_contact_count')
134
+ self.unsubscribe_contact_count = attributes[:'unsubscribe_contact_count']
135
+ end
136
+
137
+ if attributes.key?(:'bounce_contact_count')
138
+ self.bounce_contact_count = attributes[:'bounce_contact_count']
139
+ end
140
+
141
+ if attributes.key?(:'spam_contact_count')
142
+ self.spam_contact_count = attributes[:'spam_contact_count']
143
+ end
144
+
145
+ if attributes.key?(:'clicked_contact_count')
146
+ self.clicked_contact_count = attributes[:'clicked_contact_count']
147
+ end
148
+
149
+ if attributes.key?(:'opened_contact_count')
150
+ self.opened_contact_count = attributes[:'opened_contact_count']
151
+ end
152
+ end
153
+
154
+ # Show invalid properties with the reasons. Usually used together with valid?
155
+ # @return Array for valid properties with the reasons
156
+ def list_invalid_properties
157
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
158
+ invalid_properties = Array.new
159
+ invalid_properties
160
+ end
161
+
162
+ # Check to see if the all the properties in the model are valid
163
+ # @return true if the model is valid
164
+ def valid?
165
+ warn '[DEPRECATED] the `valid?` method is obsolete'
166
+ true
167
+ end
168
+
169
+ # Checks equality by comparing each attribute.
170
+ # @param [Object] Object to be compared
171
+ def ==(o)
172
+ return true if self.equal?(o)
173
+ self.class == o.class &&
174
+ campaign_id == o.campaign_id &&
175
+ link_stats == o.link_stats &&
176
+ clicked_unique_contact_count == o.clicked_unique_contact_count &&
177
+ opened_unique_contact_count == o.opened_unique_contact_count &&
178
+ sent_contact_count == o.sent_contact_count &&
179
+ unsubscribe_contact_count == o.unsubscribe_contact_count &&
180
+ bounce_contact_count == o.bounce_contact_count &&
181
+ spam_contact_count == o.spam_contact_count &&
182
+ clicked_contact_count == o.clicked_contact_count &&
183
+ opened_contact_count == o.opened_contact_count
184
+ end
185
+
186
+ # @see the `==` method
187
+ # @param [Object] Object to be compared
188
+ def eql?(o)
189
+ self == o
190
+ end
191
+
192
+ # Calculates hash code according to all attributes.
193
+ # @return [Integer] Hash code
194
+ def hash
195
+ [campaign_id, link_stats, clicked_unique_contact_count, opened_unique_contact_count, sent_contact_count, unsubscribe_contact_count, bounce_contact_count, spam_contact_count, clicked_contact_count, opened_contact_count].hash
196
+ end
197
+
198
+ # Builds the object from hash
199
+ # @param [Hash] attributes Model attributes in the form of hash
200
+ # @return [Object] Returns the model itself
201
+ def self.build_from_hash(attributes)
202
+ return nil unless attributes.is_a?(Hash)
203
+ attributes = attributes.transform_keys(&:to_sym)
204
+ transformed_hash = {}
205
+ openapi_types.each_pair do |key, type|
206
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
207
+ transformed_hash["#{key}"] = nil
208
+ elsif type =~ /\AArray<(.*)>/i
209
+ # check to ensure the input is an array given that the attribute
210
+ # is documented as an array but the input is not
211
+ if attributes[attribute_map[key]].is_a?(Array)
212
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
213
+ end
214
+ elsif !attributes[attribute_map[key]].nil?
215
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
216
+ end
217
+ end
218
+ new(transformed_hash)
219
+ end
220
+
221
+ # Deserializes the data based on type
222
+ # @param string type Data type
223
+ # @param string value Value to be deserialized
224
+ # @return [Object] Deserialized data
225
+ def self._deserialize(type, value)
226
+ case type.to_sym
227
+ when :Time
228
+ Time.parse(value)
229
+ when :Date
230
+ Date.parse(value)
231
+ when :String
232
+ value.to_s
233
+ when :Integer
234
+ value.to_i
235
+ when :Float
236
+ value.to_f
237
+ when :Boolean
238
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
239
+ true
240
+ else
241
+ false
242
+ end
243
+ when :Object
244
+ # generic object (usually a Hash), return directly
245
+ value
246
+ when /\AArray<(?<inner_type>.+)>\z/
247
+ inner_type = Regexp.last_match[:inner_type]
248
+ value.map { |v| _deserialize(inner_type, v) }
249
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
250
+ k_type = Regexp.last_match[:k_type]
251
+ v_type = Regexp.last_match[:v_type]
252
+ {}.tap do |hash|
253
+ value.each do |k, v|
254
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
255
+ end
256
+ end
257
+ else # model
258
+ # models (e.g. Pet) or oneOf
259
+ klass = SendX.const_get(type)
260
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
261
+ end
262
+ end
263
+
264
+ # Returns the string representation of the object
265
+ # @return [String] String presentation of the object
266
+ def to_s
267
+ to_hash.to_s
268
+ end
269
+
270
+ # to_body is an alias to to_hash (backward compatibility)
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_body
273
+ to_hash
274
+ end
275
+
276
+ # Returns the object in the form of hash
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_hash
279
+ hash = {}
280
+ self.class.attribute_map.each_pair do |attr, param|
281
+ value = self.send(attr)
282
+ if value.nil?
283
+ is_nullable = self.class.openapi_nullable.include?(attr)
284
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
285
+ end
286
+
287
+ hash[param] = _to_hash(value)
288
+ end
289
+ hash
290
+ end
291
+
292
+ # Outputs non-array value in the form of hash
293
+ # For object, use to_hash. Otherwise, just return the value
294
+ # @param [Object] value Any valid value
295
+ # @return [Hash] Returns the value in the form of hash
296
+ def _to_hash(value)
297
+ if value.is_a?(Array)
298
+ value.compact.map { |v| _to_hash(v) }
299
+ elsif value.is_a?(Hash)
300
+ {}.tap do |hash|
301
+ value.each { |k, v| hash[k] = _to_hash(v) }
302
+ end
303
+ elsif value.respond_to? :to_hash
304
+ value.to_hash
305
+ else
306
+ value
307
+ end
308
+ end
309
+
310
+ end
311
+
312
+ end
@@ -0,0 +1,285 @@
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 RevenueEventRequest
18
+ # Contact email address
19
+ attr_accessor :identifier
20
+
21
+ # Revenue amount
22
+ attr_accessor :amount
23
+
24
+ # Source of the revenue event
25
+ attr_accessor :source
26
+
27
+ # Unix timestamp (in seconds since January 1, 1970) representing when the event occurred.
28
+ attr_accessor :time
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'identifier' => :'identifier',
34
+ :'amount' => :'amount',
35
+ :'source' => :'source',
36
+ :'time' => :'time'
37
+ }
38
+ end
39
+
40
+ # Returns attribute mapping this model knows about
41
+ def self.acceptable_attribute_map
42
+ attribute_map
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ acceptable_attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'identifier' => :'String',
54
+ :'amount' => :'Float',
55
+ :'source' => :'String',
56
+ :'time' => :'Integer'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::RevenueEventRequest` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ acceptable_attribute_map = self.class.acceptable_attribute_map
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!acceptable_attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::RevenueEventRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'identifier')
83
+ self.identifier = attributes[:'identifier']
84
+ else
85
+ self.identifier = nil
86
+ end
87
+
88
+ if attributes.key?(:'amount')
89
+ self.amount = attributes[:'amount']
90
+ else
91
+ self.amount = nil
92
+ end
93
+
94
+ if attributes.key?(:'source')
95
+ self.source = attributes[:'source']
96
+ end
97
+
98
+ if attributes.key?(:'time')
99
+ self.time = attributes[:'time']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ if @identifier.nil?
109
+ invalid_properties.push('invalid value for "identifier", identifier cannot be nil.')
110
+ end
111
+
112
+ if @amount.nil?
113
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
114
+ end
115
+
116
+ invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ warn '[DEPRECATED] the `valid?` method is obsolete'
123
+ return false if @identifier.nil?
124
+ return false if @amount.nil?
125
+ true
126
+ end
127
+
128
+ # Custom attribute writer method with validation
129
+ # @param [Object] identifier Value to be assigned
130
+ def identifier=(identifier)
131
+ if identifier.nil?
132
+ fail ArgumentError, 'identifier cannot be nil'
133
+ end
134
+
135
+ @identifier = identifier
136
+ end
137
+
138
+ # Custom attribute writer method with validation
139
+ # @param [Object] amount Value to be assigned
140
+ def amount=(amount)
141
+ if amount.nil?
142
+ fail ArgumentError, 'amount cannot be nil'
143
+ end
144
+
145
+ @amount = amount
146
+ end
147
+
148
+ # Checks equality by comparing each attribute.
149
+ # @param [Object] Object to be compared
150
+ def ==(o)
151
+ return true if self.equal?(o)
152
+ self.class == o.class &&
153
+ identifier == o.identifier &&
154
+ amount == o.amount &&
155
+ source == o.source &&
156
+ time == o.time
157
+ end
158
+
159
+ # @see the `==` method
160
+ # @param [Object] Object to be compared
161
+ def eql?(o)
162
+ self == o
163
+ end
164
+
165
+ # Calculates hash code according to all attributes.
166
+ # @return [Integer] Hash code
167
+ def hash
168
+ [identifier, amount, source, time].hash
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def self.build_from_hash(attributes)
175
+ return nil unless attributes.is_a?(Hash)
176
+ attributes = attributes.transform_keys(&:to_sym)
177
+ transformed_hash = {}
178
+ openapi_types.each_pair do |key, type|
179
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
180
+ transformed_hash["#{key}"] = nil
181
+ elsif type =~ /\AArray<(.*)>/i
182
+ # check to ensure the input is an array given that the attribute
183
+ # is documented as an array but the input is not
184
+ if attributes[attribute_map[key]].is_a?(Array)
185
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
186
+ end
187
+ elsif !attributes[attribute_map[key]].nil?
188
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
189
+ end
190
+ end
191
+ new(transformed_hash)
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def self._deserialize(type, value)
199
+ case type.to_sym
200
+ when :Time
201
+ Time.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :Boolean
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ # models (e.g. Pet) or oneOf
232
+ klass = SendX.const_get(type)
233
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
234
+ end
235
+ end
236
+
237
+ # Returns the string representation of the object
238
+ # @return [String] String presentation of the object
239
+ def to_s
240
+ to_hash.to_s
241
+ end
242
+
243
+ # to_body is an alias to to_hash (backward compatibility)
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_body
246
+ to_hash
247
+ end
248
+
249
+ # Returns the object in the form of hash
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_hash
252
+ hash = {}
253
+ self.class.attribute_map.each_pair do |attr, param|
254
+ value = self.send(attr)
255
+ if value.nil?
256
+ is_nullable = self.class.openapi_nullable.include?(attr)
257
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
258
+ end
259
+
260
+ hash[param] = _to_hash(value)
261
+ end
262
+ hash
263
+ end
264
+
265
+ # Outputs non-array value in the form of hash
266
+ # For object, use to_hash. Otherwise, just return the value
267
+ # @param [Object] value Any valid value
268
+ # @return [Hash] Returns the value in the form of hash
269
+ def _to_hash(value)
270
+ if value.is_a?(Array)
271
+ value.compact.map { |v| _to_hash(v) }
272
+ elsif value.is_a?(Hash)
273
+ {}.tap do |hash|
274
+ value.each { |k, v| hash[k] = _to_hash(v) }
275
+ end
276
+ elsif value.respond_to? :to_hash
277
+ value.to_hash
278
+ else
279
+ value
280
+ end
281
+ end
282
+
283
+ end
284
+
285
+ end