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,391 @@
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 'cgi'
14
+
15
+ module SendX
16
+ class CustomFieldApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Create custom field
23
+ # Creates a new custom field for storing contact data.
24
+ # @param rest_e_custom_field [RestECustomField]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [RestRCustomField]
27
+ def create_custom_field(rest_e_custom_field, opts = {})
28
+ data, _status_code, _headers = create_custom_field_with_http_info(rest_e_custom_field, opts)
29
+ data
30
+ end
31
+
32
+ # Create custom field
33
+ # Creates a new custom field for storing contact data.
34
+ # @param rest_e_custom_field [RestECustomField]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(RestRCustomField, Integer, Hash)>] RestRCustomField data, response status code and response headers
37
+ def create_custom_field_with_http_info(rest_e_custom_field, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: CustomFieldApi.create_custom_field ...'
40
+ end
41
+ # verify the required parameter 'rest_e_custom_field' is set
42
+ if @api_client.config.client_side_validation && rest_e_custom_field.nil?
43
+ fail ArgumentError, "Missing the required parameter 'rest_e_custom_field' when calling CustomFieldApi.create_custom_field"
44
+ end
45
+ # resource path
46
+ local_var_path = '/customfield'
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
55
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(rest_e_custom_field)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'RestRCustomField'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"CustomFieldApi.create_custom_field",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: CustomFieldApi#create_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
90
+ # Delete custom field
91
+ # Deletes a custom field (data is preserved). **🎯 Key Features:** - Remove unused fields - Data remains on contacts - Clean up field list
92
+ # @param identifier [String] Custom field identifier to update
93
+ # @param [Hash] opts the optional parameters
94
+ # @return [DeleteResponse]
95
+ def delete_custom_field(identifier, opts = {})
96
+ data, _status_code, _headers = delete_custom_field_with_http_info(identifier, opts)
97
+ data
98
+ end
99
+
100
+ # Delete custom field
101
+ # Deletes a custom field (data is preserved). **🎯 Key Features:** - Remove unused fields - Data remains on contacts - Clean up field list
102
+ # @param identifier [String] Custom field identifier to update
103
+ # @param [Hash] opts the optional parameters
104
+ # @return [Array<(DeleteResponse, Integer, Hash)>] DeleteResponse data, response status code and response headers
105
+ def delete_custom_field_with_http_info(identifier, opts = {})
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug 'Calling API: CustomFieldApi.delete_custom_field ...'
108
+ end
109
+ # verify the required parameter 'identifier' is set
110
+ if @api_client.config.client_side_validation && identifier.nil?
111
+ fail ArgumentError, "Missing the required parameter 'identifier' when calling CustomFieldApi.delete_custom_field"
112
+ end
113
+ pattern = Regexp.new(/^(field_)?[a-zA-Z0-9]{22}$/)
114
+ if @api_client.config.client_side_validation && identifier !~ pattern
115
+ fail ArgumentError, "invalid value for 'identifier' when calling CustomFieldApi.delete_custom_field, must conform to the pattern #{pattern}."
116
+ end
117
+
118
+ # resource path
119
+ local_var_path = '/customfield/{identifier}'.sub('{' + 'identifier' + '}', CGI.escape(identifier.to_s))
120
+
121
+ # query parameters
122
+ query_params = opts[:query_params] || {}
123
+
124
+ # header parameters
125
+ header_params = opts[:header_params] || {}
126
+ # HTTP header 'Accept' (if needed)
127
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
128
+
129
+ # form parameters
130
+ form_params = opts[:form_params] || {}
131
+
132
+ # http body (model)
133
+ post_body = opts[:debug_body]
134
+
135
+ # return_type
136
+ return_type = opts[:debug_return_type] || 'DeleteResponse'
137
+
138
+ # auth_names
139
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
140
+
141
+ new_options = opts.merge(
142
+ :operation => :"CustomFieldApi.delete_custom_field",
143
+ :header_params => header_params,
144
+ :query_params => query_params,
145
+ :form_params => form_params,
146
+ :body => post_body,
147
+ :auth_names => auth_names,
148
+ :return_type => return_type
149
+ )
150
+
151
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
152
+ if @api_client.config.debugging
153
+ @api_client.config.logger.debug "API called: CustomFieldApi#delete_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
154
+ end
155
+ return data, status_code, headers
156
+ end
157
+
158
+ # Get all custom fields
159
+ # Retrieves all custom fields defined for your team.
160
+ # @param [Hash] opts the optional parameters
161
+ # @option opts [Integer] :offset Number of fields to skip for pagination (default to 0)
162
+ # @option opts [Integer] :limit Maximum number of fields to return (default to 10)
163
+ # @option opts [String] :search Search custom fields by name (case-insensitive partial matching). **Examples:** - &#x60;points&#x60; - Finds \&quot;Loyalty points\&quot;, \&quot;Reward points\&quot;
164
+ # @return [Array<RestRCustomField>]
165
+ def get_all_custom_fields(opts = {})
166
+ data, _status_code, _headers = get_all_custom_fields_with_http_info(opts)
167
+ data
168
+ end
169
+
170
+ # Get all custom fields
171
+ # Retrieves all custom fields defined for your team.
172
+ # @param [Hash] opts the optional parameters
173
+ # @option opts [Integer] :offset Number of fields to skip for pagination (default to 0)
174
+ # @option opts [Integer] :limit Maximum number of fields to return (default to 10)
175
+ # @option opts [String] :search Search custom fields by name (case-insensitive partial matching). **Examples:** - &#x60;points&#x60; - Finds \&quot;Loyalty points\&quot;, \&quot;Reward points\&quot;
176
+ # @return [Array<(Array<RestRCustomField>, Integer, Hash)>] Array<RestRCustomField> data, response status code and response headers
177
+ def get_all_custom_fields_with_http_info(opts = {})
178
+ if @api_client.config.debugging
179
+ @api_client.config.logger.debug 'Calling API: CustomFieldApi.get_all_custom_fields ...'
180
+ end
181
+ if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
182
+ fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling CustomFieldApi.get_all_custom_fields, must be greater than or equal to 0.'
183
+ end
184
+
185
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
186
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CustomFieldApi.get_all_custom_fields, must be smaller than or equal to 100.'
187
+ end
188
+
189
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
190
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CustomFieldApi.get_all_custom_fields, must be greater than or equal to 1.'
191
+ end
192
+
193
+ if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length > 100
194
+ fail ArgumentError, 'invalid value for "opts[:"search"]" when calling CustomFieldApi.get_all_custom_fields, the character length must be smaller than or equal to 100.'
195
+ end
196
+
197
+ if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length < 2
198
+ fail ArgumentError, 'invalid value for "opts[:"search"]" when calling CustomFieldApi.get_all_custom_fields, the character length must be great than or equal to 2.'
199
+ end
200
+
201
+ # resource path
202
+ local_var_path = '/customfield'
203
+
204
+ # query parameters
205
+ query_params = opts[:query_params] || {}
206
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
207
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
208
+ query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?
209
+
210
+ # header parameters
211
+ header_params = opts[:header_params] || {}
212
+ # HTTP header 'Accept' (if needed)
213
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
214
+
215
+ # form parameters
216
+ form_params = opts[:form_params] || {}
217
+
218
+ # http body (model)
219
+ post_body = opts[:debug_body]
220
+
221
+ # return_type
222
+ return_type = opts[:debug_return_type] || 'Array<RestRCustomField>'
223
+
224
+ # auth_names
225
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
226
+
227
+ new_options = opts.merge(
228
+ :operation => :"CustomFieldApi.get_all_custom_fields",
229
+ :header_params => header_params,
230
+ :query_params => query_params,
231
+ :form_params => form_params,
232
+ :body => post_body,
233
+ :auth_names => auth_names,
234
+ :return_type => return_type
235
+ )
236
+
237
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
238
+ if @api_client.config.debugging
239
+ @api_client.config.logger.debug "API called: CustomFieldApi#get_all_custom_fields\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
240
+ end
241
+ return data, status_code, headers
242
+ end
243
+
244
+ # Get custom field by ID
245
+ # Retrieves details about a specific custom field.
246
+ # @param identifier [String] Custom field identifier to update
247
+ # @param [Hash] opts the optional parameters
248
+ # @return [RestRCustomField]
249
+ def get_custom_field(identifier, opts = {})
250
+ data, _status_code, _headers = get_custom_field_with_http_info(identifier, opts)
251
+ data
252
+ end
253
+
254
+ # Get custom field by ID
255
+ # Retrieves details about a specific custom field.
256
+ # @param identifier [String] Custom field identifier to update
257
+ # @param [Hash] opts the optional parameters
258
+ # @return [Array<(RestRCustomField, Integer, Hash)>] RestRCustomField data, response status code and response headers
259
+ def get_custom_field_with_http_info(identifier, opts = {})
260
+ if @api_client.config.debugging
261
+ @api_client.config.logger.debug 'Calling API: CustomFieldApi.get_custom_field ...'
262
+ end
263
+ # verify the required parameter 'identifier' is set
264
+ if @api_client.config.client_side_validation && identifier.nil?
265
+ fail ArgumentError, "Missing the required parameter 'identifier' when calling CustomFieldApi.get_custom_field"
266
+ end
267
+ pattern = Regexp.new(/^(field_)?[a-zA-Z0-9]{22}$/)
268
+ if @api_client.config.client_side_validation && identifier !~ pattern
269
+ fail ArgumentError, "invalid value for 'identifier' when calling CustomFieldApi.get_custom_field, must conform to the pattern #{pattern}."
270
+ end
271
+
272
+ # resource path
273
+ local_var_path = '/customfield/{identifier}'.sub('{' + 'identifier' + '}', CGI.escape(identifier.to_s))
274
+
275
+ # query parameters
276
+ query_params = opts[:query_params] || {}
277
+
278
+ # header parameters
279
+ header_params = opts[:header_params] || {}
280
+ # HTTP header 'Accept' (if needed)
281
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
282
+
283
+ # form parameters
284
+ form_params = opts[:form_params] || {}
285
+
286
+ # http body (model)
287
+ post_body = opts[:debug_body]
288
+
289
+ # return_type
290
+ return_type = opts[:debug_return_type] || 'RestRCustomField'
291
+
292
+ # auth_names
293
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
294
+
295
+ new_options = opts.merge(
296
+ :operation => :"CustomFieldApi.get_custom_field",
297
+ :header_params => header_params,
298
+ :query_params => query_params,
299
+ :form_params => form_params,
300
+ :body => post_body,
301
+ :auth_names => auth_names,
302
+ :return_type => return_type
303
+ )
304
+
305
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
306
+ if @api_client.config.debugging
307
+ @api_client.config.logger.debug "API called: CustomFieldApi#get_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
308
+ end
309
+ return data, status_code, headers
310
+ end
311
+
312
+ # Update custom field
313
+ # Updates a custom field definition.
314
+ # @param rest_e_custom_field [RestECustomField]
315
+ # @param identifier [String] Custom field identifier to update
316
+ # @param [Hash] opts the optional parameters
317
+ # @return [RestRCustomField]
318
+ def update_custom_field(rest_e_custom_field, identifier, opts = {})
319
+ data, _status_code, _headers = update_custom_field_with_http_info(rest_e_custom_field, identifier, opts)
320
+ data
321
+ end
322
+
323
+ # Update custom field
324
+ # Updates a custom field definition.
325
+ # @param rest_e_custom_field [RestECustomField]
326
+ # @param identifier [String] Custom field identifier to update
327
+ # @param [Hash] opts the optional parameters
328
+ # @return [Array<(RestRCustomField, Integer, Hash)>] RestRCustomField data, response status code and response headers
329
+ def update_custom_field_with_http_info(rest_e_custom_field, identifier, opts = {})
330
+ if @api_client.config.debugging
331
+ @api_client.config.logger.debug 'Calling API: CustomFieldApi.update_custom_field ...'
332
+ end
333
+ # verify the required parameter 'rest_e_custom_field' is set
334
+ if @api_client.config.client_side_validation && rest_e_custom_field.nil?
335
+ fail ArgumentError, "Missing the required parameter 'rest_e_custom_field' when calling CustomFieldApi.update_custom_field"
336
+ end
337
+ # verify the required parameter 'identifier' is set
338
+ if @api_client.config.client_side_validation && identifier.nil?
339
+ fail ArgumentError, "Missing the required parameter 'identifier' when calling CustomFieldApi.update_custom_field"
340
+ end
341
+ pattern = Regexp.new(/^(field_)?[a-zA-Z0-9]{22}$/)
342
+ if @api_client.config.client_side_validation && identifier !~ pattern
343
+ fail ArgumentError, "invalid value for 'identifier' when calling CustomFieldApi.update_custom_field, must conform to the pattern #{pattern}."
344
+ end
345
+
346
+ # resource path
347
+ local_var_path = '/customfield/{identifier}'.sub('{' + 'identifier' + '}', CGI.escape(identifier.to_s))
348
+
349
+ # query parameters
350
+ query_params = opts[:query_params] || {}
351
+
352
+ # header parameters
353
+ header_params = opts[:header_params] || {}
354
+ # HTTP header 'Accept' (if needed)
355
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
356
+ # HTTP header 'Content-Type'
357
+ content_type = @api_client.select_header_content_type(['application/json'])
358
+ if !content_type.nil?
359
+ header_params['Content-Type'] = content_type
360
+ end
361
+
362
+ # form parameters
363
+ form_params = opts[:form_params] || {}
364
+
365
+ # http body (model)
366
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(rest_e_custom_field)
367
+
368
+ # return_type
369
+ return_type = opts[:debug_return_type] || 'RestRCustomField'
370
+
371
+ # auth_names
372
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
373
+
374
+ new_options = opts.merge(
375
+ :operation => :"CustomFieldApi.update_custom_field",
376
+ :header_params => header_params,
377
+ :query_params => query_params,
378
+ :form_params => form_params,
379
+ :body => post_body,
380
+ :auth_names => auth_names,
381
+ :return_type => return_type
382
+ )
383
+
384
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
385
+ if @api_client.config.debugging
386
+ @api_client.config.logger.debug "API called: CustomFieldApi#update_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
387
+ end
388
+ return data, status_code, headers
389
+ end
390
+ end
391
+ end
@@ -0,0 +1,158 @@
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 'cgi'
14
+
15
+ module SendX
16
+ class EmailSendingApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Send transactional email
23
+ # Sends transactional emails to specified recipients with support for personalization, attachments, and tracking.
24
+ # @param x_email_message [XEmailMessage]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [Array<XEmailResponse>]
27
+ def send_email(x_email_message, opts = {})
28
+ data, _status_code, _headers = send_email_with_http_info(x_email_message, opts)
29
+ data
30
+ end
31
+
32
+ # Send transactional email
33
+ # Sends transactional emails to specified recipients with support for personalization, attachments, and tracking.
34
+ # @param x_email_message [XEmailMessage]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(Array<XEmailResponse>, Integer, Hash)>] Array<XEmailResponse> data, response status code and response headers
37
+ def send_email_with_http_info(x_email_message, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: EmailSendingApi.send_email ...'
40
+ end
41
+ # verify the required parameter 'x_email_message' is set
42
+ if @api_client.config.client_side_validation && x_email_message.nil?
43
+ fail ArgumentError, "Missing the required parameter 'x_email_message' when calling EmailSendingApi.send_email"
44
+ end
45
+ # resource path
46
+ local_var_path = '/send/email'
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
55
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(x_email_message)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'Array<XEmailResponse>'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"EmailSendingApi.send_email",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: EmailSendingApi#send_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
90
+ # Send email using template
91
+ # Sends emails using a pre-defined template with variable substitution.
92
+ # @param template_email_message [TemplateEmailMessage]
93
+ # @param [Hash] opts the optional parameters
94
+ # @return [Array<XEmailResponse>]
95
+ def send_email_with_template(template_email_message, opts = {})
96
+ data, _status_code, _headers = send_email_with_template_with_http_info(template_email_message, opts)
97
+ data
98
+ end
99
+
100
+ # Send email using template
101
+ # Sends emails using a pre-defined template with variable substitution.
102
+ # @param template_email_message [TemplateEmailMessage]
103
+ # @param [Hash] opts the optional parameters
104
+ # @return [Array<(Array<XEmailResponse>, Integer, Hash)>] Array<XEmailResponse> data, response status code and response headers
105
+ def send_email_with_template_with_http_info(template_email_message, opts = {})
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug 'Calling API: EmailSendingApi.send_email_with_template ...'
108
+ end
109
+ # verify the required parameter 'template_email_message' is set
110
+ if @api_client.config.client_side_validation && template_email_message.nil?
111
+ fail ArgumentError, "Missing the required parameter 'template_email_message' when calling EmailSendingApi.send_email_with_template"
112
+ end
113
+ # resource path
114
+ local_var_path = '/send/template'
115
+
116
+ # query parameters
117
+ query_params = opts[:query_params] || {}
118
+
119
+ # header parameters
120
+ header_params = opts[:header_params] || {}
121
+ # HTTP header 'Accept' (if needed)
122
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
123
+ # HTTP header 'Content-Type'
124
+ content_type = @api_client.select_header_content_type(['application/json'])
125
+ if !content_type.nil?
126
+ header_params['Content-Type'] = content_type
127
+ end
128
+
129
+ # form parameters
130
+ form_params = opts[:form_params] || {}
131
+
132
+ # http body (model)
133
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(template_email_message)
134
+
135
+ # return_type
136
+ return_type = opts[:debug_return_type] || 'Array<XEmailResponse>'
137
+
138
+ # auth_names
139
+ auth_names = opts[:debug_auth_names] || ['TeamApiKey']
140
+
141
+ new_options = opts.merge(
142
+ :operation => :"EmailSendingApi.send_email_with_template",
143
+ :header_params => header_params,
144
+ :query_params => query_params,
145
+ :form_params => form_params,
146
+ :body => post_body,
147
+ :auth_names => auth_names,
148
+ :return_type => return_type
149
+ )
150
+
151
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
152
+ if @api_client.config.debugging
153
+ @api_client.config.logger.debug "API called: EmailSendingApi#send_email_with_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
154
+ end
155
+ return data, status_code, headers
156
+ end
157
+ end
158
+ end