repull 0.2.18 → 0.2.19

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.
@@ -28,10 +28,10 @@ module Repull
28
28
 
29
29
  attr_accessor :security_deposit
30
30
 
31
- # Fraction, not a percentage: `0.1` is 10% off a stay of a week or more.
31
+ # A percentage, not a fraction: `10` is 10% off a stay of a week or more. A value between 0 and 1 is refused (it would publish as a fraction of one percent) — send `10`, not `0.1`. `0` clears it.
32
32
  attr_accessor :weekly_discount
33
33
 
34
- # Fraction, not a percentage.
34
+ # A percentage, not a fraction: `20` is 20% off a stay of 28 nights or more. Values between 0 and 1 are refused, as for `weeklyDiscount`.
35
35
  attr_accessor :monthly_discount
36
36
 
37
37
  # Guests covered by the nightly rate before `pricePerExtraGuest` applies.
@@ -153,6 +153,22 @@ module Repull
153
153
  def list_invalid_properties
154
154
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
155
155
  invalid_properties = Array.new
156
+ if !@weekly_discount.nil? && @weekly_discount > 99
157
+ invalid_properties.push('invalid value for "weekly_discount", must be smaller than or equal to 99.')
158
+ end
159
+
160
+ if !@weekly_discount.nil? && @weekly_discount < 0
161
+ invalid_properties.push('invalid value for "weekly_discount", must be greater than or equal to 0.')
162
+ end
163
+
164
+ if !@monthly_discount.nil? && @monthly_discount > 99
165
+ invalid_properties.push('invalid value for "monthly_discount", must be smaller than or equal to 99.')
166
+ end
167
+
168
+ if !@monthly_discount.nil? && @monthly_discount < 0
169
+ invalid_properties.push('invalid value for "monthly_discount", must be greater than or equal to 0.')
170
+ end
171
+
156
172
  invalid_properties
157
173
  end
158
174
 
@@ -160,9 +176,41 @@ module Repull
160
176
  # @return true if the model is valid
161
177
  def valid?
162
178
  warn '[DEPRECATED] the `valid?` method is obsolete'
179
+ return false if !@weekly_discount.nil? && @weekly_discount > 99
180
+ return false if !@weekly_discount.nil? && @weekly_discount < 0
181
+ return false if !@monthly_discount.nil? && @monthly_discount > 99
182
+ return false if !@monthly_discount.nil? && @monthly_discount < 0
163
183
  true
164
184
  end
165
185
 
186
+ # Custom attribute writer method with validation
187
+ # @param [Object] weekly_discount Value to be assigned
188
+ def weekly_discount=(weekly_discount)
189
+ if !weekly_discount.nil? && weekly_discount > 99
190
+ fail ArgumentError, 'invalid value for "weekly_discount", must be smaller than or equal to 99.'
191
+ end
192
+
193
+ if !weekly_discount.nil? && weekly_discount < 0
194
+ fail ArgumentError, 'invalid value for "weekly_discount", must be greater than or equal to 0.'
195
+ end
196
+
197
+ @weekly_discount = weekly_discount
198
+ end
199
+
200
+ # Custom attribute writer method with validation
201
+ # @param [Object] monthly_discount Value to be assigned
202
+ def monthly_discount=(monthly_discount)
203
+ if !monthly_discount.nil? && monthly_discount > 99
204
+ fail ArgumentError, 'invalid value for "monthly_discount", must be smaller than or equal to 99.'
205
+ end
206
+
207
+ if !monthly_discount.nil? && monthly_discount < 0
208
+ fail ArgumentError, 'invalid value for "monthly_discount", must be greater than or equal to 0.'
209
+ end
210
+
211
+ @monthly_discount = monthly_discount
212
+ end
213
+
166
214
  # Checks equality by comparing each attribute.
167
215
  # @param [Object] Object to be compared
168
216
  def ==(o)
@@ -0,0 +1,225 @@
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` | 50 | | `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
+ Contact: ivan@vanio.ai
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 ListingContentUpdateRequestRoomsInner < ApiModelBase
18
+ # e.g. `bedroom`, `full_bathroom`, `half_bathroom`, `living_room`, `kitchen`. Not a closed list — Airbnb validates it at publish and its refusal comes back in the publish result.
19
+ attr_accessor :room_type
20
+
21
+ # Your own label, e.g. \"Primary bedroom\".
22
+ attr_accessor :room_name
23
+
24
+ # Order among rooms of the same type, from 1.
25
+ attr_accessor :room_number
26
+
27
+ # Whether the room is private to the guest.
28
+ attr_accessor :is_private
29
+
30
+ attr_accessor :beds
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'room_type' => :'roomType',
36
+ :'room_name' => :'roomName',
37
+ :'room_number' => :'roomNumber',
38
+ :'is_private' => :'isPrivate',
39
+ :'beds' => :'beds'
40
+ }
41
+ end
42
+
43
+ # Returns attribute mapping this model knows about
44
+ def self.acceptable_attribute_map
45
+ attribute_map
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ acceptable_attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'room_type' => :'String',
57
+ :'room_name' => :'String',
58
+ :'room_number' => :'Integer',
59
+ :'is_private' => :'Boolean',
60
+ :'beds' => :'Array<ListingContentUpdateRequestRoomsInnerBedsInner>'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ :'room_name',
68
+ :'room_number',
69
+ :'is_private',
70
+ :'beds'
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::ListingContentUpdateRequestRoomsInner` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ acceptable_attribute_map = self.class.acceptable_attribute_map
83
+ attributes = attributes.each_with_object({}) { |(k, v), h|
84
+ if (!acceptable_attribute_map.key?(k.to_sym))
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::ListingContentUpdateRequestRoomsInner`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
86
+ end
87
+ h[k.to_sym] = v
88
+ }
89
+
90
+ if attributes.key?(:'room_type')
91
+ self.room_type = attributes[:'room_type']
92
+ else
93
+ self.room_type = nil
94
+ end
95
+
96
+ if attributes.key?(:'room_name')
97
+ self.room_name = attributes[:'room_name']
98
+ end
99
+
100
+ if attributes.key?(:'room_number')
101
+ self.room_number = attributes[:'room_number']
102
+ end
103
+
104
+ if attributes.key?(:'is_private')
105
+ self.is_private = attributes[:'is_private']
106
+ end
107
+
108
+ if attributes.key?(:'beds')
109
+ if (value = attributes[:'beds']).is_a?(Array)
110
+ self.beds = value
111
+ end
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
119
+ invalid_properties = Array.new
120
+ if @room_type.nil?
121
+ invalid_properties.push('invalid value for "room_type", room_type cannot be nil.')
122
+ end
123
+
124
+ if !@room_number.nil? && @room_number < 1
125
+ invalid_properties.push('invalid value for "room_number", must be greater than or equal to 1.')
126
+ end
127
+
128
+ invalid_properties
129
+ end
130
+
131
+ # Check to see if the all the properties in the model are valid
132
+ # @return true if the model is valid
133
+ def valid?
134
+ warn '[DEPRECATED] the `valid?` method is obsolete'
135
+ return false if @room_type.nil?
136
+ return false if !@room_number.nil? && @room_number < 1
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method with validation
141
+ # @param [Object] room_type Value to be assigned
142
+ def room_type=(room_type)
143
+ if room_type.nil?
144
+ fail ArgumentError, 'room_type cannot be nil'
145
+ end
146
+
147
+ @room_type = room_type
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] room_number Value to be assigned
152
+ def room_number=(room_number)
153
+ if !room_number.nil? && room_number < 1
154
+ fail ArgumentError, 'invalid value for "room_number", must be greater than or equal to 1.'
155
+ end
156
+
157
+ @room_number = room_number
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ room_type == o.room_type &&
166
+ room_name == o.room_name &&
167
+ room_number == o.room_number &&
168
+ is_private == o.is_private &&
169
+ beds == o.beds
170
+ end
171
+
172
+ # @see the `==` method
173
+ # @param [Object] Object to be compared
174
+ def eql?(o)
175
+ self == o
176
+ end
177
+
178
+ # Calculates hash code according to all attributes.
179
+ # @return [Integer] Hash code
180
+ def hash
181
+ [room_type, room_name, room_number, is_private, beds].hash
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def self.build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ attributes = attributes.transform_keys(&:to_sym)
190
+ transformed_hash = {}
191
+ openapi_types.each_pair do |key, type|
192
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
193
+ transformed_hash["#{key}"] = nil
194
+ elsif type =~ /\AArray<(.*)>/i
195
+ # check to ensure the input is an array given that the attribute
196
+ # is documented as an array but the input is not
197
+ if attributes[attribute_map[key]].is_a?(Array)
198
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
199
+ end
200
+ elsif !attributes[attribute_map[key]].nil?
201
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
202
+ end
203
+ end
204
+ new(transformed_hash)
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -0,0 +1,209 @@
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` | 50 | | `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
+ Contact: ivan@vanio.ai
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 ListingContentUpdateRequestRoomsInnerBedsInner < ApiModelBase
18
+ # e.g. `king_bed`, `queen_bed`, `double_bed`, `single_bed`, `sofa_bed`, `bunk_bed`.
19
+ attr_accessor :bed_type
20
+
21
+ attr_accessor :quantity
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'bed_type' => :'bedType',
27
+ :'quantity' => :'quantity'
28
+ }
29
+ end
30
+
31
+ # Returns attribute mapping this model knows about
32
+ def self.acceptable_attribute_map
33
+ attribute_map
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ acceptable_attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'bed_type' => :'String',
45
+ :'quantity' => :'Integer'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::ListingContentUpdateRequestRoomsInnerBedsInner` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ acceptable_attribute_map = self.class.acceptable_attribute_map
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!acceptable_attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::ListingContentUpdateRequestRoomsInnerBedsInner`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'bed_type')
72
+ self.bed_type = attributes[:'bed_type']
73
+ else
74
+ self.bed_type = nil
75
+ end
76
+
77
+ if attributes.key?(:'quantity')
78
+ self.quantity = attributes[:'quantity']
79
+ else
80
+ self.quantity = nil
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
88
+ invalid_properties = Array.new
89
+ if @bed_type.nil?
90
+ invalid_properties.push('invalid value for "bed_type", bed_type cannot be nil.')
91
+ end
92
+
93
+ if @quantity.nil?
94
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
95
+ end
96
+
97
+ if @quantity > 20
98
+ invalid_properties.push('invalid value for "quantity", must be smaller than or equal to 20.')
99
+ end
100
+
101
+ if @quantity < 1
102
+ invalid_properties.push('invalid value for "quantity", must be greater than or equal to 1.')
103
+ end
104
+
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ warn '[DEPRECATED] the `valid?` method is obsolete'
112
+ return false if @bed_type.nil?
113
+ return false if @quantity.nil?
114
+ return false if @quantity > 20
115
+ return false if @quantity < 1
116
+ true
117
+ end
118
+
119
+ # Custom attribute writer method with validation
120
+ # @param [Object] bed_type Value to be assigned
121
+ def bed_type=(bed_type)
122
+ if bed_type.nil?
123
+ fail ArgumentError, 'bed_type cannot be nil'
124
+ end
125
+
126
+ @bed_type = bed_type
127
+ end
128
+
129
+ # Custom attribute writer method with validation
130
+ # @param [Object] quantity Value to be assigned
131
+ def quantity=(quantity)
132
+ if quantity.nil?
133
+ fail ArgumentError, 'quantity cannot be nil'
134
+ end
135
+
136
+ if quantity > 20
137
+ fail ArgumentError, 'invalid value for "quantity", must be smaller than or equal to 20.'
138
+ end
139
+
140
+ if quantity < 1
141
+ fail ArgumentError, 'invalid value for "quantity", must be greater than or equal to 1.'
142
+ end
143
+
144
+ @quantity = quantity
145
+ end
146
+
147
+ # Checks equality by comparing each attribute.
148
+ # @param [Object] Object to be compared
149
+ def ==(o)
150
+ return true if self.equal?(o)
151
+ self.class == o.class &&
152
+ bed_type == o.bed_type &&
153
+ quantity == o.quantity
154
+ end
155
+
156
+ # @see the `==` method
157
+ # @param [Object] Object to be compared
158
+ def eql?(o)
159
+ self == o
160
+ end
161
+
162
+ # Calculates hash code according to all attributes.
163
+ # @return [Integer] Hash code
164
+ def hash
165
+ [bed_type, quantity].hash
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def self.build_from_hash(attributes)
172
+ return nil unless attributes.is_a?(Hash)
173
+ attributes = attributes.transform_keys(&:to_sym)
174
+ transformed_hash = {}
175
+ openapi_types.each_pair do |key, type|
176
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
177
+ transformed_hash["#{key}"] = nil
178
+ elsif type =~ /\AArray<(.*)>/i
179
+ # check to ensure the input is an array given that the attribute
180
+ # is documented as an array but the input is not
181
+ if attributes[attribute_map[key]].is_a?(Array)
182
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
183
+ end
184
+ elsif !attributes[attribute_map[key]].nil?
185
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
186
+ end
187
+ end
188
+ new(transformed_hash)
189
+ end
190
+
191
+ # Returns the object in the form of hash
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_hash
194
+ hash = {}
195
+ self.class.attribute_map.each_pair do |attr, param|
196
+ value = self.send(attr)
197
+ if value.nil?
198
+ is_nullable = self.class.openapi_nullable.include?(attr)
199
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
200
+ end
201
+
202
+ hash[param] = _to_hash(value)
203
+ end
204
+ hash
205
+ end
206
+
207
+ end
208
+
209
+ end