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,438 @@
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 RestRContact
18
+ # Unique contact identifier with contact_ prefix. **Format:** `contact_` + 22 alphanumeric characters **Usage:** - Use this ID for all subsequent API calls - Unique across the entire SendX platform - Never changes once created
19
+ attr_accessor :id
20
+
21
+ # First name of the contact
22
+ attr_accessor :first_name
23
+
24
+ # Last name of the contact
25
+ attr_accessor :last_name
26
+
27
+ # Email address of the contact (unique within team)
28
+ attr_accessor :email
29
+
30
+ # Company name of the contact
31
+ attr_accessor :company
32
+
33
+ # Custom fields with field_ prefixed keys. **Format:** All keys have `field_` prefix in responses **Example Structure:** ```json { \"field_MnuqBAG2NPLm7PZMWbjQxt\": \"Engineering\", \"field_QqfhckbdcvQinLPlduIbHq\": \"Senior\", \"field_MnuqBAG2NPLm7PZMWbjQxt\": \"$75000\" } ```
34
+ attr_accessor :custom_fields
35
+
36
+ # Associated lists with list_ prefixed identifiers. **Format:** All IDs have `list_` prefix in responses
37
+ attr_accessor :lists
38
+
39
+ # Associated tags with tag_ prefixed identifiers. **Format:** All IDs have `tag_` prefix in responses
40
+ attr_accessor :tags
41
+
42
+ # Whether the contact has unsubscribed from emails
43
+ attr_accessor :unsubscribed
44
+
45
+ # Whether emails to this contact have bounced
46
+ attr_accessor :bounced
47
+
48
+ # Whether the contact has marked emails as spam
49
+ attr_accessor :spam
50
+
51
+ # Whether the contact is blocked from receiving emails
52
+ attr_accessor :blocked
53
+
54
+ # Whether emails to this contact have been dropped
55
+ attr_accessor :dropped
56
+
57
+ # Contact creation timestamp (ISO 8601 format)
58
+ attr_accessor :created
59
+
60
+ # Contact last update timestamp (ISO 8601 format)
61
+ attr_accessor :updated
62
+
63
+ # Email tracking data and UTM parameters. **Contains:** - UTM parameters from campaigns - Attribution data - Custom tracking parameters
64
+ attr_accessor :track_data
65
+
66
+ # Source type of the contact creation. **Values:** - `1` - API/Manual - `2` - Import - `3` - Form - `4` - Integration
67
+ attr_accessor :contact_source
68
+
69
+ # URL of the page where contact was created
70
+ attr_accessor :page_source
71
+
72
+ # Last tracked IP address of the contact
73
+ attr_accessor :last_tracked_ip
74
+
75
+ # Lifetime Value of the contact in cents. **Example:** 7500 = $75.00
76
+ attr_accessor :ltv
77
+
78
+ # Attribute mapping from ruby-style variable name to JSON key.
79
+ def self.attribute_map
80
+ {
81
+ :'id' => :'id',
82
+ :'first_name' => :'firstName',
83
+ :'last_name' => :'lastName',
84
+ :'email' => :'email',
85
+ :'company' => :'company',
86
+ :'custom_fields' => :'customFields',
87
+ :'lists' => :'lists',
88
+ :'tags' => :'tags',
89
+ :'unsubscribed' => :'unsubscribed',
90
+ :'bounced' => :'bounced',
91
+ :'spam' => :'spam',
92
+ :'blocked' => :'blocked',
93
+ :'dropped' => :'dropped',
94
+ :'created' => :'created',
95
+ :'updated' => :'updated',
96
+ :'track_data' => :'trackData',
97
+ :'contact_source' => :'contactSource',
98
+ :'page_source' => :'pageSource',
99
+ :'last_tracked_ip' => :'lastTrackedIp',
100
+ :'ltv' => :'LTV'
101
+ }
102
+ end
103
+
104
+ # Returns attribute mapping this model knows about
105
+ def self.acceptable_attribute_map
106
+ attribute_map
107
+ end
108
+
109
+ # Returns all the JSON keys this model knows about
110
+ def self.acceptable_attributes
111
+ acceptable_attribute_map.values
112
+ end
113
+
114
+ # Attribute type mapping.
115
+ def self.openapi_types
116
+ {
117
+ :'id' => :'String',
118
+ :'first_name' => :'String',
119
+ :'last_name' => :'String',
120
+ :'email' => :'String',
121
+ :'company' => :'String',
122
+ :'custom_fields' => :'Hash<String, String>',
123
+ :'lists' => :'Array<String>',
124
+ :'tags' => :'Array<String>',
125
+ :'unsubscribed' => :'Boolean',
126
+ :'bounced' => :'Boolean',
127
+ :'spam' => :'Boolean',
128
+ :'blocked' => :'Boolean',
129
+ :'dropped' => :'Boolean',
130
+ :'created' => :'Time',
131
+ :'updated' => :'Time',
132
+ :'track_data' => :'String',
133
+ :'contact_source' => :'Integer',
134
+ :'page_source' => :'String',
135
+ :'last_tracked_ip' => :'String',
136
+ :'ltv' => :'Integer'
137
+ }
138
+ end
139
+
140
+ # List of attributes with nullable: true
141
+ def self.openapi_nullable
142
+ Set.new([
143
+ ])
144
+ end
145
+
146
+ # Initializes the object
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ def initialize(attributes = {})
149
+ if (!attributes.is_a?(Hash))
150
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::RestRContact` initialize method"
151
+ end
152
+
153
+ # check to see if the attribute exists and convert string to symbol for hash key
154
+ acceptable_attribute_map = self.class.acceptable_attribute_map
155
+ attributes = attributes.each_with_object({}) { |(k, v), h|
156
+ if (!acceptable_attribute_map.key?(k.to_sym))
157
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::RestRContact`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
158
+ end
159
+ h[k.to_sym] = v
160
+ }
161
+
162
+ if attributes.key?(:'id')
163
+ self.id = attributes[:'id']
164
+ end
165
+
166
+ if attributes.key?(:'first_name')
167
+ self.first_name = attributes[:'first_name']
168
+ end
169
+
170
+ if attributes.key?(:'last_name')
171
+ self.last_name = attributes[:'last_name']
172
+ end
173
+
174
+ if attributes.key?(:'email')
175
+ self.email = attributes[:'email']
176
+ end
177
+
178
+ if attributes.key?(:'company')
179
+ self.company = attributes[:'company']
180
+ end
181
+
182
+ if attributes.key?(:'custom_fields')
183
+ if (value = attributes[:'custom_fields']).is_a?(Hash)
184
+ self.custom_fields = value
185
+ end
186
+ end
187
+
188
+ if attributes.key?(:'lists')
189
+ if (value = attributes[:'lists']).is_a?(Array)
190
+ self.lists = value
191
+ end
192
+ end
193
+
194
+ if attributes.key?(:'tags')
195
+ if (value = attributes[:'tags']).is_a?(Array)
196
+ self.tags = value
197
+ end
198
+ end
199
+
200
+ if attributes.key?(:'unsubscribed')
201
+ self.unsubscribed = attributes[:'unsubscribed']
202
+ end
203
+
204
+ if attributes.key?(:'bounced')
205
+ self.bounced = attributes[:'bounced']
206
+ end
207
+
208
+ if attributes.key?(:'spam')
209
+ self.spam = attributes[:'spam']
210
+ end
211
+
212
+ if attributes.key?(:'blocked')
213
+ self.blocked = attributes[:'blocked']
214
+ end
215
+
216
+ if attributes.key?(:'dropped')
217
+ self.dropped = attributes[:'dropped']
218
+ end
219
+
220
+ if attributes.key?(:'created')
221
+ self.created = attributes[:'created']
222
+ end
223
+
224
+ if attributes.key?(:'updated')
225
+ self.updated = attributes[:'updated']
226
+ end
227
+
228
+ if attributes.key?(:'track_data')
229
+ self.track_data = attributes[:'track_data']
230
+ end
231
+
232
+ if attributes.key?(:'contact_source')
233
+ self.contact_source = attributes[:'contact_source']
234
+ end
235
+
236
+ if attributes.key?(:'page_source')
237
+ self.page_source = attributes[:'page_source']
238
+ end
239
+
240
+ if attributes.key?(:'last_tracked_ip')
241
+ self.last_tracked_ip = attributes[:'last_tracked_ip']
242
+ end
243
+
244
+ if attributes.key?(:'ltv')
245
+ self.ltv = attributes[:'ltv']
246
+ end
247
+ end
248
+
249
+ # Show invalid properties with the reasons. Usually used together with valid?
250
+ # @return Array for valid properties with the reasons
251
+ def list_invalid_properties
252
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
253
+ invalid_properties = Array.new
254
+ pattern = Regexp.new(/^contact_[a-zA-Z0-9]{22}$/)
255
+ if !@id.nil? && @id !~ pattern
256
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
257
+ end
258
+
259
+ invalid_properties
260
+ end
261
+
262
+ # Check to see if the all the properties in the model are valid
263
+ # @return true if the model is valid
264
+ def valid?
265
+ warn '[DEPRECATED] the `valid?` method is obsolete'
266
+ return false if !@id.nil? && @id !~ Regexp.new(/^contact_[a-zA-Z0-9]{22}$/)
267
+ true
268
+ end
269
+
270
+ # Custom attribute writer method with validation
271
+ # @param [Object] id Value to be assigned
272
+ def id=(id)
273
+ if id.nil?
274
+ fail ArgumentError, 'id cannot be nil'
275
+ end
276
+
277
+ pattern = Regexp.new(/^contact_[a-zA-Z0-9]{22}$/)
278
+ if id !~ pattern
279
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
280
+ end
281
+
282
+ @id = id
283
+ end
284
+
285
+ # Checks equality by comparing each attribute.
286
+ # @param [Object] Object to be compared
287
+ def ==(o)
288
+ return true if self.equal?(o)
289
+ self.class == o.class &&
290
+ id == o.id &&
291
+ first_name == o.first_name &&
292
+ last_name == o.last_name &&
293
+ email == o.email &&
294
+ company == o.company &&
295
+ custom_fields == o.custom_fields &&
296
+ lists == o.lists &&
297
+ tags == o.tags &&
298
+ unsubscribed == o.unsubscribed &&
299
+ bounced == o.bounced &&
300
+ spam == o.spam &&
301
+ blocked == o.blocked &&
302
+ dropped == o.dropped &&
303
+ created == o.created &&
304
+ updated == o.updated &&
305
+ track_data == o.track_data &&
306
+ contact_source == o.contact_source &&
307
+ page_source == o.page_source &&
308
+ last_tracked_ip == o.last_tracked_ip &&
309
+ ltv == o.ltv
310
+ end
311
+
312
+ # @see the `==` method
313
+ # @param [Object] Object to be compared
314
+ def eql?(o)
315
+ self == o
316
+ end
317
+
318
+ # Calculates hash code according to all attributes.
319
+ # @return [Integer] Hash code
320
+ def hash
321
+ [id, first_name, last_name, email, company, custom_fields, lists, tags, unsubscribed, bounced, spam, blocked, dropped, created, updated, track_data, contact_source, page_source, last_tracked_ip, ltv].hash
322
+ end
323
+
324
+ # Builds the object from hash
325
+ # @param [Hash] attributes Model attributes in the form of hash
326
+ # @return [Object] Returns the model itself
327
+ def self.build_from_hash(attributes)
328
+ return nil unless attributes.is_a?(Hash)
329
+ attributes = attributes.transform_keys(&:to_sym)
330
+ transformed_hash = {}
331
+ openapi_types.each_pair do |key, type|
332
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
333
+ transformed_hash["#{key}"] = nil
334
+ elsif type =~ /\AArray<(.*)>/i
335
+ # check to ensure the input is an array given that the attribute
336
+ # is documented as an array but the input is not
337
+ if attributes[attribute_map[key]].is_a?(Array)
338
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
339
+ end
340
+ elsif !attributes[attribute_map[key]].nil?
341
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
342
+ end
343
+ end
344
+ new(transformed_hash)
345
+ end
346
+
347
+ # Deserializes the data based on type
348
+ # @param string type Data type
349
+ # @param string value Value to be deserialized
350
+ # @return [Object] Deserialized data
351
+ def self._deserialize(type, value)
352
+ case type.to_sym
353
+ when :Time
354
+ Time.parse(value)
355
+ when :Date
356
+ Date.parse(value)
357
+ when :String
358
+ value.to_s
359
+ when :Integer
360
+ value.to_i
361
+ when :Float
362
+ value.to_f
363
+ when :Boolean
364
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
365
+ true
366
+ else
367
+ false
368
+ end
369
+ when :Object
370
+ # generic object (usually a Hash), return directly
371
+ value
372
+ when /\AArray<(?<inner_type>.+)>\z/
373
+ inner_type = Regexp.last_match[:inner_type]
374
+ value.map { |v| _deserialize(inner_type, v) }
375
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
376
+ k_type = Regexp.last_match[:k_type]
377
+ v_type = Regexp.last_match[:v_type]
378
+ {}.tap do |hash|
379
+ value.each do |k, v|
380
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
381
+ end
382
+ end
383
+ else # model
384
+ # models (e.g. Pet) or oneOf
385
+ klass = SendX.const_get(type)
386
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
387
+ end
388
+ end
389
+
390
+ # Returns the string representation of the object
391
+ # @return [String] String presentation of the object
392
+ def to_s
393
+ to_hash.to_s
394
+ end
395
+
396
+ # to_body is an alias to to_hash (backward compatibility)
397
+ # @return [Hash] Returns the object in the form of hash
398
+ def to_body
399
+ to_hash
400
+ end
401
+
402
+ # Returns the object in the form of hash
403
+ # @return [Hash] Returns the object in the form of hash
404
+ def to_hash
405
+ hash = {}
406
+ self.class.attribute_map.each_pair do |attr, param|
407
+ value = self.send(attr)
408
+ if value.nil?
409
+ is_nullable = self.class.openapi_nullable.include?(attr)
410
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
411
+ end
412
+
413
+ hash[param] = _to_hash(value)
414
+ end
415
+ hash
416
+ end
417
+
418
+ # Outputs non-array value in the form of hash
419
+ # For object, use to_hash. Otherwise, just return the value
420
+ # @param [Object] value Any valid value
421
+ # @return [Hash] Returns the value in the form of hash
422
+ def _to_hash(value)
423
+ if value.is_a?(Array)
424
+ value.compact.map { |v| _to_hash(v) }
425
+ elsif value.is_a?(Hash)
426
+ {}.tap do |hash|
427
+ value.each { |k, v| hash[k] = _to_hash(v) }
428
+ end
429
+ elsif value.respond_to? :to_hash
430
+ value.to_hash
431
+ else
432
+ value
433
+ end
434
+ end
435
+
436
+ end
437
+
438
+ end