svix 1.24.0 → 1.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/lib/svix/api/authentication_api.rb +87 -0
  4. data/lib/svix/api/endpoint_api.rb +277 -2
  5. data/lib/svix/api/events_api.rb +3 -3
  6. data/lib/svix/api/message_api.rb +317 -101
  7. data/lib/svix/api/transformation_template_api.rb +195 -24
  8. data/lib/svix/models/auth_token_out.rb +284 -0
  9. data/lib/svix/models/create_message_token_in.rb +250 -0
  10. data/lib/svix/models/create_stream_in.rb +225 -0
  11. data/lib/svix/models/endpoint_created_event_data.rb +1 -0
  12. data/lib/svix/models/endpoint_deleted_event_data.rb +1 -0
  13. data/lib/svix/models/endpoint_mtls_config_in.rb +15 -19
  14. data/lib/svix/models/endpoint_oauth_config_in.rb +13 -2
  15. data/lib/svix/models/endpoint_updated_event_data.rb +1 -0
  16. data/lib/svix/models/environment_settings_out.rb +15 -4
  17. data/lib/svix/models/event_in.rb +223 -0
  18. data/lib/svix/models/event_out.rb +237 -0
  19. data/lib/svix/models/event_stream_out.rb +253 -0
  20. data/lib/svix/models/event_type_from_open_api.rb +280 -0
  21. data/lib/svix/models/event_type_import_open_api_in.rb +13 -1
  22. data/lib/svix/models/event_type_import_open_api_out_data.rb +16 -4
  23. data/lib/svix/models/event_type_in.rb +38 -1
  24. data/lib/svix/models/event_type_out.rb +38 -1
  25. data/lib/svix/models/event_type_patch.rb +38 -1
  26. data/lib/svix/models/event_type_update.rb +38 -1
  27. data/lib/svix/models/hubspot_oauth_config_in.rb +223 -0
  28. data/lib/svix/models/{oauth_payload_out.rb → incoming_webhook_payload_out.rb} +3 -3
  29. data/lib/svix/models/kafka_security_protocol_type.rb +38 -0
  30. data/lib/svix/models/list_response_sink_out.rb +259 -0
  31. data/lib/svix/models/{message_stream_out.rb → message_events_out.rb} +3 -3
  32. data/lib/svix/models/message_subscriber_auth_token_out.rb +237 -0
  33. data/lib/svix/models/{oauth_payload_in.rb → o_auth_payload_in.rb} +3 -3
  34. data/lib/svix/models/o_auth_payload_out.rb +239 -0
  35. data/lib/svix/models/{oauth2_grant_type.rb → oauth2_grant_type_in.rb} +4 -3
  36. data/lib/svix/models/settings_in.rb +15 -4
  37. data/lib/svix/models/settings_out.rb +15 -4
  38. data/lib/svix/models/sink_in.rb +107 -0
  39. data/lib/svix/models/sink_in_one_of.rb +285 -0
  40. data/lib/svix/models/sink_in_one_of1.rb +313 -0
  41. data/lib/svix/models/sink_in_one_of2.rb +321 -0
  42. data/lib/svix/models/sink_in_one_of3.rb +271 -0
  43. data/lib/svix/models/sink_out.rb +107 -0
  44. data/lib/svix/version.rb +1 -1
  45. metadata +24 -6
@@ -19,6 +19,109 @@ module Svix
19
19
  def initialize(api_client = ApiClient.default)
20
20
  @api_client = api_client
21
21
  end
22
+ # Update Hubspot Oauth Config
23
+ # Create/update endpoint Hubsport OAuth configuration Specific private endpoint just for us, to avoid exposing the Hubspot secret to the client.
24
+ # @param app_id [String] The app's ID or UID
25
+ # @param endpoint_id [String] The ep's ID or UID
26
+ # @param hubspot_oauth_config_in [HubspotOauthConfigIn]
27
+ # @param [Hash] opts the optional parameters
28
+ # @return [nil]
29
+ def v1_endpoint_update_hubspot_oauth_config(app_id, endpoint_id, hubspot_oauth_config_in, opts = {})
30
+ v1_endpoint_update_hubspot_oauth_config_with_http_info(app_id, endpoint_id, hubspot_oauth_config_in, opts)
31
+ nil
32
+ end
33
+
34
+ # Update Hubspot Oauth Config
35
+ # Create/update endpoint Hubsport OAuth configuration Specific private endpoint just for us, to avoid exposing the Hubspot secret to the client.
36
+ # @param app_id [String] The app's ID or UID
37
+ # @param endpoint_id [String] The ep's ID or UID
38
+ # @param hubspot_oauth_config_in [HubspotOauthConfigIn]
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
41
+ def v1_endpoint_update_hubspot_oauth_config_with_http_info(app_id, endpoint_id, hubspot_oauth_config_in, opts = {})
42
+ if @api_client.config.debugging
43
+ @api_client.config.logger.debug 'Calling API: TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config ...'
44
+ end
45
+ # verify the required parameter 'app_id' is set
46
+ if @api_client.config.client_side_validation && app_id.nil?
47
+ fail ArgumentError, "Missing the required parameter 'app_id' when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config"
48
+ end
49
+ if @api_client.config.client_side_validation && app_id.to_s.length > 256
50
+ fail ArgumentError, 'invalid value for "app_id" when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config, the character length must be smaller than or equal to 256.'
51
+ end
52
+
53
+ if @api_client.config.client_side_validation && app_id.to_s.length < 1
54
+ fail ArgumentError, 'invalid value for "app_id" when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config, the character length must be great than or equal to 1.'
55
+ end
56
+
57
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
58
+ if @api_client.config.client_side_validation && app_id !~ pattern
59
+ fail ArgumentError, "invalid value for 'app_id' when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config, must conform to the pattern #{pattern}."
60
+ end
61
+
62
+ # verify the required parameter 'endpoint_id' is set
63
+ if @api_client.config.client_side_validation && endpoint_id.nil?
64
+ fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config"
65
+ end
66
+ if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256
67
+ fail ArgumentError, 'invalid value for "endpoint_id" when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config, the character length must be smaller than or equal to 256.'
68
+ end
69
+
70
+ if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1
71
+ fail ArgumentError, 'invalid value for "endpoint_id" when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config, the character length must be great than or equal to 1.'
72
+ end
73
+
74
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
75
+ if @api_client.config.client_side_validation && endpoint_id !~ pattern
76
+ fail ArgumentError, "invalid value for 'endpoint_id' when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config, must conform to the pattern #{pattern}."
77
+ end
78
+
79
+ # verify the required parameter 'hubspot_oauth_config_in' is set
80
+ if @api_client.config.client_side_validation && hubspot_oauth_config_in.nil?
81
+ fail ArgumentError, "Missing the required parameter 'hubspot_oauth_config_in' when calling TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config"
82
+ end
83
+ # resource path
84
+ local_var_path = '/api/v1/app/{app_id}/endpoint/{endpoint_id}/transformation-template/oauth/hubspot'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_id.to_s))
85
+
86
+ # query parameters
87
+ query_params = opts[:query_params] || {}
88
+
89
+ # header parameters
90
+ header_params = opts[:header_params] || {}
91
+ # HTTP header 'Accept' (if needed)
92
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
93
+ # HTTP header 'Content-Type'
94
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
95
+
96
+ # form parameters
97
+ form_params = opts[:form_params] || {}
98
+
99
+ # http body (model)
100
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(hubspot_oauth_config_in)
101
+
102
+ # return_type
103
+ return_type = opts[:debug_return_type]
104
+
105
+ # auth_names
106
+ auth_names = opts[:debug_auth_names] || ['HTTPBearer']
107
+
108
+ new_options = opts.merge(
109
+ :operation => :"TransformationTemplateApi.v1_endpoint_update_hubspot_oauth_config",
110
+ :header_params => header_params,
111
+ :query_params => query_params,
112
+ :form_params => form_params,
113
+ :body => post_body,
114
+ :auth_names => auth_names,
115
+ :return_type => return_type
116
+ )
117
+
118
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
119
+ if @api_client.config.debugging
120
+ @api_client.config.logger.debug "API called: TransformationTemplateApi#v1_endpoint_update_hubspot_oauth_config\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
121
+ end
122
+ return data, status_code, headers
123
+ end
124
+
22
125
  # Create Transformation Template
23
126
  # Create a new transformation template
24
127
  # @param template_in [TemplateIn]
@@ -357,28 +460,28 @@ module Svix
357
460
 
358
461
  # Authorize Discord
359
462
  # Get Discord Incoming webhook URL
360
- # @param oauth_payload_in [OauthPayloadIn]
463
+ # @param o_auth_payload_in [OAuthPayloadIn]
361
464
  # @param [Hash] opts the optional parameters
362
465
  # @option opts [String] :idempotency_key The request&#39;s idempotency key
363
- # @return [OauthPayloadOut]
364
- def v1_transformation_template_oauth_discord(oauth_payload_in, opts = {})
365
- data, _status_code, _headers = v1_transformation_template_oauth_discord_with_http_info(oauth_payload_in, opts)
466
+ # @return [IncomingWebhookPayloadOut]
467
+ def v1_transformation_template_oauth_discord(o_auth_payload_in, opts = {})
468
+ data, _status_code, _headers = v1_transformation_template_oauth_discord_with_http_info(o_auth_payload_in, opts)
366
469
  data
367
470
  end
368
471
 
369
472
  # Authorize Discord
370
473
  # Get Discord Incoming webhook URL
371
- # @param oauth_payload_in [OauthPayloadIn]
474
+ # @param o_auth_payload_in [OAuthPayloadIn]
372
475
  # @param [Hash] opts the optional parameters
373
476
  # @option opts [String] :idempotency_key The request&#39;s idempotency key
374
- # @return [Array<(OauthPayloadOut, Integer, Hash)>] OauthPayloadOut data, response status code and response headers
375
- def v1_transformation_template_oauth_discord_with_http_info(oauth_payload_in, opts = {})
477
+ # @return [Array<(IncomingWebhookPayloadOut, Integer, Hash)>] IncomingWebhookPayloadOut data, response status code and response headers
478
+ def v1_transformation_template_oauth_discord_with_http_info(o_auth_payload_in, opts = {})
376
479
  if @api_client.config.debugging
377
480
  @api_client.config.logger.debug 'Calling API: TransformationTemplateApi.v1_transformation_template_oauth_discord ...'
378
481
  end
379
- # verify the required parameter 'oauth_payload_in' is set
380
- if @api_client.config.client_side_validation && oauth_payload_in.nil?
381
- fail ArgumentError, "Missing the required parameter 'oauth_payload_in' when calling TransformationTemplateApi.v1_transformation_template_oauth_discord"
482
+ # verify the required parameter 'o_auth_payload_in' is set
483
+ if @api_client.config.client_side_validation && o_auth_payload_in.nil?
484
+ fail ArgumentError, "Missing the required parameter 'o_auth_payload_in' when calling TransformationTemplateApi.v1_transformation_template_oauth_discord"
382
485
  end
383
486
  # resource path
384
487
  local_var_path = '/api/v1/transformation-template/oauth/discord'
@@ -398,10 +501,10 @@ module Svix
398
501
  form_params = opts[:form_params] || {}
399
502
 
400
503
  # http body (model)
401
- post_body = opts[:debug_body] || @api_client.object_to_http_body(oauth_payload_in)
504
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(o_auth_payload_in)
402
505
 
403
506
  # return_type
404
- return_type = opts[:debug_return_type] || 'OauthPayloadOut'
507
+ return_type = opts[:debug_return_type] || 'IncomingWebhookPayloadOut'
405
508
 
406
509
  # auth_names
407
510
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']
@@ -423,30 +526,98 @@ module Svix
423
526
  return data, status_code, headers
424
527
  end
425
528
 
529
+ # Authorize Hubspot
530
+ # Get Hubspot access token using authorization code
531
+ # @param o_auth_payload_in [OAuthPayloadIn]
532
+ # @param [Hash] opts the optional parameters
533
+ # @option opts [String] :idempotency_key The request&#39;s idempotency key
534
+ # @return [OAuthPayloadOut]
535
+ def v1_transformation_template_oauth_hubspot(o_auth_payload_in, opts = {})
536
+ data, _status_code, _headers = v1_transformation_template_oauth_hubspot_with_http_info(o_auth_payload_in, opts)
537
+ data
538
+ end
539
+
540
+ # Authorize Hubspot
541
+ # Get Hubspot access token using authorization code
542
+ # @param o_auth_payload_in [OAuthPayloadIn]
543
+ # @param [Hash] opts the optional parameters
544
+ # @option opts [String] :idempotency_key The request&#39;s idempotency key
545
+ # @return [Array<(OAuthPayloadOut, Integer, Hash)>] OAuthPayloadOut data, response status code and response headers
546
+ def v1_transformation_template_oauth_hubspot_with_http_info(o_auth_payload_in, opts = {})
547
+ if @api_client.config.debugging
548
+ @api_client.config.logger.debug 'Calling API: TransformationTemplateApi.v1_transformation_template_oauth_hubspot ...'
549
+ end
550
+ # verify the required parameter 'o_auth_payload_in' is set
551
+ if @api_client.config.client_side_validation && o_auth_payload_in.nil?
552
+ fail ArgumentError, "Missing the required parameter 'o_auth_payload_in' when calling TransformationTemplateApi.v1_transformation_template_oauth_hubspot"
553
+ end
554
+ # resource path
555
+ local_var_path = '/api/v1/transformation-template/oauth/hubspot'
556
+
557
+ # query parameters
558
+ query_params = opts[:query_params] || {}
559
+
560
+ # header parameters
561
+ header_params = opts[:header_params] || {}
562
+ # HTTP header 'Accept' (if needed)
563
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
564
+ # HTTP header 'Content-Type'
565
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
566
+ header_params[:'idempotency-key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
567
+
568
+ # form parameters
569
+ form_params = opts[:form_params] || {}
570
+
571
+ # http body (model)
572
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(o_auth_payload_in)
573
+
574
+ # return_type
575
+ return_type = opts[:debug_return_type] || 'OAuthPayloadOut'
576
+
577
+ # auth_names
578
+ auth_names = opts[:debug_auth_names] || ['HTTPBearer']
579
+
580
+ new_options = opts.merge(
581
+ :operation => :"TransformationTemplateApi.v1_transformation_template_oauth_hubspot",
582
+ :header_params => header_params,
583
+ :query_params => query_params,
584
+ :form_params => form_params,
585
+ :body => post_body,
586
+ :auth_names => auth_names,
587
+ :return_type => return_type
588
+ )
589
+
590
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
591
+ if @api_client.config.debugging
592
+ @api_client.config.logger.debug "API called: TransformationTemplateApi#v1_transformation_template_oauth_hubspot\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
593
+ end
594
+ return data, status_code, headers
595
+ end
596
+
426
597
  # Authorize Slack
427
598
  # Get Slack Incoming webhook URL
428
- # @param oauth_payload_in [OauthPayloadIn]
599
+ # @param o_auth_payload_in [OAuthPayloadIn]
429
600
  # @param [Hash] opts the optional parameters
430
601
  # @option opts [String] :idempotency_key The request&#39;s idempotency key
431
- # @return [OauthPayloadOut]
432
- def v1_transformation_template_oauth_slack(oauth_payload_in, opts = {})
433
- data, _status_code, _headers = v1_transformation_template_oauth_slack_with_http_info(oauth_payload_in, opts)
602
+ # @return [IncomingWebhookPayloadOut]
603
+ def v1_transformation_template_oauth_slack(o_auth_payload_in, opts = {})
604
+ data, _status_code, _headers = v1_transformation_template_oauth_slack_with_http_info(o_auth_payload_in, opts)
434
605
  data
435
606
  end
436
607
 
437
608
  # Authorize Slack
438
609
  # Get Slack Incoming webhook URL
439
- # @param oauth_payload_in [OauthPayloadIn]
610
+ # @param o_auth_payload_in [OAuthPayloadIn]
440
611
  # @param [Hash] opts the optional parameters
441
612
  # @option opts [String] :idempotency_key The request&#39;s idempotency key
442
- # @return [Array<(OauthPayloadOut, Integer, Hash)>] OauthPayloadOut data, response status code and response headers
443
- def v1_transformation_template_oauth_slack_with_http_info(oauth_payload_in, opts = {})
613
+ # @return [Array<(IncomingWebhookPayloadOut, Integer, Hash)>] IncomingWebhookPayloadOut data, response status code and response headers
614
+ def v1_transformation_template_oauth_slack_with_http_info(o_auth_payload_in, opts = {})
444
615
  if @api_client.config.debugging
445
616
  @api_client.config.logger.debug 'Calling API: TransformationTemplateApi.v1_transformation_template_oauth_slack ...'
446
617
  end
447
- # verify the required parameter 'oauth_payload_in' is set
448
- if @api_client.config.client_side_validation && oauth_payload_in.nil?
449
- fail ArgumentError, "Missing the required parameter 'oauth_payload_in' when calling TransformationTemplateApi.v1_transformation_template_oauth_slack"
618
+ # verify the required parameter 'o_auth_payload_in' is set
619
+ if @api_client.config.client_side_validation && o_auth_payload_in.nil?
620
+ fail ArgumentError, "Missing the required parameter 'o_auth_payload_in' when calling TransformationTemplateApi.v1_transformation_template_oauth_slack"
450
621
  end
451
622
  # resource path
452
623
  local_var_path = '/api/v1/transformation-template/oauth/slack'
@@ -466,10 +637,10 @@ module Svix
466
637
  form_params = opts[:form_params] || {}
467
638
 
468
639
  # http body (model)
469
- post_body = opts[:debug_body] || @api_client.object_to_http_body(oauth_payload_in)
640
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(o_auth_payload_in)
470
641
 
471
642
  # return_type
472
- return_type = opts[:debug_return_type] || 'OauthPayloadOut'
643
+ return_type = opts[:debug_return_type] || 'IncomingWebhookPayloadOut'
473
644
 
474
645
  # auth_names
475
646
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']
@@ -0,0 +1,284 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class AuthTokenOut
18
+ attr_accessor :created_at
19
+
20
+ attr_accessor :expires_at
21
+
22
+ # The key's ID
23
+ attr_accessor :id
24
+
25
+ attr_accessor :name
26
+
27
+ attr_accessor :scopes
28
+
29
+ attr_accessor :token
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'created_at' => :'createdAt',
35
+ :'expires_at' => :'expiresAt',
36
+ :'id' => :'id',
37
+ :'name' => :'name',
38
+ :'scopes' => :'scopes',
39
+ :'token' => :'token'
40
+ }
41
+ end
42
+
43
+ # Returns all the JSON keys this model knows about
44
+ def self.acceptable_attributes
45
+ attribute_map.values
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'created_at' => :'Time',
52
+ :'expires_at' => :'Time',
53
+ :'id' => :'String',
54
+ :'name' => :'String',
55
+ :'scopes' => :'Array<String>',
56
+ :'token' => :'String'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ :'expires_at',
64
+ :'name',
65
+ :'scopes',
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::AuthTokenOut` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::AuthTokenOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'created_at')
85
+ self.created_at = attributes[:'created_at']
86
+ end
87
+
88
+ if attributes.key?(:'expires_at')
89
+ self.expires_at = attributes[:'expires_at']
90
+ end
91
+
92
+ if attributes.key?(:'id')
93
+ self.id = attributes[:'id']
94
+ end
95
+
96
+ if attributes.key?(:'name')
97
+ self.name = attributes[:'name']
98
+ end
99
+
100
+ if attributes.key?(:'scopes')
101
+ if (value = attributes[:'scopes']).is_a?(Array)
102
+ self.scopes = value
103
+ end
104
+ end
105
+
106
+ if attributes.key?(:'token')
107
+ self.token = attributes[:'token']
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ if @created_at.nil?
116
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
117
+ end
118
+
119
+ if @id.nil?
120
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
121
+ end
122
+
123
+ if @token.nil?
124
+ invalid_properties.push('invalid value for "token", token cannot be nil.')
125
+ end
126
+
127
+ invalid_properties
128
+ end
129
+
130
+ # Check to see if the all the properties in the model are valid
131
+ # @return true if the model is valid
132
+ def valid?
133
+ return false if @created_at.nil?
134
+ return false if @id.nil?
135
+ return false if @token.nil?
136
+ true
137
+ end
138
+
139
+ # Checks equality by comparing each attribute.
140
+ # @param [Object] Object to be compared
141
+ def ==(o)
142
+ return true if self.equal?(o)
143
+ self.class == o.class &&
144
+ created_at == o.created_at &&
145
+ expires_at == o.expires_at &&
146
+ id == o.id &&
147
+ name == o.name &&
148
+ scopes == o.scopes &&
149
+ token == o.token
150
+ end
151
+
152
+ # @see the `==` method
153
+ # @param [Object] Object to be compared
154
+ def eql?(o)
155
+ self == o
156
+ end
157
+
158
+ # Calculates hash code according to all attributes.
159
+ # @return [Integer] Hash code
160
+ def hash
161
+ [created_at, expires_at, id, name, scopes, token].hash
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def self.build_from_hash(attributes)
168
+ new.build_from_hash(attributes)
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def build_from_hash(attributes)
175
+ return nil unless attributes.is_a?(Hash)
176
+ self.class.openapi_types.each_pair do |key, type|
177
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
178
+ self.send("#{key}=", nil)
179
+ elsif type =~ /\AArray<(.*)>/i
180
+ # check to ensure the input is an array given that the attribute
181
+ # is documented as an array but the input is not
182
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
183
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
184
+ end
185
+ elsif !attributes[self.class.attribute_map[key]].nil?
186
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
187
+ end
188
+ end
189
+
190
+ self
191
+ end
192
+
193
+ # Deserializes the data based on type
194
+ # @param string type Data type
195
+ # @param string value Value to be deserialized
196
+ # @return [Object] Deserialized data
197
+ def _deserialize(type, value)
198
+ case type.to_sym
199
+ when :Time
200
+ Time.parse(value)
201
+ when :Date
202
+ Date.parse(value)
203
+ when :String
204
+ value.to_s
205
+ when :Integer
206
+ value.to_i
207
+ when :Float
208
+ value.to_f
209
+ when :Boolean
210
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
211
+ true
212
+ else
213
+ false
214
+ end
215
+ when :Object
216
+ # generic object (usually a Hash), return directly
217
+ value
218
+ when /\AArray<(?<inner_type>.+)>\z/
219
+ inner_type = Regexp.last_match[:inner_type]
220
+ value.map { |v| _deserialize(inner_type, v) }
221
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
222
+ k_type = Regexp.last_match[:k_type]
223
+ v_type = Regexp.last_match[:v_type]
224
+ {}.tap do |hash|
225
+ value.each do |k, v|
226
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
227
+ end
228
+ end
229
+ else # model
230
+ # models (e.g. Pet) or oneOf
231
+ klass = Svix.const_get(type)
232
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ if value.nil?
255
+ is_nullable = self.class.openapi_nullable.include?(attr)
256
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
257
+ end
258
+
259
+ hash[param] = _to_hash(value)
260
+ end
261
+ hash
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value)
269
+ if value.is_a?(Array)
270
+ value.compact.map { |v| _to_hash(v) }
271
+ elsif value.is_a?(Hash)
272
+ {}.tap do |hash|
273
+ value.each { |k, v| hash[k] = _to_hash(v) }
274
+ end
275
+ elsif value.respond_to? :to_hash
276
+ value.to_hash
277
+ else
278
+ value
279
+ end
280
+ end
281
+
282
+ end
283
+
284
+ end