smplkit 3.0.8 → 3.0.9

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb +0 -469
  3. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/subscription_api.rb +289 -0
  4. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{subscription_list_response.rb → admin_subscription_request.rb} +9 -20
  5. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/admin_subscription_request_attributes.rb +190 -0
  6. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{create_subscription_data.rb → admin_subscription_request_resource.rb} +46 -12
  7. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{next_tier_meta.rb → next_tier_response.rb} +6 -6
  8. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_change_projection.rb +321 -0
  9. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{create_subscription_attributes.rb → subscription_item_request.rb} +10 -21
  10. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{subscription_attributes.rb → subscription_item_response.rb} +66 -77
  11. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb +390 -0
  12. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_resource.rb +241 -0
  13. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{plan_change_request.rb → subscription_preview_response.rb} +20 -21
  14. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{create_subscription_body.rb → subscription_request.rb} +5 -5
  15. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_request_attributes.rb +179 -0
  16. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_request_resource.rb +227 -0
  17. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_resource.rb +4 -2
  18. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_response.rb +1 -1
  19. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{subscription_list_meta.rb → subscription_response_attributes.rb} +135 -62
  20. data/lib/smplkit/_generated/app/lib/smplkit_app_client.rb +15 -8
  21. data/lib/smplkit/_generated/app/spec/api/billing_api_spec.rb +0 -86
  22. data/lib/smplkit/_generated/app/spec/api/subscription_api_spec.rb +83 -0
  23. data/lib/smplkit/_generated/app/spec/models/{create_subscription_attributes_spec.rb → admin_subscription_request_attributes_spec.rb} +9 -9
  24. data/lib/smplkit/_generated/app/spec/models/admin_subscription_request_resource_spec.rb +52 -0
  25. data/lib/smplkit/_generated/app/spec/models/{plan_change_request_spec.rb → admin_subscription_request_spec.rb} +7 -7
  26. data/lib/smplkit/_generated/app/spec/models/{next_tier_meta_spec.rb → next_tier_response_spec.rb} +6 -6
  27. data/lib/smplkit/_generated/app/spec/models/{subscription_list_meta_spec.rb → subscription_change_projection_spec.rb} +20 -14
  28. data/lib/smplkit/_generated/app/spec/models/{create_subscription_data_spec.rb → subscription_item_request_spec.rb} +8 -8
  29. data/lib/smplkit/_generated/app/spec/models/{subscription_attributes_spec.rb → subscription_item_response_spec.rb} +12 -18
  30. data/lib/smplkit/_generated/app/spec/models/subscription_preview_attributes_spec.rb +88 -0
  31. data/lib/smplkit/_generated/app/spec/models/subscription_preview_resource_spec.rb +56 -0
  32. data/lib/smplkit/_generated/app/spec/models/subscription_preview_response_spec.rb +36 -0
  33. data/lib/smplkit/_generated/app/spec/models/{subscription_list_response_spec.rb → subscription_request_attributes_spec.rb} +8 -8
  34. data/lib/smplkit/_generated/app/spec/models/subscription_request_resource_spec.rb +52 -0
  35. data/lib/smplkit/_generated/app/spec/models/{create_subscription_body_spec.rb → subscription_request_spec.rb} +6 -6
  36. data/lib/smplkit/_generated/app/spec/models/subscription_response_attributes_spec.rb +100 -0
  37. metadata +31 -17
@@ -0,0 +1,289 @@
1
+ =begin
2
+ #smplkit API
3
+
4
+ #API for the smplkit platform.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module SmplkitGeneratedClient::App
16
+ class SubscriptionApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Replace Account Subscription (admin)
23
+ # Admin replacement of a specific account's subscription. Accepts the same body shape as the customer endpoint plus ``discount_override_pct``. Setting the override to 100 skips the billing provider entirely; lowering it below 100 requires a payment method on file for the target account.
24
+ # @param account_id [String]
25
+ # @param admin_subscription_request [AdminSubscriptionRequest]
26
+ # @param [Hash] opts the optional parameters
27
+ # @return [SubscriptionResponse]
28
+ def admin_put_account_subscription(account_id, admin_subscription_request, opts = {})
29
+ data, _status_code, _headers = admin_put_account_subscription_with_http_info(account_id, admin_subscription_request, opts)
30
+ data
31
+ end
32
+
33
+ # Replace Account Subscription (admin)
34
+ # Admin replacement of a specific account's subscription. Accepts the same body shape as the customer endpoint plus ``discount_override_pct``. Setting the override to 100 skips the billing provider entirely; lowering it below 100 requires a payment method on file for the target account.
35
+ # @param account_id [String]
36
+ # @param admin_subscription_request [AdminSubscriptionRequest]
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers
39
+ def admin_put_account_subscription_with_http_info(account_id, admin_subscription_request, opts = {})
40
+ if @api_client.config.debugging
41
+ @api_client.config.logger.debug 'Calling API: SubscriptionApi.admin_put_account_subscription ...'
42
+ end
43
+ # verify the required parameter 'account_id' is set
44
+ if @api_client.config.client_side_validation && account_id.nil?
45
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling SubscriptionApi.admin_put_account_subscription"
46
+ end
47
+ # verify the required parameter 'admin_subscription_request' is set
48
+ if @api_client.config.client_side_validation && admin_subscription_request.nil?
49
+ fail ArgumentError, "Missing the required parameter 'admin_subscription_request' when calling SubscriptionApi.admin_put_account_subscription"
50
+ end
51
+ # resource path
52
+ local_var_path = '/api/v1/accounts/{account_id}/subscription'.sub('{account_id}', CGI.escape(account_id.to_s))
53
+
54
+ # query parameters
55
+ query_params = opts[:query_params] || {}
56
+
57
+ # header parameters
58
+ header_params = opts[:header_params] || {}
59
+ # HTTP header 'Accept' (if needed)
60
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
61
+ # HTTP header 'Content-Type'
62
+ content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
63
+ if !content_type.nil?
64
+ header_params['Content-Type'] = content_type
65
+ end
66
+
67
+ # form parameters
68
+ form_params = opts[:form_params] || {}
69
+
70
+ # http body (model)
71
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(admin_subscription_request)
72
+
73
+ # return_type
74
+ return_type = opts[:debug_return_type] || 'SubscriptionResponse'
75
+
76
+ # auth_names
77
+ auth_names = opts[:debug_auth_names] || ['HTTPBearer']
78
+
79
+ new_options = opts.merge(
80
+ :operation => :"SubscriptionApi.admin_put_account_subscription",
81
+ :header_params => header_params,
82
+ :query_params => query_params,
83
+ :form_params => form_params,
84
+ :body => post_body,
85
+ :auth_names => auth_names,
86
+ :return_type => return_type
87
+ )
88
+
89
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
90
+ if @api_client.config.debugging
91
+ @api_client.config.logger.debug "API called: SubscriptionApi#admin_put_account_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
92
+ end
93
+ return data, status_code, headers
94
+ end
95
+
96
+ # Get Current Subscription
97
+ # Return the authenticated account's subscription, or 404 if none exists.
98
+ # @param [Hash] opts the optional parameters
99
+ # @return [SubscriptionResponse]
100
+ def get_current_subscription(opts = {})
101
+ data, _status_code, _headers = get_current_subscription_with_http_info(opts)
102
+ data
103
+ end
104
+
105
+ # Get Current Subscription
106
+ # Return the authenticated account&#39;s subscription, or 404 if none exists.
107
+ # @param [Hash] opts the optional parameters
108
+ # @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers
109
+ def get_current_subscription_with_http_info(opts = {})
110
+ if @api_client.config.debugging
111
+ @api_client.config.logger.debug 'Calling API: SubscriptionApi.get_current_subscription ...'
112
+ end
113
+ # resource path
114
+ local_var_path = '/api/v1/accounts/current/subscription'
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/vnd.api+json']) unless header_params['Accept']
123
+
124
+ # form parameters
125
+ form_params = opts[:form_params] || {}
126
+
127
+ # http body (model)
128
+ post_body = opts[:debug_body]
129
+
130
+ # return_type
131
+ return_type = opts[:debug_return_type] || 'SubscriptionResponse'
132
+
133
+ # auth_names
134
+ auth_names = opts[:debug_auth_names] || ['HTTPBearer']
135
+
136
+ new_options = opts.merge(
137
+ :operation => :"SubscriptionApi.get_current_subscription",
138
+ :header_params => header_params,
139
+ :query_params => query_params,
140
+ :form_params => form_params,
141
+ :body => post_body,
142
+ :auth_names => auth_names,
143
+ :return_type => return_type
144
+ )
145
+
146
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
147
+ if @api_client.config.debugging
148
+ @api_client.config.logger.debug "API called: SubscriptionApi#get_current_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
149
+ end
150
+ return data, status_code, headers
151
+ end
152
+
153
+ # Preview Subscription Change
154
+ # Project the result of replacing the subscription with the desired state. No database or billing-provider changes are made; safe to call as the customer iterates on a plan picker.
155
+ # @param subscription_request [SubscriptionRequest]
156
+ # @param [Hash] opts the optional parameters
157
+ # @return [SubscriptionPreviewResponse]
158
+ def preview_current_subscription(subscription_request, opts = {})
159
+ data, _status_code, _headers = preview_current_subscription_with_http_info(subscription_request, opts)
160
+ data
161
+ end
162
+
163
+ # Preview Subscription Change
164
+ # Project the result of replacing the subscription with the desired state. No database or billing-provider changes are made; safe to call as the customer iterates on a plan picker.
165
+ # @param subscription_request [SubscriptionRequest]
166
+ # @param [Hash] opts the optional parameters
167
+ # @return [Array<(SubscriptionPreviewResponse, Integer, Hash)>] SubscriptionPreviewResponse data, response status code and response headers
168
+ def preview_current_subscription_with_http_info(subscription_request, opts = {})
169
+ if @api_client.config.debugging
170
+ @api_client.config.logger.debug 'Calling API: SubscriptionApi.preview_current_subscription ...'
171
+ end
172
+ # verify the required parameter 'subscription_request' is set
173
+ if @api_client.config.client_side_validation && subscription_request.nil?
174
+ fail ArgumentError, "Missing the required parameter 'subscription_request' when calling SubscriptionApi.preview_current_subscription"
175
+ end
176
+ # resource path
177
+ local_var_path = '/api/v1/accounts/current/subscription/actions/preview'
178
+
179
+ # query parameters
180
+ query_params = opts[:query_params] || {}
181
+
182
+ # header parameters
183
+ header_params = opts[:header_params] || {}
184
+ # HTTP header 'Accept' (if needed)
185
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
186
+ # HTTP header 'Content-Type'
187
+ content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
188
+ if !content_type.nil?
189
+ header_params['Content-Type'] = content_type
190
+ end
191
+
192
+ # form parameters
193
+ form_params = opts[:form_params] || {}
194
+
195
+ # http body (model)
196
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_request)
197
+
198
+ # return_type
199
+ return_type = opts[:debug_return_type] || 'SubscriptionPreviewResponse'
200
+
201
+ # auth_names
202
+ auth_names = opts[:debug_auth_names] || ['HTTPBearer']
203
+
204
+ new_options = opts.merge(
205
+ :operation => :"SubscriptionApi.preview_current_subscription",
206
+ :header_params => header_params,
207
+ :query_params => query_params,
208
+ :form_params => form_params,
209
+ :body => post_body,
210
+ :auth_names => auth_names,
211
+ :return_type => return_type
212
+ )
213
+
214
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
215
+ if @api_client.config.debugging
216
+ @api_client.config.logger.debug "API called: SubscriptionApi#preview_current_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
217
+ end
218
+ return data, status_code, headers
219
+ end
220
+
221
+ # Replace Current Subscription
222
+ # Replace the authenticated account's subscription with the desired state.
223
+ # @param subscription_request [SubscriptionRequest]
224
+ # @param [Hash] opts the optional parameters
225
+ # @return [SubscriptionResponse]
226
+ def put_current_subscription(subscription_request, opts = {})
227
+ data, _status_code, _headers = put_current_subscription_with_http_info(subscription_request, opts)
228
+ data
229
+ end
230
+
231
+ # Replace Current Subscription
232
+ # Replace the authenticated account&#39;s subscription with the desired state.
233
+ # @param subscription_request [SubscriptionRequest]
234
+ # @param [Hash] opts the optional parameters
235
+ # @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers
236
+ def put_current_subscription_with_http_info(subscription_request, opts = {})
237
+ if @api_client.config.debugging
238
+ @api_client.config.logger.debug 'Calling API: SubscriptionApi.put_current_subscription ...'
239
+ end
240
+ # verify the required parameter 'subscription_request' is set
241
+ if @api_client.config.client_side_validation && subscription_request.nil?
242
+ fail ArgumentError, "Missing the required parameter 'subscription_request' when calling SubscriptionApi.put_current_subscription"
243
+ end
244
+ # resource path
245
+ local_var_path = '/api/v1/accounts/current/subscription'
246
+
247
+ # query parameters
248
+ query_params = opts[:query_params] || {}
249
+
250
+ # header parameters
251
+ header_params = opts[:header_params] || {}
252
+ # HTTP header 'Accept' (if needed)
253
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
254
+ # HTTP header 'Content-Type'
255
+ content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
256
+ if !content_type.nil?
257
+ header_params['Content-Type'] = content_type
258
+ end
259
+
260
+ # form parameters
261
+ form_params = opts[:form_params] || {}
262
+
263
+ # http body (model)
264
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_request)
265
+
266
+ # return_type
267
+ return_type = opts[:debug_return_type] || 'SubscriptionResponse'
268
+
269
+ # auth_names
270
+ auth_names = opts[:debug_auth_names] || ['HTTPBearer']
271
+
272
+ new_options = opts.merge(
273
+ :operation => :"SubscriptionApi.put_current_subscription",
274
+ :header_params => header_params,
275
+ :query_params => query_params,
276
+ :form_params => form_params,
277
+ :body => post_body,
278
+ :auth_names => auth_names,
279
+ :return_type => return_type
280
+ )
281
+
282
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
283
+ if @api_client.config.debugging
284
+ @api_client.config.logger.debug "API called: SubscriptionApi#put_current_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
285
+ end
286
+ return data, status_code, headers
287
+ end
288
+ end
289
+ end
@@ -14,17 +14,14 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module SmplkitGeneratedClient::App
17
- # JSON:API collection response for subscriptions.
18
- class SubscriptionListResponse < ApiModelBase
17
+ # Admin-scope request envelope for replacing a subscription.
18
+ class AdminSubscriptionRequest < ApiModelBase
19
19
  attr_accessor :data
20
20
 
21
- attr_accessor :meta
22
-
23
21
  # Attribute mapping from ruby-style variable name to JSON key.
24
22
  def self.attribute_map
25
23
  {
26
- :'data' => :'data',
27
- :'meta' => :'meta'
24
+ :'data' => :'data'
28
25
  }
29
26
  end
30
27
 
@@ -41,8 +38,7 @@ module SmplkitGeneratedClient::App
41
38
  # Attribute type mapping.
42
39
  def self.openapi_types
43
40
  {
44
- :'data' => :'Array<SubscriptionResource>',
45
- :'meta' => :'SubscriptionListMeta'
41
+ :'data' => :'AdminSubscriptionRequestResource'
46
42
  }
47
43
  end
48
44
 
@@ -56,29 +52,23 @@ module SmplkitGeneratedClient::App
56
52
  # @param [Hash] attributes Model attributes in the form of hash
57
53
  def initialize(attributes = {})
58
54
  if (!attributes.is_a?(Hash))
59
- fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::SubscriptionListResponse` initialize method"
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::AdminSubscriptionRequest` initialize method"
60
56
  end
61
57
 
62
58
  # check to see if the attribute exists and convert string to symbol for hash key
63
59
  acceptable_attribute_map = self.class.acceptable_attribute_map
64
60
  attributes = attributes.each_with_object({}) { |(k, v), h|
65
61
  if (!acceptable_attribute_map.key?(k.to_sym))
66
- fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::SubscriptionListResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::AdminSubscriptionRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
67
63
  end
68
64
  h[k.to_sym] = v
69
65
  }
70
66
 
71
67
  if attributes.key?(:'data')
72
- if (value = attributes[:'data']).is_a?(Array)
73
- self.data = value
74
- end
68
+ self.data = attributes[:'data']
75
69
  else
76
70
  self.data = nil
77
71
  end
78
-
79
- if attributes.key?(:'meta')
80
- self.meta = attributes[:'meta']
81
- end
82
72
  end
83
73
 
84
74
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -116,8 +106,7 @@ module SmplkitGeneratedClient::App
116
106
  def ==(o)
117
107
  return true if self.equal?(o)
118
108
  self.class == o.class &&
119
- data == o.data &&
120
- meta == o.meta
109
+ data == o.data
121
110
  end
122
111
 
123
112
  # @see the `==` method
@@ -129,7 +118,7 @@ module SmplkitGeneratedClient::App
129
118
  # Calculates hash code according to all attributes.
130
119
  # @return [Integer] Hash code
131
120
  def hash
132
- [data, meta].hash
121
+ [data].hash
133
122
  end
134
123
 
135
124
  # Builds the object from hash
@@ -0,0 +1,190 @@
1
+ =begin
2
+ #smplkit API
3
+
4
+ #API for the smplkit platform.
5
+
6
+ The version of the OpenAPI document: 0.1.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 SmplkitGeneratedClient::App
17
+ # Same as the customer request body plus the admin-only override field.
18
+ class AdminSubscriptionRequestAttributes < ApiModelBase
19
+ # Desired enrollments. Products listed are scheduled to be on the specified plan immediately (for upgrades and new enrollments) or at the end of the current billing period (for downgrades). Products not listed are scheduled to be dropped at the end of the current billing period.
20
+ attr_accessor :items
21
+
22
+ # Optional identifier of the payment method to bill against. If omitted, the account's default payment method is used.
23
+ attr_accessor :payment_method
24
+
25
+ # Administrator-set discount percentage (0–100). When set, the multi-product discount schedule is bypassed and this value is used directly. Setting `100` skips the billing provider entirely — the customer pays nothing. Pass `null` to clear any existing override and revert to the multi-product discount schedule.
26
+ attr_accessor :discount_override_pct
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'items' => :'items',
32
+ :'payment_method' => :'payment_method',
33
+ :'discount_override_pct' => :'discount_override_pct'
34
+ }
35
+ end
36
+
37
+ # Returns attribute mapping this model knows about
38
+ def self.acceptable_attribute_map
39
+ attribute_map
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ acceptable_attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'items' => :'Array<SubscriptionItemRequest>',
51
+ :'payment_method' => :'String',
52
+ :'discount_override_pct' => :'Integer'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ :'payment_method',
60
+ :'discount_override_pct'
61
+ ])
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ if (!attributes.is_a?(Hash))
68
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::AdminSubscriptionRequestAttributes` initialize method"
69
+ end
70
+
71
+ # check to see if the attribute exists and convert string to symbol for hash key
72
+ acceptable_attribute_map = self.class.acceptable_attribute_map
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!acceptable_attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::AdminSubscriptionRequestAttributes`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'items')
81
+ if (value = attributes[:'items']).is_a?(Array)
82
+ self.items = value
83
+ end
84
+ else
85
+ self.items = nil
86
+ end
87
+
88
+ if attributes.key?(:'payment_method')
89
+ self.payment_method = attributes[:'payment_method']
90
+ end
91
+
92
+ if attributes.key?(:'discount_override_pct')
93
+ self.discount_override_pct = attributes[:'discount_override_pct']
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
101
+ invalid_properties = Array.new
102
+ if @items.nil?
103
+ invalid_properties.push('invalid value for "items", items cannot be nil.')
104
+ end
105
+
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ warn '[DEPRECATED] the `valid?` method is obsolete'
113
+ return false if @items.nil?
114
+ true
115
+ end
116
+
117
+ # Custom attribute writer method with validation
118
+ # @param [Object] items Value to be assigned
119
+ def items=(items)
120
+ if items.nil?
121
+ fail ArgumentError, 'items cannot be nil'
122
+ end
123
+
124
+ @items = items
125
+ end
126
+
127
+ # Checks equality by comparing each attribute.
128
+ # @param [Object] Object to be compared
129
+ def ==(o)
130
+ return true if self.equal?(o)
131
+ self.class == o.class &&
132
+ items == o.items &&
133
+ payment_method == o.payment_method &&
134
+ discount_override_pct == o.discount_override_pct
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [items, payment_method, discount_override_pct].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[attribute_map[key]].is_a?(Array)
163
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ end
165
+ elsif !attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ end
168
+ end
169
+ new(transformed_hash)
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = self.send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ end
189
+
190
+ end
@@ -14,16 +14,41 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module SmplkitGeneratedClient::App
17
- # Resource object for the create-subscription request.
18
- class CreateSubscriptionData < ApiModelBase
19
- # Resource type; must be `subscription`.
17
+ # Admin-scope resource object for a subscription update request.
18
+ class AdminSubscriptionRequestResource < ApiModelBase
19
+ attr_accessor :id
20
+
21
+ # JSON:API resource type.
20
22
  attr_accessor :type
21
23
 
22
24
  attr_accessor :attributes
23
25
 
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
24
48
  # Attribute mapping from ruby-style variable name to JSON key.
25
49
  def self.attribute_map
26
50
  {
51
+ :'id' => :'id',
27
52
  :'type' => :'type',
28
53
  :'attributes' => :'attributes'
29
54
  }
@@ -42,14 +67,16 @@ module SmplkitGeneratedClient::App
42
67
  # Attribute type mapping.
43
68
  def self.openapi_types
44
69
  {
70
+ :'id' => :'String',
45
71
  :'type' => :'String',
46
- :'attributes' => :'CreateSubscriptionAttributes'
72
+ :'attributes' => :'AdminSubscriptionRequestAttributes'
47
73
  }
48
74
  end
49
75
 
50
76
  # List of attributes with nullable: true
51
77
  def self.openapi_nullable
52
78
  Set.new([
79
+ :'id',
53
80
  ])
54
81
  end
55
82
 
@@ -57,18 +84,22 @@ module SmplkitGeneratedClient::App
57
84
  # @param [Hash] attributes Model attributes in the form of hash
58
85
  def initialize(attributes = {})
59
86
  if (!attributes.is_a?(Hash))
60
- fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::CreateSubscriptionData` initialize method"
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::AdminSubscriptionRequestResource` initialize method"
61
88
  end
62
89
 
63
90
  # check to see if the attribute exists and convert string to symbol for hash key
64
91
  acceptable_attribute_map = self.class.acceptable_attribute_map
65
92
  attributes = attributes.each_with_object({}) { |(k, v), h|
66
93
  if (!acceptable_attribute_map.key?(k.to_sym))
67
- fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::CreateSubscriptionData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
94
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::AdminSubscriptionRequestResource`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
68
95
  end
69
96
  h[k.to_sym] = v
70
97
  }
71
98
 
99
+ if attributes.key?(:'id')
100
+ self.id = attributes[:'id']
101
+ end
102
+
72
103
  if attributes.key?(:'type')
73
104
  self.type = attributes[:'type']
74
105
  else
@@ -103,17 +134,19 @@ module SmplkitGeneratedClient::App
103
134
  def valid?
104
135
  warn '[DEPRECATED] the `valid?` method is obsolete'
105
136
  return false if @type.nil?
137
+ type_validator = EnumAttributeValidator.new('String', ["subscription"])
138
+ return false unless type_validator.valid?(@type)
106
139
  return false if @attributes.nil?
107
140
  true
108
141
  end
109
142
 
110
- # Custom attribute writer method with validation
111
- # @param [Object] type Value to be assigned
143
+ # Custom attribute writer method checking allowed values (enum).
144
+ # @param [Object] type Object to be assigned
112
145
  def type=(type)
113
- if type.nil?
114
- fail ArgumentError, 'type cannot be nil'
146
+ validator = EnumAttributeValidator.new('String', ["subscription"])
147
+ unless validator.valid?(type)
148
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
115
149
  end
116
-
117
150
  @type = type
118
151
  end
119
152
 
@@ -132,6 +165,7 @@ module SmplkitGeneratedClient::App
132
165
  def ==(o)
133
166
  return true if self.equal?(o)
134
167
  self.class == o.class &&
168
+ id == o.id &&
135
169
  type == o.type &&
136
170
  attributes == o.attributes
137
171
  end
@@ -145,7 +179,7 @@ module SmplkitGeneratedClient::App
145
179
  # Calculates hash code according to all attributes.
146
180
  # @return [Integer] Hash code
147
181
  def hash
148
- [type, attributes].hash
182
+ [id, type, attributes].hash
149
183
  end
150
184
 
151
185
  # Builds the object from hash