repull 0.2.33 → 0.2.35

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/repull/api/connect_api.rb +4 -4
  3. data/lib/repull/api/health_api.rb +3 -3
  4. data/lib/repull/api/promotions_api.rb +574 -0
  5. data/lib/repull/models/connect_session_completed_payload.rb +1 -1
  6. data/lib/repull/models/connect_status_accounts_inner.rb +12 -1
  7. data/lib/repull/models/create_connect_session_request.rb +25 -1
  8. data/lib/repull/models/create_connection_request.rb +2 -22
  9. data/lib/repull/models/list_connection_units200_response.rb +12 -1
  10. data/lib/repull/models/list_connection_units200_response_units_inner.rb +1 -0
  11. data/lib/repull/models/listing_address.rb +62 -5
  12. data/lib/repull/models/listing_updated_payload.rb +2 -2
  13. data/lib/repull/models/message.rb +24 -1
  14. data/lib/repull/models/postal_address.rb +216 -0
  15. data/lib/repull/models/promotion.rb +344 -0
  16. data/lib/repull/models/promotion_applies_to.rb +161 -0
  17. data/lib/repull/models/promotion_bulk_request.rb +236 -0
  18. data/lib/repull/models/{plumguide_listing_list_response.rb → promotion_bulk_response.rb} +11 -11
  19. data/lib/repull/models/{calendar_updated_payload.rb → promotion_bulk_response_data_inner.rb} +23 -33
  20. data/lib/repull/models/promotion_bulk_response_data_inner_error.rb +165 -0
  21. data/lib/repull/models/promotion_bulk_response_summary.rb +156 -0
  22. data/lib/repull/models/{plumguide_listing.rb → promotion_catalog.rb} +18 -27
  23. data/lib/repull/models/promotion_catalog_channels_inner.rb +222 -0
  24. data/lib/repull/models/promotion_catalog_entry.rb +265 -0
  25. data/lib/repull/models/promotion_catalog_field.rb +205 -0
  26. data/lib/repull/models/{calendar_updated_payload_range.rb → promotion_catalog_field_options_inner.rb} +16 -16
  27. data/lib/repull/models/promotion_catalog_response.rb +147 -0
  28. data/lib/repull/models/promotion_create_request.rb +258 -0
  29. data/lib/repull/models/promotion_delete_response.rb +147 -0
  30. data/lib/repull/models/promotion_delete_response_data.rb +156 -0
  31. data/lib/repull/models/promotion_discount.rb +191 -0
  32. data/lib/repull/models/promotion_input.rb +241 -0
  33. data/lib/repull/models/promotion_list_response.rb +170 -0
  34. data/lib/repull/models/promotion_refresh_response.rb +170 -0
  35. data/lib/repull/models/promotion_response.rb +147 -0
  36. data/lib/repull/models/{calendar_updated_event.rb → promotion_rules.rb} +113 -104
  37. data/lib/repull/models/promotion_rules_blackout_dates_quota.rb +156 -0
  38. data/lib/repull/models/promotion_rules_booking_window.rb +230 -0
  39. data/lib/repull/models/promotion_rules_last_minute.rb +218 -0
  40. data/lib/repull/models/promotion_rules_stay_window.rb +211 -0
  41. data/lib/repull/models/promotion_type.rb +47 -0
  42. data/lib/repull/models/promotion_update_request.rb +175 -0
  43. data/lib/repull/models/promotion_usage.rb +193 -0
  44. data/lib/repull/models/promotion_usage_revenue.rb +156 -0
  45. data/lib/repull/models/property.rb +12 -2
  46. data/lib/repull/models/reservation_money_line.rb +14 -4
  47. data/lib/repull/models/webhook_event.rb +0 -2
  48. data/lib/repull/models/webhook_event_type.rb +1 -2
  49. data/lib/repull/version.rb +1 -1
  50. data/lib/repull.rb +32 -6
  51. data/openapi/v1.json +1193 -357
  52. data/scripts/regen.sh +1 -1
  53. metadata +34 -8
  54. data/lib/repull/api/plumguide_api.rb +0 -552
@@ -14,31 +14,44 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Repull
17
- class CalendarUpdatedEvent < ApiModelBase
18
- # The event name. This field is `event`, not `type`.
19
- attr_accessor :event
17
+ # Which rules a type supports depends on the channel — see the catalog.
18
+ class PromotionRules < ApiModelBase
19
+ # Booking.com campaigns: `black_friday`, `getaway`, `late_escape`, `early_year`.
20
+ attr_accessor :campaign
20
21
 
21
- # Stable across every delivery and replay of this logical event — dedupe on it.
22
- attr_accessor :event_id
22
+ # `public`, `subscribers` (members only, at least 10%), `app`, `all` (app and mobile web), or a country id from the catalog (e.g. `united_kingdom_pos`).
23
+ attr_accessor :audience
23
24
 
24
- attr_accessor :api_version
25
+ attr_accessor :stay_window
25
26
 
26
- # When this delivery was built.
27
- attr_accessor :timestamp
27
+ attr_accessor :booking_window
28
28
 
29
- attr_accessor :account
29
+ attr_accessor :last_minute
30
30
 
31
- attr_accessor :data
31
+ attr_accessor :early_booker_days
32
+
33
+ attr_accessor :min_nights
34
+
35
+ attr_accessor :non_refundable
36
+
37
+ # Airbnb — not yet available.
38
+ attr_accessor :blackout_dates
39
+
40
+ attr_accessor :blackout_dates_quota
32
41
 
33
42
  # Attribute mapping from ruby-style variable name to JSON key.
34
43
  def self.attribute_map
35
44
  {
36
- :'event' => :'event',
37
- :'event_id' => :'eventId',
38
- :'api_version' => :'apiVersion',
39
- :'timestamp' => :'timestamp',
40
- :'account' => :'account',
41
- :'data' => :'data'
45
+ :'campaign' => :'campaign',
46
+ :'audience' => :'audience',
47
+ :'stay_window' => :'stayWindow',
48
+ :'booking_window' => :'bookingWindow',
49
+ :'last_minute' => :'lastMinute',
50
+ :'early_booker_days' => :'earlyBookerDays',
51
+ :'min_nights' => :'minNights',
52
+ :'non_refundable' => :'nonRefundable',
53
+ :'blackout_dates' => :'blackoutDates',
54
+ :'blackout_dates_quota' => :'blackoutDatesQuota'
42
55
  }
43
56
  end
44
57
 
@@ -55,19 +68,22 @@ module Repull
55
68
  # Attribute type mapping.
56
69
  def self.openapi_types
57
70
  {
58
- :'event' => :'String',
59
- :'event_id' => :'String',
60
- :'api_version' => :'String',
61
- :'timestamp' => :'Time',
62
- :'account' => :'WebhookEventAccount',
63
- :'data' => :'CalendarUpdatedPayload'
71
+ :'campaign' => :'String',
72
+ :'audience' => :'String',
73
+ :'stay_window' => :'PromotionRulesStayWindow',
74
+ :'booking_window' => :'PromotionRulesBookingWindow',
75
+ :'last_minute' => :'PromotionRulesLastMinute',
76
+ :'early_booker_days' => :'Integer',
77
+ :'min_nights' => :'Integer',
78
+ :'non_refundable' => :'Boolean',
79
+ :'blackout_dates' => :'Array<Date>',
80
+ :'blackout_dates_quota' => :'PromotionRulesBlackoutDatesQuota'
64
81
  }
65
82
  end
66
83
 
67
84
  # List of attributes with nullable: true
68
85
  def self.openapi_nullable
69
86
  Set.new([
70
- :'account',
71
87
  ])
72
88
  end
73
89
 
@@ -75,50 +91,58 @@ module Repull
75
91
  # @param [Hash] attributes Model attributes in the form of hash
76
92
  def initialize(attributes = {})
77
93
  if (!attributes.is_a?(Hash))
78
- fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::CalendarUpdatedEvent` initialize method"
94
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::PromotionRules` initialize method"
79
95
  end
80
96
 
81
97
  # check to see if the attribute exists and convert string to symbol for hash key
82
98
  acceptable_attribute_map = self.class.acceptable_attribute_map
83
99
  attributes = attributes.each_with_object({}) { |(k, v), h|
84
100
  if (!acceptable_attribute_map.key?(k.to_sym))
85
- fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::CalendarUpdatedEvent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::PromotionRules`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
86
102
  end
87
103
  h[k.to_sym] = v
88
104
  }
89
105
 
90
- if attributes.key?(:'event')
91
- self.event = attributes[:'event']
92
- else
93
- self.event = nil
106
+ if attributes.key?(:'campaign')
107
+ self.campaign = attributes[:'campaign']
108
+ end
109
+
110
+ if attributes.key?(:'audience')
111
+ self.audience = attributes[:'audience']
112
+ end
113
+
114
+ if attributes.key?(:'stay_window')
115
+ self.stay_window = attributes[:'stay_window']
116
+ end
117
+
118
+ if attributes.key?(:'booking_window')
119
+ self.booking_window = attributes[:'booking_window']
120
+ end
121
+
122
+ if attributes.key?(:'last_minute')
123
+ self.last_minute = attributes[:'last_minute']
94
124
  end
95
125
 
96
- if attributes.key?(:'event_id')
97
- self.event_id = attributes[:'event_id']
98
- else
99
- self.event_id = nil
126
+ if attributes.key?(:'early_booker_days')
127
+ self.early_booker_days = attributes[:'early_booker_days']
100
128
  end
101
129
 
102
- if attributes.key?(:'api_version')
103
- self.api_version = attributes[:'api_version']
104
- else
105
- self.api_version = nil
130
+ if attributes.key?(:'min_nights')
131
+ self.min_nights = attributes[:'min_nights']
106
132
  end
107
133
 
108
- if attributes.key?(:'timestamp')
109
- self.timestamp = attributes[:'timestamp']
110
- else
111
- self.timestamp = nil
134
+ if attributes.key?(:'non_refundable')
135
+ self.non_refundable = attributes[:'non_refundable']
112
136
  end
113
137
 
114
- if attributes.key?(:'account')
115
- self.account = attributes[:'account']
138
+ if attributes.key?(:'blackout_dates')
139
+ if (value = attributes[:'blackout_dates']).is_a?(Array)
140
+ self.blackout_dates = value
141
+ end
116
142
  end
117
143
 
118
- if attributes.key?(:'data')
119
- self.data = attributes[:'data']
120
- else
121
- self.data = nil
144
+ if attributes.key?(:'blackout_dates_quota')
145
+ self.blackout_dates_quota = attributes[:'blackout_dates_quota']
122
146
  end
123
147
  end
124
148
 
@@ -127,24 +151,20 @@ module Repull
127
151
  def list_invalid_properties
128
152
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
129
153
  invalid_properties = Array.new
130
- if @event.nil?
131
- invalid_properties.push('invalid value for "event", event cannot be nil.')
132
- end
133
-
134
- if @event_id.nil?
135
- invalid_properties.push('invalid value for "event_id", event_id cannot be nil.')
154
+ if !@early_booker_days.nil? && @early_booker_days > 500
155
+ invalid_properties.push('invalid value for "early_booker_days", must be smaller than or equal to 500.')
136
156
  end
137
157
 
138
- if @api_version.nil?
139
- invalid_properties.push('invalid value for "api_version", api_version cannot be nil.')
158
+ if !@early_booker_days.nil? && @early_booker_days < 1
159
+ invalid_properties.push('invalid value for "early_booker_days", must be greater than or equal to 1.')
140
160
  end
141
161
 
142
- if @timestamp.nil?
143
- invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
162
+ if !@min_nights.nil? && @min_nights > 30
163
+ invalid_properties.push('invalid value for "min_nights", must be smaller than or equal to 30.')
144
164
  end
145
165
 
146
- if @data.nil?
147
- invalid_properties.push('invalid value for "data", data cannot be nil.')
166
+ if !@min_nights.nil? && @min_nights < 0
167
+ invalid_properties.push('invalid value for "min_nights", must be greater than or equal to 0.')
148
168
  end
149
169
 
150
170
  invalid_properties
@@ -154,62 +174,47 @@ module Repull
154
174
  # @return true if the model is valid
155
175
  def valid?
156
176
  warn '[DEPRECATED] the `valid?` method is obsolete'
157
- return false if @event.nil?
158
- return false if @event_id.nil?
159
- return false if @api_version.nil?
160
- return false if @timestamp.nil?
161
- return false if @data.nil?
177
+ return false if !@early_booker_days.nil? && @early_booker_days > 500
178
+ return false if !@early_booker_days.nil? && @early_booker_days < 1
179
+ return false if !@min_nights.nil? && @min_nights > 30
180
+ return false if !@min_nights.nil? && @min_nights < 0
162
181
  true
163
182
  end
164
183
 
165
184
  # Custom attribute writer method with validation
166
- # @param [Object] event Value to be assigned
167
- def event=(event)
168
- if event.nil?
169
- fail ArgumentError, 'event cannot be nil'
185
+ # @param [Object] early_booker_days Value to be assigned
186
+ def early_booker_days=(early_booker_days)
187
+ if early_booker_days.nil?
188
+ fail ArgumentError, 'early_booker_days cannot be nil'
170
189
  end
171
190
 
172
- @event = event
173
- end
174
-
175
- # Custom attribute writer method with validation
176
- # @param [Object] event_id Value to be assigned
177
- def event_id=(event_id)
178
- if event_id.nil?
179
- fail ArgumentError, 'event_id cannot be nil'
191
+ if early_booker_days > 500
192
+ fail ArgumentError, 'invalid value for "early_booker_days", must be smaller than or equal to 500.'
180
193
  end
181
194
 
182
- @event_id = event_id
183
- end
184
-
185
- # Custom attribute writer method with validation
186
- # @param [Object] api_version Value to be assigned
187
- def api_version=(api_version)
188
- if api_version.nil?
189
- fail ArgumentError, 'api_version cannot be nil'
195
+ if early_booker_days < 1
196
+ fail ArgumentError, 'invalid value for "early_booker_days", must be greater than or equal to 1.'
190
197
  end
191
198
 
192
- @api_version = api_version
199
+ @early_booker_days = early_booker_days
193
200
  end
194
201
 
195
202
  # Custom attribute writer method with validation
196
- # @param [Object] timestamp Value to be assigned
197
- def timestamp=(timestamp)
198
- if timestamp.nil?
199
- fail ArgumentError, 'timestamp cannot be nil'
203
+ # @param [Object] min_nights Value to be assigned
204
+ def min_nights=(min_nights)
205
+ if min_nights.nil?
206
+ fail ArgumentError, 'min_nights cannot be nil'
200
207
  end
201
208
 
202
- @timestamp = timestamp
203
- end
209
+ if min_nights > 30
210
+ fail ArgumentError, 'invalid value for "min_nights", must be smaller than or equal to 30.'
211
+ end
204
212
 
205
- # Custom attribute writer method with validation
206
- # @param [Object] data Value to be assigned
207
- def data=(data)
208
- if data.nil?
209
- fail ArgumentError, 'data cannot be nil'
213
+ if min_nights < 0
214
+ fail ArgumentError, 'invalid value for "min_nights", must be greater than or equal to 0.'
210
215
  end
211
216
 
212
- @data = data
217
+ @min_nights = min_nights
213
218
  end
214
219
 
215
220
  # Checks equality by comparing each attribute.
@@ -217,12 +222,16 @@ module Repull
217
222
  def ==(o)
218
223
  return true if self.equal?(o)
219
224
  self.class == o.class &&
220
- event == o.event &&
221
- event_id == o.event_id &&
222
- api_version == o.api_version &&
223
- timestamp == o.timestamp &&
224
- account == o.account &&
225
- data == o.data
225
+ campaign == o.campaign &&
226
+ audience == o.audience &&
227
+ stay_window == o.stay_window &&
228
+ booking_window == o.booking_window &&
229
+ last_minute == o.last_minute &&
230
+ early_booker_days == o.early_booker_days &&
231
+ min_nights == o.min_nights &&
232
+ non_refundable == o.non_refundable &&
233
+ blackout_dates == o.blackout_dates &&
234
+ blackout_dates_quota == o.blackout_dates_quota
226
235
  end
227
236
 
228
237
  # @see the `==` method
@@ -234,7 +243,7 @@ module Repull
234
243
  # Calculates hash code according to all attributes.
235
244
  # @return [Integer] Hash code
236
245
  def hash
237
- [event, event_id, api_version, timestamp, account, data].hash
246
+ [campaign, audience, stay_window, booking_window, last_minute, early_booker_days, min_nights, non_refundable, blackout_dates, blackout_dates_quota].hash
238
247
  end
239
248
 
240
249
  # Builds the object from hash
@@ -0,0 +1,156 @@
1
+ =begin
2
+ #Repull API
3
+
4
+ #The unified API for vacation rental tech. Connect to 50+ PMS platforms and 4 OTA channels through one REST API. Built-in AI operations for guest communication, pricing, and listing optimization. ## Designed for AI agents Every error response on this API includes machine-parseable fields so an LLM (Claude in MCP, Cursor, Cline, GPT, etc.) can self-recover without escalating to a human: - `error.code` — stable string identifier (e.g. `invalid_params`, `rate_limit_exceeded`) - `error.message` — human-readable cause - `error.fix` — exact recovery steps (e.g. \"Pass `check_in_after` as ISO 8601: `?check_in_after=2026-01-15`\") - `error.docs_url` — link to the canonical write-up at `https://repull.dev/docs/errors/{code}` - `error.request_id` — id to correlate with server-side logs - `error.field` / `error.value_received` / `error.valid_values` / `error.did_you_mean` — when the error is parameter-specific - `error.retry_after` — seconds to wait before retrying (rate-limit + transient upstream) `Access-Control-Expose-Headers` lists `x-request-id` and the `X-RateLimit-*` family so browsers can read them on cross-origin responses. ## Quick Start 1. Get an API key at https://repull.dev/dashboard 2. Connect a PMS: `POST /v1/connect/{provider}` 3. List properties: `GET /v1/properties` 4. Get reservations: `GET /v1/reservations` ## Authentication All requests require a Bearer token: ``` Authorization: Bearer sk_live_YOUR_API_KEY ``` ## Request Correlation (X-Request-ID) Every response carries an `X-Request-ID` header, e.g. `X-Request-ID: req_01HXY...`. Include this id in support tickets and bug reports — we can trace the full request lifecycle (auth, rate limit, handler, downstream calls, log row) from a single id. You may set the header on the inbound request to forward your own trace id; we will echo it back instead of generating a new one. Accepted format: `^[\\\\w.-]{1,128}$`. The id is also embedded in error envelopes as `request_id` so server-side log diffs work even when the response headers are stripped by an intermediate proxy. ## Rate Limits The public API enforces a per-API-key sliding-window rate limit on top of the per-tier monthly + daily-AI quotas. **Default policy:** 600 requests per 60 seconds, per API key. Sliding window — there is no fixed-minute boundary you can burst across. Every response includes: | Header | Meaning | |---|---| | `X-RateLimit-Limit` | Requests permitted in the current window. | | `X-RateLimit-Remaining` | Requests left in the current window after this call. | | `X-RateLimit-Reset` | Unix epoch (seconds) when the next slot opens. | | `X-RateLimit-Policy` | Machine-readable policy descriptor, e.g. `600;w=60`. | | `Retry-After` | Seconds to wait before retrying. **Only present on 429 responses.** | **On 429 (rate_limit_exceeded):** the response body matches the standard error envelope with `code: \"rate_limit_exceeded\"`, plus `limit`, `window_seconds`, `retry_after`, and `request_id` fields. SDKs MUST honor `Retry-After` and use exponential backoff with jitter on subsequent retries — never a tight loop. Recommended backoff: ``` sleep_ms = (Retry-After * 1000) + random(0..250) ``` Monthly + daily-AI tier quotas (`free`, `starter`, `custom`) are enforced separately and also surface as 429s; they include `tier`, `scope`, and `resetsAt` fields. ## Plan Limits (402 — `listings_limit_exceeded`) The Repull API also enforces a per-tier cap on **active listings**: | Tier | Active listings cap | |---|---| | `free` | 3 | | `starter` | unlimited (10 included, then billed per listing) | | `custom` | unlimited | When a customer's active-listing count is above their tier cap, the API returns **`402 Payment Required`** with `error.code = \"listings_limit_exceeded\"` on every route EXCEPT: - `/v1/health` — uptime probes are never gated. - `/v1/usage/*` — so dashboards can render the over-cap state. - Any `DELETE` — so the customer can trim listings to get back under the cap without paying. Unlike 429, 402 is NOT a \"wait and retry\" condition — `Retry-After` is not set. The only paths back to 200 are: 1. `DELETE` enough listings to come back under the cap, or 2. Upgrade at `https://repull.dev/dashboard/billing`. The server-side usage cache is 60s, so the first 200 after an upgrade may take up to a minute. The envelope mirrors `rate_limit_exceeded` for SDK ergonomics: `tier`, `limit`, `active_listings`, `upgrade_url`, plus the standard `code` / `message` / `fix` / `docs_url` / `request_id`.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Repull
17
+ class PromotionRulesBlackoutDatesQuota < ApiModelBase
18
+ attr_accessor :used
19
+
20
+ attr_accessor :available
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'used' => :'used',
26
+ :'available' => :'available'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'used' => :'Integer',
44
+ :'available' => :'Integer'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::PromotionRulesBlackoutDatesQuota` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::PromotionRulesBlackoutDatesQuota`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'used')
71
+ self.used = attributes[:'used']
72
+ end
73
+
74
+ if attributes.key?(:'available')
75
+ self.available = attributes[:'available']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ warn '[DEPRECATED] the `valid?` method is obsolete'
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ used == o.used &&
100
+ available == o.available
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [used, available].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ transformed_hash = {}
122
+ openapi_types.each_pair do |key, type|
123
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = nil
125
+ elsif type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[attribute_map[key]].is_a?(Array)
129
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
130
+ end
131
+ elsif !attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
133
+ end
134
+ end
135
+ new(transformed_hash)
136
+ end
137
+
138
+ # Returns the object in the form of hash
139
+ # @return [Hash] Returns the object in the form of hash
140
+ def to_hash
141
+ hash = {}
142
+ self.class.attribute_map.each_pair do |attr, param|
143
+ value = self.send(attr)
144
+ if value.nil?
145
+ is_nullable = self.class.openapi_nullable.include?(attr)
146
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
147
+ end
148
+
149
+ hash[param] = _to_hash(value)
150
+ end
151
+ hash
152
+ end
153
+
154
+ end
155
+
156
+ end