shipeasy-sdk 2.1.0 → 2.3.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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/docs/skill/SKILL.md +6 -2
- data/lib/generators/shipeasy/install/USAGE +24 -0
- data/lib/generators/shipeasy/install/install_generator.rb +86 -0
- data/lib/generators/shipeasy/install/templates/initializer.rb.tt +41 -0
- data/lib/shipeasy/admin.rb +85 -0
- data/lib/shipeasy/sdk/version.rb +1 -1
- data/lib/shipeasy_admin/api/alert_rules_api.rb +292 -0
- data/lib/shipeasy_admin/api/attributes_api.rb +82 -0
- data/lib/shipeasy_admin/api/configs_api.rb +680 -0
- data/lib/shipeasy_admin/api/events_api.rb +438 -0
- data/lib/shipeasy_admin/api/experiments_api.rb +727 -0
- data/lib/shipeasy_admin/api/gates_api.rb +438 -0
- data/lib/shipeasy_admin/api/i18n_api.rb +507 -0
- data/lib/shipeasy_admin/api/killswitches_api.rb +526 -0
- data/lib/shipeasy_admin/api/metrics_api.rb +281 -0
- data/lib/shipeasy_admin/api/ops_api.rb +525 -0
- data/lib/shipeasy_admin/api/projects_api.rb +153 -0
- data/lib/shipeasy_admin/api/universes_api.rb +306 -0
- data/lib/shipeasy_admin/api_client.rb +441 -0
- data/lib/shipeasy_admin/api_error.rb +58 -0
- data/lib/shipeasy_admin/api_model_base.rb +88 -0
- data/lib/shipeasy_admin/configuration.rb +397 -0
- data/lib/shipeasy_admin/models/approve_event_request.rb +198 -0
- data/lib/shipeasy_admin/models/approve_event_response.rb +166 -0
- data/lib/shipeasy_admin/models/create_alert_rule_request.rb +408 -0
- data/lib/shipeasy_admin/models/create_alert_rule_response.rb +165 -0
- data/lib/shipeasy_admin/models/create_config_request.rb +280 -0
- data/lib/shipeasy_admin/models/create_config_response.rb +201 -0
- data/lib/shipeasy_admin/models/create_event_request.rb +253 -0
- data/lib/shipeasy_admin/models/create_event_response.rb +193 -0
- data/lib/shipeasy_admin/models/create_experiment_request.rb +869 -0
- data/lib/shipeasy_admin/models/create_experiment_request_goal_metric.rb +336 -0
- data/lib/shipeasy_admin/models/create_experiment_response.rb +212 -0
- data/lib/shipeasy_admin/models/create_gate_request.rb +529 -0
- data/lib/shipeasy_admin/models/create_gate_response.rb +212 -0
- data/lib/shipeasy_admin/models/create_i18n_profile_request.rb +188 -0
- data/lib/shipeasy_admin/models/create_i18n_profile_response.rb +193 -0
- data/lib/shipeasy_admin/models/create_killswitch_request.rb +263 -0
- data/lib/shipeasy_admin/models/create_killswitch_response.rb +201 -0
- data/lib/shipeasy_admin/models/create_metric_request.rb +415 -0
- data/lib/shipeasy_admin/models/create_metric_response.rb +193 -0
- data/lib/shipeasy_admin/models/create_ops_item_request.rb +287 -0
- data/lib/shipeasy_admin/models/create_ops_item_response.rb +177 -0
- data/lib/shipeasy_admin/models/create_universe_request.rb +289 -0
- data/lib/shipeasy_admin/models/create_universe_response.rb +212 -0
- data/lib/shipeasy_admin/models/delete_alert_rule_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_config_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_event_response.rb +189 -0
- data/lib/shipeasy_admin/models/delete_experiment_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_gate_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_killswitch_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_metric_response.rb +189 -0
- data/lib/shipeasy_admin/models/delete_universe_response.rb +188 -0
- data/lib/shipeasy_admin/models/disable_gate_response.rb +190 -0
- data/lib/shipeasy_admin/models/discard_config_draft_request.rb +190 -0
- data/lib/shipeasy_admin/models/discard_config_draft_response.rb +188 -0
- data/lib/shipeasy_admin/models/enable_gate_response.rb +190 -0
- data/lib/shipeasy_admin/models/error_response.rb +185 -0
- data/lib/shipeasy_admin/models/get_config_response.rb +351 -0
- data/lib/shipeasy_admin/models/get_current_project_response.rb +606 -0
- data/lib/shipeasy_admin/models/get_current_project_response_module_translations.rb +104 -0
- data/lib/shipeasy_admin/models/get_event_response.rb +344 -0
- data/lib/shipeasy_admin/models/get_experiment_response.rb +688 -0
- data/lib/shipeasy_admin/models/get_experiment_results_response.rb +243 -0
- data/lib/shipeasy_admin/models/get_experiment_results_response_experiment.rb +248 -0
- data/lib/shipeasy_admin/models/get_experiment_results_response_results_inner.rb +252 -0
- data/lib/shipeasy_admin/models/get_experiment_timeseries_response.rb +192 -0
- data/lib/shipeasy_admin/models/get_experiment_timeseries_response_experiment.rb +261 -0
- data/lib/shipeasy_admin/models/get_experiment_timeseries_response_series_inner.rb +278 -0
- data/lib/shipeasy_admin/models/get_killswitch_response.rb +270 -0
- data/lib/shipeasy_admin/models/get_metric_response.rb +378 -0
- data/lib/shipeasy_admin/models/get_ops_item_response.rb +349 -0
- data/lib/shipeasy_admin/models/link_pr_to_ops_item_request.rb +186 -0
- data/lib/shipeasy_admin/models/link_pr_to_ops_item_response.rb +166 -0
- data/lib/shipeasy_admin/models/list_alert_rules_response_inner.rb +478 -0
- data/lib/shipeasy_admin/models/list_alert_rules_response_inner_notify.rb +177 -0
- data/lib/shipeasy_admin/models/list_alert_rules_response_inner_notify_slack_channel.rb +211 -0
- data/lib/shipeasy_admin/models/list_attributes_response_inner.rb +176 -0
- data/lib/shipeasy_admin/models/list_config_activity_response_inner.rb +280 -0
- data/lib/shipeasy_admin/models/list_configs_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_configs_response_data_inner.rb +351 -0
- data/lib/shipeasy_admin/models/list_configs_response_data_inner_drafts_value.rb +237 -0
- data/lib/shipeasy_admin/models/list_configs_response_data_inner_envs_value.rb +237 -0
- data/lib/shipeasy_admin/models/list_events_response_inner.rb +344 -0
- data/lib/shipeasy_admin/models/list_events_response_inner_properties_inner.rb +289 -0
- data/lib/shipeasy_admin/models/list_experiments_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_experiments_response_data_inner.rb +688 -0
- data/lib/shipeasy_admin/models/list_experiments_response_data_inner_groups_inner.rb +258 -0
- data/lib/shipeasy_admin/models/list_gates_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner.rb +395 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_enabled.rb +104 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_rules_inner.rb +238 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner.rb +105 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb +375 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb +331 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of_ramp.rb +319 -0
- data/lib/shipeasy_admin/models/list_i18n_drafts_response_inner.rb +272 -0
- data/lib/shipeasy_admin/models/list_i18n_keys_response.rb +195 -0
- data/lib/shipeasy_admin/models/list_i18n_keys_response_keys_inner.rb +284 -0
- data/lib/shipeasy_admin/models/list_i18n_profiles_response_inner.rb +224 -0
- data/lib/shipeasy_admin/models/list_killswitches_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_killswitches_response_data_inner.rb +270 -0
- data/lib/shipeasy_admin/models/list_killswitches_response_data_inner_envs_value.rb +248 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner.rb +378 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir.rb +295 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg.rb +113 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of1.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of2.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of3.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of4.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of5.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of6.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of7.rb +217 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of8.rb +233 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of9.rb +240 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of9_numerator.rb +266 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of9_numerator_filters_inner.rb +264 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_group_by.rb +228 -0
- data/lib/shipeasy_admin/models/list_ops_items_response_inner.rb +349 -0
- data/lib/shipeasy_admin/models/list_slack_channels_response.rb +195 -0
- data/lib/shipeasy_admin/models/list_slack_channels_response_channels_inner.rb +203 -0
- data/lib/shipeasy_admin/models/list_universes_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_universes_response_data_inner.rb +305 -0
- data/lib/shipeasy_admin/models/notify_ops_request.rb +261 -0
- data/lib/shipeasy_admin/models/notify_ops_response.rb +193 -0
- data/lib/shipeasy_admin/models/publish_config_draft_request.rb +190 -0
- data/lib/shipeasy_admin/models/publish_config_draft_response.rb +260 -0
- data/lib/shipeasy_admin/models/publish_i18n_profile_request.rb +149 -0
- data/lib/shipeasy_admin/models/publish_i18n_profile_response.rb +404 -0
- data/lib/shipeasy_admin/models/push_i18n_keys_request.rb +205 -0
- data/lib/shipeasy_admin/models/push_i18n_keys_request_keys_inner.rb +192 -0
- data/lib/shipeasy_admin/models/push_i18n_keys_response.rb +261 -0
- data/lib/shipeasy_admin/models/reanalyze_experiment_response.rb +214 -0
- data/lib/shipeasy_admin/models/save_config_draft_request.rb +202 -0
- data/lib/shipeasy_admin/models/save_config_draft_response.rb +286 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_request.rb +168 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_request_metrics_inner.rb +216 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_response.rb +179 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_response_metrics_inner.rb +201 -0
- data/lib/shipeasy_admin/models/set_experiment_status_request.rb +190 -0
- data/lib/shipeasy_admin/models/set_experiment_status_response.rb +214 -0
- data/lib/shipeasy_admin/models/set_killswitch_switch_request.rb +264 -0
- data/lib/shipeasy_admin/models/set_killswitch_switch_response.rb +288 -0
- data/lib/shipeasy_admin/models/unset_killswitch_switch_request.rb +237 -0
- data/lib/shipeasy_admin/models/unset_killswitch_switch_response.rb +289 -0
- data/lib/shipeasy_admin/models/update_alert_rule_request.rb +306 -0
- data/lib/shipeasy_admin/models/update_alert_rule_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_config_request.rb +198 -0
- data/lib/shipeasy_admin/models/update_config_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_event_request.rb +198 -0
- data/lib/shipeasy_admin/models/update_event_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_experiment_request.rb +746 -0
- data/lib/shipeasy_admin/models/update_experiment_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_gate_request.rb +403 -0
- data/lib/shipeasy_admin/models/update_gate_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_i18n_key_request.rb +176 -0
- data/lib/shipeasy_admin/models/update_i18n_key_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_killswitch_request.rb +224 -0
- data/lib/shipeasy_admin/models/update_killswitch_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_ops_item_request.rb +205 -0
- data/lib/shipeasy_admin/models/update_ops_item_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_universe_request.rb +213 -0
- data/lib/shipeasy_admin/models/update_universe_response.rb +165 -0
- data/lib/shipeasy_admin/models/upsert_project_request.rb +222 -0
- data/lib/shipeasy_admin/models/upsert_project_response.rb +260 -0
- data/lib/shipeasy_admin/version.rb +15 -0
- data/lib/shipeasy_admin.rb +196 -0
- metadata +230 -2
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Shipeasy Admin API
|
|
3
|
+
|
|
4
|
+
#REST API for managing feature gates, experiments, configs, universes, and killswitches in a Shipeasy project. Authenticate with an admin SDK key (`Authorization: Bearer sdk_admin_…`) and scope every request to a project via the `X-Project-Id` header. Mint admin keys via `POST /api/admin/keys` with `type: \"admin\"`. Keys expire after 90 days; rotate with the `revoke` action.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.23.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Shipeasy::Admin::Generated
|
|
17
|
+
# The project the caller's auth header resolves to. The shape is open — additional project fields may be present.
|
|
18
|
+
class GetCurrentProjectResponse < ApiModelBase
|
|
19
|
+
# Stable opaque project id.
|
|
20
|
+
attr_accessor :id
|
|
21
|
+
|
|
22
|
+
# Project name.
|
|
23
|
+
attr_accessor :name
|
|
24
|
+
|
|
25
|
+
# Project domain, or `null` if unset.
|
|
26
|
+
attr_accessor :domain
|
|
27
|
+
|
|
28
|
+
# Email of the account that owns the project.
|
|
29
|
+
attr_accessor :owner_email
|
|
30
|
+
|
|
31
|
+
# Billing plan tier.
|
|
32
|
+
attr_accessor :plan
|
|
33
|
+
|
|
34
|
+
# Project lifecycle status.
|
|
35
|
+
attr_accessor :status
|
|
36
|
+
|
|
37
|
+
# Stripe subscription status (`none`, `active`, `trialing`, `past_due`, …).
|
|
38
|
+
attr_accessor :subscription_status
|
|
39
|
+
|
|
40
|
+
# Billing cadence.
|
|
41
|
+
attr_accessor :billing_interval
|
|
42
|
+
|
|
43
|
+
# ISO-8601 end of the current billing period, or `null`.
|
|
44
|
+
attr_accessor :current_period_end
|
|
45
|
+
|
|
46
|
+
# ISO-8601 trial end, or `null` if not trialing.
|
|
47
|
+
attr_accessor :trial_ends_at
|
|
48
|
+
|
|
49
|
+
# `1` if the subscription is set to cancel at period end, else `0`.
|
|
50
|
+
attr_accessor :cancel_at_period_end
|
|
51
|
+
|
|
52
|
+
attr_accessor :module_translations
|
|
53
|
+
|
|
54
|
+
attr_accessor :module_configs
|
|
55
|
+
|
|
56
|
+
attr_accessor :module_gates
|
|
57
|
+
|
|
58
|
+
attr_accessor :module_experiments
|
|
59
|
+
|
|
60
|
+
attr_accessor :module_feedback
|
|
61
|
+
|
|
62
|
+
# ISO-8601 timestamp of project creation.
|
|
63
|
+
attr_accessor :created_at
|
|
64
|
+
|
|
65
|
+
# ISO-8601 timestamp of last update.
|
|
66
|
+
attr_accessor :updated_at
|
|
67
|
+
|
|
68
|
+
class EnumAttributeValidator
|
|
69
|
+
attr_reader :datatype
|
|
70
|
+
attr_reader :allowable_values
|
|
71
|
+
|
|
72
|
+
def initialize(datatype, allowable_values)
|
|
73
|
+
@allowable_values = allowable_values.map do |value|
|
|
74
|
+
case datatype.to_s
|
|
75
|
+
when /Integer/i
|
|
76
|
+
value.to_i
|
|
77
|
+
when /Float/i
|
|
78
|
+
value.to_f
|
|
79
|
+
else
|
|
80
|
+
value
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def valid?(value)
|
|
86
|
+
!value || allowable_values.include?(value)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
91
|
+
def self.attribute_map
|
|
92
|
+
{
|
|
93
|
+
:'id' => :'id',
|
|
94
|
+
:'name' => :'name',
|
|
95
|
+
:'domain' => :'domain',
|
|
96
|
+
:'owner_email' => :'ownerEmail',
|
|
97
|
+
:'plan' => :'plan',
|
|
98
|
+
:'status' => :'status',
|
|
99
|
+
:'subscription_status' => :'subscriptionStatus',
|
|
100
|
+
:'billing_interval' => :'billingInterval',
|
|
101
|
+
:'current_period_end' => :'currentPeriodEnd',
|
|
102
|
+
:'trial_ends_at' => :'trialEndsAt',
|
|
103
|
+
:'cancel_at_period_end' => :'cancelAtPeriodEnd',
|
|
104
|
+
:'module_translations' => :'moduleTranslations',
|
|
105
|
+
:'module_configs' => :'moduleConfigs',
|
|
106
|
+
:'module_gates' => :'moduleGates',
|
|
107
|
+
:'module_experiments' => :'moduleExperiments',
|
|
108
|
+
:'module_feedback' => :'moduleFeedback',
|
|
109
|
+
:'created_at' => :'createdAt',
|
|
110
|
+
:'updated_at' => :'updatedAt'
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Returns attribute mapping this model knows about
|
|
115
|
+
def self.acceptable_attribute_map
|
|
116
|
+
attribute_map
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Returns all the JSON keys this model knows about
|
|
120
|
+
def self.acceptable_attributes
|
|
121
|
+
acceptable_attribute_map.values
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Attribute type mapping.
|
|
125
|
+
def self.openapi_types
|
|
126
|
+
{
|
|
127
|
+
:'id' => :'String',
|
|
128
|
+
:'name' => :'String',
|
|
129
|
+
:'domain' => :'String',
|
|
130
|
+
:'owner_email' => :'String',
|
|
131
|
+
:'plan' => :'String',
|
|
132
|
+
:'status' => :'String',
|
|
133
|
+
:'subscription_status' => :'String',
|
|
134
|
+
:'billing_interval' => :'String',
|
|
135
|
+
:'current_period_end' => :'String',
|
|
136
|
+
:'trial_ends_at' => :'String',
|
|
137
|
+
:'cancel_at_period_end' => :'Float',
|
|
138
|
+
:'module_translations' => :'GetCurrentProjectResponseModuleTranslations',
|
|
139
|
+
:'module_configs' => :'GetCurrentProjectResponseModuleTranslations',
|
|
140
|
+
:'module_gates' => :'GetCurrentProjectResponseModuleTranslations',
|
|
141
|
+
:'module_experiments' => :'GetCurrentProjectResponseModuleTranslations',
|
|
142
|
+
:'module_feedback' => :'GetCurrentProjectResponseModuleTranslations',
|
|
143
|
+
:'created_at' => :'String',
|
|
144
|
+
:'updated_at' => :'String'
|
|
145
|
+
}
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# List of attributes with nullable: true
|
|
149
|
+
def self.openapi_nullable
|
|
150
|
+
Set.new([
|
|
151
|
+
:'domain',
|
|
152
|
+
:'current_period_end',
|
|
153
|
+
:'trial_ends_at',
|
|
154
|
+
])
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Initializes the object
|
|
158
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
159
|
+
def initialize(attributes = {})
|
|
160
|
+
if (!attributes.is_a?(Hash))
|
|
161
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Shipeasy::Admin::Generated::GetCurrentProjectResponse` initialize method"
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
165
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
166
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
167
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
168
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Shipeasy::Admin::Generated::GetCurrentProjectResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
169
|
+
end
|
|
170
|
+
h[k.to_sym] = v
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if attributes.key?(:'id')
|
|
174
|
+
self.id = attributes[:'id']
|
|
175
|
+
else
|
|
176
|
+
self.id = nil
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if attributes.key?(:'name')
|
|
180
|
+
self.name = attributes[:'name']
|
|
181
|
+
else
|
|
182
|
+
self.name = nil
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
if attributes.key?(:'domain')
|
|
186
|
+
self.domain = attributes[:'domain']
|
|
187
|
+
else
|
|
188
|
+
self.domain = nil
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
if attributes.key?(:'owner_email')
|
|
192
|
+
self.owner_email = attributes[:'owner_email']
|
|
193
|
+
else
|
|
194
|
+
self.owner_email = nil
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
if attributes.key?(:'plan')
|
|
198
|
+
self.plan = attributes[:'plan']
|
|
199
|
+
else
|
|
200
|
+
self.plan = nil
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
if attributes.key?(:'status')
|
|
204
|
+
self.status = attributes[:'status']
|
|
205
|
+
else
|
|
206
|
+
self.status = nil
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
if attributes.key?(:'subscription_status')
|
|
210
|
+
self.subscription_status = attributes[:'subscription_status']
|
|
211
|
+
else
|
|
212
|
+
self.subscription_status = nil
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
if attributes.key?(:'billing_interval')
|
|
216
|
+
self.billing_interval = attributes[:'billing_interval']
|
|
217
|
+
else
|
|
218
|
+
self.billing_interval = nil
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
if attributes.key?(:'current_period_end')
|
|
222
|
+
self.current_period_end = attributes[:'current_period_end']
|
|
223
|
+
else
|
|
224
|
+
self.current_period_end = nil
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
if attributes.key?(:'trial_ends_at')
|
|
228
|
+
self.trial_ends_at = attributes[:'trial_ends_at']
|
|
229
|
+
else
|
|
230
|
+
self.trial_ends_at = nil
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
if attributes.key?(:'cancel_at_period_end')
|
|
234
|
+
self.cancel_at_period_end = attributes[:'cancel_at_period_end']
|
|
235
|
+
else
|
|
236
|
+
self.cancel_at_period_end = nil
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
if attributes.key?(:'module_translations')
|
|
240
|
+
self.module_translations = attributes[:'module_translations']
|
|
241
|
+
else
|
|
242
|
+
self.module_translations = nil
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
if attributes.key?(:'module_configs')
|
|
246
|
+
self.module_configs = attributes[:'module_configs']
|
|
247
|
+
else
|
|
248
|
+
self.module_configs = nil
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
if attributes.key?(:'module_gates')
|
|
252
|
+
self.module_gates = attributes[:'module_gates']
|
|
253
|
+
else
|
|
254
|
+
self.module_gates = nil
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
if attributes.key?(:'module_experiments')
|
|
258
|
+
self.module_experiments = attributes[:'module_experiments']
|
|
259
|
+
else
|
|
260
|
+
self.module_experiments = nil
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
if attributes.key?(:'module_feedback')
|
|
264
|
+
self.module_feedback = attributes[:'module_feedback']
|
|
265
|
+
else
|
|
266
|
+
self.module_feedback = nil
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
if attributes.key?(:'created_at')
|
|
270
|
+
self.created_at = attributes[:'created_at']
|
|
271
|
+
else
|
|
272
|
+
self.created_at = nil
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
if attributes.key?(:'updated_at')
|
|
276
|
+
self.updated_at = attributes[:'updated_at']
|
|
277
|
+
else
|
|
278
|
+
self.updated_at = nil
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
283
|
+
# @return Array for valid properties with the reasons
|
|
284
|
+
def list_invalid_properties
|
|
285
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
286
|
+
invalid_properties = Array.new
|
|
287
|
+
if @id.nil?
|
|
288
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
if @name.nil?
|
|
292
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
if @owner_email.nil?
|
|
296
|
+
invalid_properties.push('invalid value for "owner_email", owner_email cannot be nil.')
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
if @plan.nil?
|
|
300
|
+
invalid_properties.push('invalid value for "plan", plan cannot be nil.')
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
if @status.nil?
|
|
304
|
+
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
if @subscription_status.nil?
|
|
308
|
+
invalid_properties.push('invalid value for "subscription_status", subscription_status cannot be nil.')
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
if @billing_interval.nil?
|
|
312
|
+
invalid_properties.push('invalid value for "billing_interval", billing_interval cannot be nil.')
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
if @cancel_at_period_end.nil?
|
|
316
|
+
invalid_properties.push('invalid value for "cancel_at_period_end", cancel_at_period_end cannot be nil.')
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
if @module_translations.nil?
|
|
320
|
+
invalid_properties.push('invalid value for "module_translations", module_translations cannot be nil.')
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
if @module_configs.nil?
|
|
324
|
+
invalid_properties.push('invalid value for "module_configs", module_configs cannot be nil.')
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
if @module_gates.nil?
|
|
328
|
+
invalid_properties.push('invalid value for "module_gates", module_gates cannot be nil.')
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
if @module_experiments.nil?
|
|
332
|
+
invalid_properties.push('invalid value for "module_experiments", module_experiments cannot be nil.')
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
if @module_feedback.nil?
|
|
336
|
+
invalid_properties.push('invalid value for "module_feedback", module_feedback cannot be nil.')
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
if @created_at.nil?
|
|
340
|
+
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
if @updated_at.nil?
|
|
344
|
+
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
invalid_properties
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# Check to see if the all the properties in the model are valid
|
|
351
|
+
# @return true if the model is valid
|
|
352
|
+
def valid?
|
|
353
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
354
|
+
return false if @id.nil?
|
|
355
|
+
return false if @name.nil?
|
|
356
|
+
return false if @owner_email.nil?
|
|
357
|
+
return false if @plan.nil?
|
|
358
|
+
plan_validator = EnumAttributeValidator.new('String', ["free", "paid"])
|
|
359
|
+
return false unless plan_validator.valid?(@plan)
|
|
360
|
+
return false if @status.nil?
|
|
361
|
+
status_validator = EnumAttributeValidator.new('String', ["active", "inactive"])
|
|
362
|
+
return false unless status_validator.valid?(@status)
|
|
363
|
+
return false if @subscription_status.nil?
|
|
364
|
+
return false if @billing_interval.nil?
|
|
365
|
+
billing_interval_validator = EnumAttributeValidator.new('String', ["monthly", "annual"])
|
|
366
|
+
return false unless billing_interval_validator.valid?(@billing_interval)
|
|
367
|
+
return false if @cancel_at_period_end.nil?
|
|
368
|
+
return false if @module_translations.nil?
|
|
369
|
+
return false if @module_configs.nil?
|
|
370
|
+
return false if @module_gates.nil?
|
|
371
|
+
return false if @module_experiments.nil?
|
|
372
|
+
return false if @module_feedback.nil?
|
|
373
|
+
return false if @created_at.nil?
|
|
374
|
+
return false if @updated_at.nil?
|
|
375
|
+
true
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# Custom attribute writer method with validation
|
|
379
|
+
# @param [Object] id Value to be assigned
|
|
380
|
+
def id=(id)
|
|
381
|
+
if id.nil?
|
|
382
|
+
fail ArgumentError, 'id cannot be nil'
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
@id = id
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# Custom attribute writer method with validation
|
|
389
|
+
# @param [Object] name Value to be assigned
|
|
390
|
+
def name=(name)
|
|
391
|
+
if name.nil?
|
|
392
|
+
fail ArgumentError, 'name cannot be nil'
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
@name = name
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
# Custom attribute writer method with validation
|
|
399
|
+
# @param [Object] owner_email Value to be assigned
|
|
400
|
+
def owner_email=(owner_email)
|
|
401
|
+
if owner_email.nil?
|
|
402
|
+
fail ArgumentError, 'owner_email cannot be nil'
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
@owner_email = owner_email
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
409
|
+
# @param [Object] plan Object to be assigned
|
|
410
|
+
def plan=(plan)
|
|
411
|
+
validator = EnumAttributeValidator.new('String', ["free", "paid"])
|
|
412
|
+
unless validator.valid?(plan)
|
|
413
|
+
fail ArgumentError, "invalid value for \"plan\", must be one of #{validator.allowable_values}."
|
|
414
|
+
end
|
|
415
|
+
@plan = plan
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
419
|
+
# @param [Object] status Object to be assigned
|
|
420
|
+
def status=(status)
|
|
421
|
+
validator = EnumAttributeValidator.new('String', ["active", "inactive"])
|
|
422
|
+
unless validator.valid?(status)
|
|
423
|
+
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
|
424
|
+
end
|
|
425
|
+
@status = status
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Custom attribute writer method with validation
|
|
429
|
+
# @param [Object] subscription_status Value to be assigned
|
|
430
|
+
def subscription_status=(subscription_status)
|
|
431
|
+
if subscription_status.nil?
|
|
432
|
+
fail ArgumentError, 'subscription_status cannot be nil'
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
@subscription_status = subscription_status
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
439
|
+
# @param [Object] billing_interval Object to be assigned
|
|
440
|
+
def billing_interval=(billing_interval)
|
|
441
|
+
validator = EnumAttributeValidator.new('String', ["monthly", "annual"])
|
|
442
|
+
unless validator.valid?(billing_interval)
|
|
443
|
+
fail ArgumentError, "invalid value for \"billing_interval\", must be one of #{validator.allowable_values}."
|
|
444
|
+
end
|
|
445
|
+
@billing_interval = billing_interval
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
# Custom attribute writer method with validation
|
|
449
|
+
# @param [Object] cancel_at_period_end Value to be assigned
|
|
450
|
+
def cancel_at_period_end=(cancel_at_period_end)
|
|
451
|
+
if cancel_at_period_end.nil?
|
|
452
|
+
fail ArgumentError, 'cancel_at_period_end cannot be nil'
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
@cancel_at_period_end = cancel_at_period_end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
# Custom attribute writer method with validation
|
|
459
|
+
# @param [Object] module_translations Value to be assigned
|
|
460
|
+
def module_translations=(module_translations)
|
|
461
|
+
if module_translations.nil?
|
|
462
|
+
fail ArgumentError, 'module_translations cannot be nil'
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
@module_translations = module_translations
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
# Custom attribute writer method with validation
|
|
469
|
+
# @param [Object] module_configs Value to be assigned
|
|
470
|
+
def module_configs=(module_configs)
|
|
471
|
+
if module_configs.nil?
|
|
472
|
+
fail ArgumentError, 'module_configs cannot be nil'
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
@module_configs = module_configs
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
# Custom attribute writer method with validation
|
|
479
|
+
# @param [Object] module_gates Value to be assigned
|
|
480
|
+
def module_gates=(module_gates)
|
|
481
|
+
if module_gates.nil?
|
|
482
|
+
fail ArgumentError, 'module_gates cannot be nil'
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
@module_gates = module_gates
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
# Custom attribute writer method with validation
|
|
489
|
+
# @param [Object] module_experiments Value to be assigned
|
|
490
|
+
def module_experiments=(module_experiments)
|
|
491
|
+
if module_experiments.nil?
|
|
492
|
+
fail ArgumentError, 'module_experiments cannot be nil'
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
@module_experiments = module_experiments
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Custom attribute writer method with validation
|
|
499
|
+
# @param [Object] module_feedback Value to be assigned
|
|
500
|
+
def module_feedback=(module_feedback)
|
|
501
|
+
if module_feedback.nil?
|
|
502
|
+
fail ArgumentError, 'module_feedback cannot be nil'
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
@module_feedback = module_feedback
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
# Custom attribute writer method with validation
|
|
509
|
+
# @param [Object] created_at Value to be assigned
|
|
510
|
+
def created_at=(created_at)
|
|
511
|
+
if created_at.nil?
|
|
512
|
+
fail ArgumentError, 'created_at cannot be nil'
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
@created_at = created_at
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
# Custom attribute writer method with validation
|
|
519
|
+
# @param [Object] updated_at Value to be assigned
|
|
520
|
+
def updated_at=(updated_at)
|
|
521
|
+
if updated_at.nil?
|
|
522
|
+
fail ArgumentError, 'updated_at cannot be nil'
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
@updated_at = updated_at
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
# Checks equality by comparing each attribute.
|
|
529
|
+
# @param [Object] Object to be compared
|
|
530
|
+
def ==(o)
|
|
531
|
+
return true if self.equal?(o)
|
|
532
|
+
self.class == o.class &&
|
|
533
|
+
id == o.id &&
|
|
534
|
+
name == o.name &&
|
|
535
|
+
domain == o.domain &&
|
|
536
|
+
owner_email == o.owner_email &&
|
|
537
|
+
plan == o.plan &&
|
|
538
|
+
status == o.status &&
|
|
539
|
+
subscription_status == o.subscription_status &&
|
|
540
|
+
billing_interval == o.billing_interval &&
|
|
541
|
+
current_period_end == o.current_period_end &&
|
|
542
|
+
trial_ends_at == o.trial_ends_at &&
|
|
543
|
+
cancel_at_period_end == o.cancel_at_period_end &&
|
|
544
|
+
module_translations == o.module_translations &&
|
|
545
|
+
module_configs == o.module_configs &&
|
|
546
|
+
module_gates == o.module_gates &&
|
|
547
|
+
module_experiments == o.module_experiments &&
|
|
548
|
+
module_feedback == o.module_feedback &&
|
|
549
|
+
created_at == o.created_at &&
|
|
550
|
+
updated_at == o.updated_at
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
# @see the `==` method
|
|
554
|
+
# @param [Object] Object to be compared
|
|
555
|
+
def eql?(o)
|
|
556
|
+
self == o
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
# Calculates hash code according to all attributes.
|
|
560
|
+
# @return [Integer] Hash code
|
|
561
|
+
def hash
|
|
562
|
+
[id, name, domain, owner_email, plan, status, subscription_status, billing_interval, current_period_end, trial_ends_at, cancel_at_period_end, module_translations, module_configs, module_gates, module_experiments, module_feedback, created_at, updated_at].hash
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
# Builds the object from hash
|
|
566
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
567
|
+
# @return [Object] Returns the model itself
|
|
568
|
+
def self.build_from_hash(attributes)
|
|
569
|
+
return nil unless attributes.is_a?(Hash)
|
|
570
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
571
|
+
transformed_hash = {}
|
|
572
|
+
openapi_types.each_pair do |key, type|
|
|
573
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
574
|
+
transformed_hash["#{key}"] = nil
|
|
575
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
576
|
+
# check to ensure the input is an array given that the attribute
|
|
577
|
+
# is documented as an array but the input is not
|
|
578
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
579
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
580
|
+
end
|
|
581
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
582
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
583
|
+
end
|
|
584
|
+
end
|
|
585
|
+
new(transformed_hash)
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
# Returns the object in the form of hash
|
|
589
|
+
# @return [Hash] Returns the object in the form of hash
|
|
590
|
+
def to_hash
|
|
591
|
+
hash = {}
|
|
592
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
593
|
+
value = self.send(attr)
|
|
594
|
+
if value.nil?
|
|
595
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
596
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
hash[param] = _to_hash(value)
|
|
600
|
+
end
|
|
601
|
+
hash
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
end
|
|
605
|
+
|
|
606
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Shipeasy Admin API
|
|
3
|
+
|
|
4
|
+
#REST API for managing feature gates, experiments, configs, universes, and killswitches in a Shipeasy project. Authenticate with an admin SDK key (`Authorization: Bearer sdk_admin_…`) and scope every request to a project via the `X-Project-Id` header. Mint admin keys via `POST /api/admin/keys` with `type: \"admin\"`. Keys expire after 90 days; rotate with the `revoke` action.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.23.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Shipeasy::Admin::Generated
|
|
17
|
+
# Whether the i18n/translations module is enabled.
|
|
18
|
+
module GetCurrentProjectResponseModuleTranslations
|
|
19
|
+
class << self
|
|
20
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
21
|
+
def openapi_any_of
|
|
22
|
+
[
|
|
23
|
+
:'Boolean',
|
|
24
|
+
:'Float'
|
|
25
|
+
]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the object
|
|
29
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
30
|
+
# @return [Object] Returns the model or the data itself
|
|
31
|
+
def build(data)
|
|
32
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
|
33
|
+
# Note:
|
|
34
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
+
# - TODO: logging when debugging is set.
|
|
38
|
+
openapi_any_of.each do |klass|
|
|
39
|
+
begin
|
|
40
|
+
next if klass == :AnyType # "nullable: true"
|
|
41
|
+
return find_and_cast_into_type(klass, data)
|
|
42
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
52
|
+
|
|
53
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
54
|
+
def find_and_cast_into_type(klass, data)
|
|
55
|
+
return if data.nil?
|
|
56
|
+
|
|
57
|
+
case klass.to_s
|
|
58
|
+
when 'Boolean'
|
|
59
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
60
|
+
when 'Float'
|
|
61
|
+
return data if data.instance_of?(Float)
|
|
62
|
+
when 'Integer'
|
|
63
|
+
return data if data.instance_of?(Integer)
|
|
64
|
+
when 'Time'
|
|
65
|
+
return Time.parse(data)
|
|
66
|
+
when 'Date'
|
|
67
|
+
return Date.iso8601(data)
|
|
68
|
+
when 'String'
|
|
69
|
+
return data if data.instance_of?(String)
|
|
70
|
+
when 'Object' # "type: object"
|
|
71
|
+
return data if data.instance_of?(Hash)
|
|
72
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
73
|
+
if data.instance_of?(Array)
|
|
74
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
75
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
76
|
+
end
|
|
77
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
78
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
79
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
80
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
81
|
+
end
|
|
82
|
+
else # model
|
|
83
|
+
const = Shipeasy::Admin::Generated.const_get(klass)
|
|
84
|
+
if const
|
|
85
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
86
|
+
model = const.build(data)
|
|
87
|
+
return model if model
|
|
88
|
+
else
|
|
89
|
+
# raise if data contains keys that are not known to the model
|
|
90
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
91
|
+
model = const.build_from_hash(data)
|
|
92
|
+
return model if model
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
raise # if no match by now, raise
|
|
98
|
+
rescue
|
|
99
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|