mx-platform-ruby 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1593,6 +1593,81 @@ module MxPlatformRuby
1593
1593
  return data, status_code, headers
1594
1594
  end
1595
1595
 
1596
+ # Download a Tax Document PDF
1597
+ # Use this endpoint to download a PDF version of the specified tax document. The endpoint URL is the base URL appended with the uri of the tax_document.
1598
+ # @param tax_document_guid [String] The unique id for a `tax_document`.
1599
+ # @param member_guid [String] The unique id for a `member`.
1600
+ # @param user_guid [String] The unique id for a `user`.
1601
+ # @param [Hash] opts the optional parameters
1602
+ # @return [File]
1603
+ def download_tax_document(tax_document_guid, member_guid, user_guid, opts = {})
1604
+ data, _status_code, _headers = download_tax_document_with_http_info(tax_document_guid, member_guid, user_guid, opts)
1605
+ data
1606
+ end
1607
+
1608
+ # Download a Tax Document PDF
1609
+ # Use this endpoint to download a PDF version of the specified tax document. The endpoint URL is the base URL appended with the uri of the tax_document.
1610
+ # @param tax_document_guid [String] The unique id for a `tax_document`.
1611
+ # @param member_guid [String] The unique id for a `member`.
1612
+ # @param user_guid [String] The unique id for a `user`.
1613
+ # @param [Hash] opts the optional parameters
1614
+ # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
1615
+ def download_tax_document_with_http_info(tax_document_guid, member_guid, user_guid, opts = {})
1616
+ if @api_client.config.debugging
1617
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.download_tax_document ...'
1618
+ end
1619
+ # verify the required parameter 'tax_document_guid' is set
1620
+ if @api_client.config.client_side_validation && tax_document_guid.nil?
1621
+ fail ArgumentError, "Missing the required parameter 'tax_document_guid' when calling MxPlatformApi.download_tax_document"
1622
+ end
1623
+ # verify the required parameter 'member_guid' is set
1624
+ if @api_client.config.client_side_validation && member_guid.nil?
1625
+ fail ArgumentError, "Missing the required parameter 'member_guid' when calling MxPlatformApi.download_tax_document"
1626
+ end
1627
+ # verify the required parameter 'user_guid' is set
1628
+ if @api_client.config.client_side_validation && user_guid.nil?
1629
+ fail ArgumentError, "Missing the required parameter 'user_guid' when calling MxPlatformApi.download_tax_document"
1630
+ end
1631
+ # resource path
1632
+ local_var_path = '/users/{user_guid}/members/{member_guid}/tax_documents/{tax_document_guid}.pdf'.sub('{' + 'tax_document_guid' + '}', CGI.escape(tax_document_guid.to_s)).sub('{' + 'member_guid' + '}', CGI.escape(member_guid.to_s)).sub('{' + 'user_guid' + '}', CGI.escape(user_guid.to_s))
1633
+
1634
+ # query parameters
1635
+ query_params = opts[:query_params] || {}
1636
+
1637
+ # header parameters
1638
+ header_params = opts[:header_params] || {}
1639
+ # HTTP header 'Accept' (if needed)
1640
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+pdf'])
1641
+
1642
+ # form parameters
1643
+ form_params = opts[:form_params] || {}
1644
+
1645
+ # http body (model)
1646
+ post_body = opts[:debug_body]
1647
+
1648
+ # return_type
1649
+ return_type = opts[:debug_return_type] || 'File'
1650
+
1651
+ # auth_names
1652
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
1653
+
1654
+ new_options = opts.merge(
1655
+ :operation => :"MxPlatformApi.download_tax_document",
1656
+ :header_params => header_params,
1657
+ :query_params => query_params,
1658
+ :form_params => form_params,
1659
+ :body => post_body,
1660
+ :auth_names => auth_names,
1661
+ :return_type => return_type
1662
+ )
1663
+
1664
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1665
+ if @api_client.config.debugging
1666
+ @api_client.config.logger.debug "API called: MxPlatformApi#download_tax_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1667
+ end
1668
+ return data, status_code, headers
1669
+ end
1670
+
1596
1671
  # Enhance transactions
1597
1672
  # Use this endpoint to categorize, cleanse, and classify transactions. These transactions are not persisted or stored on the MX platform.
1598
1673
  # @param enhance_transactions_request_body [EnhanceTransactionsRequestBody] Transaction object to be enhanced
@@ -1799,6 +1874,75 @@ module MxPlatformRuby
1799
1874
  return data, status_code, headers
1800
1875
  end
1801
1876
 
1877
+ # Fetch Tax Documents
1878
+ # Use this endpoint to fetch (aggregate) the tax documents associated with the specified member. This request **does not** return the latest tax documents. It just starts the document aggregation process and returns the initial state of the process. You must interact with the newly aggregated data using the other document endpoints in this reference. This request may also trigger multi-factor authentication which requires end-user input and a specific process for answering authentication challenges.
1879
+ # @param member_guid [String] The unique id for a &#x60;member&#x60;.
1880
+ # @param user_guid [String] The unique id for a &#x60;user&#x60;.
1881
+ # @param [Hash] opts the optional parameters
1882
+ # @return [MemberResponseBody]
1883
+ def fetch_tax_documents(member_guid, user_guid, opts = {})
1884
+ data, _status_code, _headers = fetch_tax_documents_with_http_info(member_guid, user_guid, opts)
1885
+ data
1886
+ end
1887
+
1888
+ # Fetch Tax Documents
1889
+ # Use this endpoint to fetch (aggregate) the tax documents associated with the specified member. This request **does not** return the latest tax documents. It just starts the document aggregation process and returns the initial state of the process. You must interact with the newly aggregated data using the other document endpoints in this reference. This request may also trigger multi-factor authentication which requires end-user input and a specific process for answering authentication challenges.
1890
+ # @param member_guid [String] The unique id for a &#x60;member&#x60;.
1891
+ # @param user_guid [String] The unique id for a &#x60;user&#x60;.
1892
+ # @param [Hash] opts the optional parameters
1893
+ # @return [Array<(MemberResponseBody, Integer, Hash)>] MemberResponseBody data, response status code and response headers
1894
+ def fetch_tax_documents_with_http_info(member_guid, user_guid, opts = {})
1895
+ if @api_client.config.debugging
1896
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.fetch_tax_documents ...'
1897
+ end
1898
+ # verify the required parameter 'member_guid' is set
1899
+ if @api_client.config.client_side_validation && member_guid.nil?
1900
+ fail ArgumentError, "Missing the required parameter 'member_guid' when calling MxPlatformApi.fetch_tax_documents"
1901
+ end
1902
+ # verify the required parameter 'user_guid' is set
1903
+ if @api_client.config.client_side_validation && user_guid.nil?
1904
+ fail ArgumentError, "Missing the required parameter 'user_guid' when calling MxPlatformApi.fetch_tax_documents"
1905
+ end
1906
+ # resource path
1907
+ local_var_path = '/users/{user_guid}/members/{member_guid}/fetch_tax_documents'.sub('{' + 'member_guid' + '}', CGI.escape(member_guid.to_s)).sub('{' + 'user_guid' + '}', CGI.escape(user_guid.to_s))
1908
+
1909
+ # query parameters
1910
+ query_params = opts[:query_params] || {}
1911
+
1912
+ # header parameters
1913
+ header_params = opts[:header_params] || {}
1914
+ # HTTP header 'Accept' (if needed)
1915
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+json'])
1916
+
1917
+ # form parameters
1918
+ form_params = opts[:form_params] || {}
1919
+
1920
+ # http body (model)
1921
+ post_body = opts[:debug_body]
1922
+
1923
+ # return_type
1924
+ return_type = opts[:debug_return_type] || 'MemberResponseBody'
1925
+
1926
+ # auth_names
1927
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
1928
+
1929
+ new_options = opts.merge(
1930
+ :operation => :"MxPlatformApi.fetch_tax_documents",
1931
+ :header_params => header_params,
1932
+ :query_params => query_params,
1933
+ :form_params => form_params,
1934
+ :body => post_body,
1935
+ :auth_names => auth_names,
1936
+ :return_type => return_type
1937
+ )
1938
+
1939
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
1940
+ if @api_client.config.debugging
1941
+ @api_client.config.logger.debug "API called: MxPlatformApi#fetch_tax_documents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1942
+ end
1943
+ return data, status_code, headers
1944
+ end
1945
+
1802
1946
  # Identify member
1803
1947
  # The identify endpoint begins an identification process for an already-existing member.
1804
1948
  # @param member_guid [String] The unique id for a &#x60;member&#x60;.
@@ -3602,6 +3746,81 @@ module MxPlatformRuby
3602
3746
  return data, status_code, headers
3603
3747
  end
3604
3748
 
3749
+ # List Tax Documents
3750
+ # Use this endpoint to get a paginated list of tax documents.
3751
+ # @param member_guid [String] The unique id for a &#x60;member&#x60;.
3752
+ # @param user_guid [String] The unique id for a &#x60;user&#x60;.
3753
+ # @param [Hash] opts the optional parameters
3754
+ # @option opts [Integer] :page Specify current page.
3755
+ # @option opts [Integer] :records_per_page Specify records per page.
3756
+ # @return [TaxDocumentsResponseBody]
3757
+ def list_tax_documents(member_guid, user_guid, opts = {})
3758
+ data, _status_code, _headers = list_tax_documents_with_http_info(member_guid, user_guid, opts)
3759
+ data
3760
+ end
3761
+
3762
+ # List Tax Documents
3763
+ # Use this endpoint to get a paginated list of tax documents.
3764
+ # @param member_guid [String] The unique id for a &#x60;member&#x60;.
3765
+ # @param user_guid [String] The unique id for a &#x60;user&#x60;.
3766
+ # @param [Hash] opts the optional parameters
3767
+ # @option opts [Integer] :page Specify current page.
3768
+ # @option opts [Integer] :records_per_page Specify records per page.
3769
+ # @return [Array<(TaxDocumentsResponseBody, Integer, Hash)>] TaxDocumentsResponseBody data, response status code and response headers
3770
+ def list_tax_documents_with_http_info(member_guid, user_guid, opts = {})
3771
+ if @api_client.config.debugging
3772
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.list_tax_documents ...'
3773
+ end
3774
+ # verify the required parameter 'member_guid' is set
3775
+ if @api_client.config.client_side_validation && member_guid.nil?
3776
+ fail ArgumentError, "Missing the required parameter 'member_guid' when calling MxPlatformApi.list_tax_documents"
3777
+ end
3778
+ # verify the required parameter 'user_guid' is set
3779
+ if @api_client.config.client_side_validation && user_guid.nil?
3780
+ fail ArgumentError, "Missing the required parameter 'user_guid' when calling MxPlatformApi.list_tax_documents"
3781
+ end
3782
+ # resource path
3783
+ local_var_path = '/users/{user_guid}/members/{member_guid}/tax_documents'.sub('{' + 'member_guid' + '}', CGI.escape(member_guid.to_s)).sub('{' + 'user_guid' + '}', CGI.escape(user_guid.to_s))
3784
+
3785
+ # query parameters
3786
+ query_params = opts[:query_params] || {}
3787
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
3788
+ query_params[:'records_per_page'] = opts[:'records_per_page'] if !opts[:'records_per_page'].nil?
3789
+
3790
+ # header parameters
3791
+ header_params = opts[:header_params] || {}
3792
+ # HTTP header 'Accept' (if needed)
3793
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+json'])
3794
+
3795
+ # form parameters
3796
+ form_params = opts[:form_params] || {}
3797
+
3798
+ # http body (model)
3799
+ post_body = opts[:debug_body]
3800
+
3801
+ # return_type
3802
+ return_type = opts[:debug_return_type] || 'TaxDocumentsResponseBody'
3803
+
3804
+ # auth_names
3805
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
3806
+
3807
+ new_options = opts.merge(
3808
+ :operation => :"MxPlatformApi.list_tax_documents",
3809
+ :header_params => header_params,
3810
+ :query_params => query_params,
3811
+ :form_params => form_params,
3812
+ :body => post_body,
3813
+ :auth_names => auth_names,
3814
+ :return_type => return_type
3815
+ )
3816
+
3817
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
3818
+ if @api_client.config.debugging
3819
+ @api_client.config.logger.debug "API called: MxPlatformApi#list_tax_documents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
3820
+ end
3821
+ return data, status_code, headers
3822
+ end
3823
+
3605
3824
  # List transaction rules
3606
3825
  # Use this endpoint to read the attributes of all existing transaction rules belonging to the user.
3607
3826
  # @param user_guid [String] The unique id for a &#x60;user&#x60;.
@@ -5243,6 +5462,81 @@ module MxPlatformRuby
5243
5462
  return data, status_code, headers
5244
5463
  end
5245
5464
 
5465
+ # Read a Tax Document
5466
+ # Use this endpoint to read the attributes of the specified tax document.
5467
+ # @param tax_document_guid [String] The unique id for a &#x60;tax_document&#x60;.
5468
+ # @param member_guid [String] The unique id for a &#x60;member&#x60;.
5469
+ # @param user_guid [String] The unique id for a &#x60;user&#x60;.
5470
+ # @param [Hash] opts the optional parameters
5471
+ # @return [TaxDocumentResponseBody]
5472
+ def read_tax_document(tax_document_guid, member_guid, user_guid, opts = {})
5473
+ data, _status_code, _headers = read_tax_document_with_http_info(tax_document_guid, member_guid, user_guid, opts)
5474
+ data
5475
+ end
5476
+
5477
+ # Read a Tax Document
5478
+ # Use this endpoint to read the attributes of the specified tax document.
5479
+ # @param tax_document_guid [String] The unique id for a &#x60;tax_document&#x60;.
5480
+ # @param member_guid [String] The unique id for a &#x60;member&#x60;.
5481
+ # @param user_guid [String] The unique id for a &#x60;user&#x60;.
5482
+ # @param [Hash] opts the optional parameters
5483
+ # @return [Array<(TaxDocumentResponseBody, Integer, Hash)>] TaxDocumentResponseBody data, response status code and response headers
5484
+ def read_tax_document_with_http_info(tax_document_guid, member_guid, user_guid, opts = {})
5485
+ if @api_client.config.debugging
5486
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.read_tax_document ...'
5487
+ end
5488
+ # verify the required parameter 'tax_document_guid' is set
5489
+ if @api_client.config.client_side_validation && tax_document_guid.nil?
5490
+ fail ArgumentError, "Missing the required parameter 'tax_document_guid' when calling MxPlatformApi.read_tax_document"
5491
+ end
5492
+ # verify the required parameter 'member_guid' is set
5493
+ if @api_client.config.client_side_validation && member_guid.nil?
5494
+ fail ArgumentError, "Missing the required parameter 'member_guid' when calling MxPlatformApi.read_tax_document"
5495
+ end
5496
+ # verify the required parameter 'user_guid' is set
5497
+ if @api_client.config.client_side_validation && user_guid.nil?
5498
+ fail ArgumentError, "Missing the required parameter 'user_guid' when calling MxPlatformApi.read_tax_document"
5499
+ end
5500
+ # resource path
5501
+ local_var_path = '/users/{user_guid}/members/{member_guid}/tax_documents/{tax_document_guid}'.sub('{' + 'tax_document_guid' + '}', CGI.escape(tax_document_guid.to_s)).sub('{' + 'member_guid' + '}', CGI.escape(member_guid.to_s)).sub('{' + 'user_guid' + '}', CGI.escape(user_guid.to_s))
5502
+
5503
+ # query parameters
5504
+ query_params = opts[:query_params] || {}
5505
+
5506
+ # header parameters
5507
+ header_params = opts[:header_params] || {}
5508
+ # HTTP header 'Accept' (if needed)
5509
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+json'])
5510
+
5511
+ # form parameters
5512
+ form_params = opts[:form_params] || {}
5513
+
5514
+ # http body (model)
5515
+ post_body = opts[:debug_body]
5516
+
5517
+ # return_type
5518
+ return_type = opts[:debug_return_type] || 'TaxDocumentResponseBody'
5519
+
5520
+ # auth_names
5521
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
5522
+
5523
+ new_options = opts.merge(
5524
+ :operation => :"MxPlatformApi.read_tax_document",
5525
+ :header_params => header_params,
5526
+ :query_params => query_params,
5527
+ :form_params => form_params,
5528
+ :body => post_body,
5529
+ :auth_names => auth_names,
5530
+ :return_type => return_type
5531
+ )
5532
+
5533
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
5534
+ if @api_client.config.debugging
5535
+ @api_client.config.logger.debug "API called: MxPlatformApi#read_tax_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5536
+ end
5537
+ return data, status_code, headers
5538
+ end
5539
+
5246
5540
  # Read transaction
5247
5541
  # Requests to this endpoint will return the attributes of the specified `transaction`.
5248
5542
  # @param transaction_guid [String] The unique id for a &#x60;transaction&#x60;.
@@ -0,0 +1,309 @@
1
+ =begin
2
+ #MX Platform API
3
+
4
+ #The MX Platform API is a powerful, fully-featured API designed to make aggregating and enhancing financial data easy and reliable. It can seamlessly connect your app or website to tens of thousands of financial institutions.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MxPlatformRuby
17
+ class TaxDocumentResponse
18
+ attr_accessor :content_hash
19
+
20
+ attr_accessor :created_at
21
+
22
+ attr_accessor :document_type
23
+
24
+ attr_accessor :guid
25
+
26
+ attr_accessor :issued_on
27
+
28
+ attr_accessor :member_guid
29
+
30
+ attr_accessor :tax_year
31
+
32
+ attr_accessor :updated_at
33
+
34
+ attr_accessor :uri
35
+
36
+ attr_accessor :user_guid
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'content_hash' => :'content_hash',
42
+ :'created_at' => :'created_at',
43
+ :'document_type' => :'document_type',
44
+ :'guid' => :'guid',
45
+ :'issued_on' => :'issued_on',
46
+ :'member_guid' => :'member_guid',
47
+ :'tax_year' => :'tax_year',
48
+ :'updated_at' => :'updated_at',
49
+ :'uri' => :'uri',
50
+ :'user_guid' => :'user_guid'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'content_hash' => :'String',
63
+ :'created_at' => :'String',
64
+ :'document_type' => :'String',
65
+ :'guid' => :'String',
66
+ :'issued_on' => :'String',
67
+ :'member_guid' => :'String',
68
+ :'tax_year' => :'String',
69
+ :'updated_at' => :'String',
70
+ :'uri' => :'String',
71
+ :'user_guid' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ :'content_hash',
79
+ :'created_at',
80
+ :'document_type',
81
+ :'guid',
82
+ :'issued_on',
83
+ :'member_guid',
84
+ :'tax_year',
85
+ :'updated_at',
86
+ :'uri',
87
+ :'user_guid'
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::TaxDocumentResponse` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::TaxDocumentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'content_hash')
107
+ self.content_hash = attributes[:'content_hash']
108
+ end
109
+
110
+ if attributes.key?(:'created_at')
111
+ self.created_at = attributes[:'created_at']
112
+ end
113
+
114
+ if attributes.key?(:'document_type')
115
+ self.document_type = attributes[:'document_type']
116
+ end
117
+
118
+ if attributes.key?(:'guid')
119
+ self.guid = attributes[:'guid']
120
+ end
121
+
122
+ if attributes.key?(:'issued_on')
123
+ self.issued_on = attributes[:'issued_on']
124
+ end
125
+
126
+ if attributes.key?(:'member_guid')
127
+ self.member_guid = attributes[:'member_guid']
128
+ end
129
+
130
+ if attributes.key?(:'tax_year')
131
+ self.tax_year = attributes[:'tax_year']
132
+ end
133
+
134
+ if attributes.key?(:'updated_at')
135
+ self.updated_at = attributes[:'updated_at']
136
+ end
137
+
138
+ if attributes.key?(:'uri')
139
+ self.uri = attributes[:'uri']
140
+ end
141
+
142
+ if attributes.key?(:'user_guid')
143
+ self.user_guid = attributes[:'user_guid']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ true
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ content_hash == o.content_hash &&
166
+ created_at == o.created_at &&
167
+ document_type == o.document_type &&
168
+ guid == o.guid &&
169
+ issued_on == o.issued_on &&
170
+ member_guid == o.member_guid &&
171
+ tax_year == o.tax_year &&
172
+ updated_at == o.updated_at &&
173
+ uri == o.uri &&
174
+ user_guid == o.user_guid
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Integer] Hash code
185
+ def hash
186
+ [content_hash, created_at, document_type, guid, issued_on, member_guid, tax_year, updated_at, uri, user_guid].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def self.build_from_hash(attributes)
193
+ new.build_from_hash(attributes)
194
+ end
195
+
196
+ # Builds the object from hash
197
+ # @param [Hash] attributes Model attributes in the form of hash
198
+ # @return [Object] Returns the model itself
199
+ def build_from_hash(attributes)
200
+ return nil unless attributes.is_a?(Hash)
201
+ self.class.openapi_types.each_pair do |key, type|
202
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
203
+ self.send("#{key}=", nil)
204
+ elsif type =~ /\AArray<(.*)>/i
205
+ # check to ensure the input is an array given that the attribute
206
+ # is documented as an array but the input is not
207
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
208
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
209
+ end
210
+ elsif !attributes[self.class.attribute_map[key]].nil?
211
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
212
+ end
213
+ end
214
+
215
+ self
216
+ end
217
+
218
+ # Deserializes the data based on type
219
+ # @param string type Data type
220
+ # @param string value Value to be deserialized
221
+ # @return [Object] Deserialized data
222
+ def _deserialize(type, value)
223
+ case type.to_sym
224
+ when :Time
225
+ Time.parse(value)
226
+ when :Date
227
+ Date.parse(value)
228
+ when :String
229
+ value.to_s
230
+ when :Integer
231
+ value.to_i
232
+ when :Float
233
+ value.to_f
234
+ when :Boolean
235
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
236
+ true
237
+ else
238
+ false
239
+ end
240
+ when :Object
241
+ # generic object (usually a Hash), return directly
242
+ value
243
+ when /\AArray<(?<inner_type>.+)>\z/
244
+ inner_type = Regexp.last_match[:inner_type]
245
+ value.map { |v| _deserialize(inner_type, v) }
246
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
247
+ k_type = Regexp.last_match[:k_type]
248
+ v_type = Regexp.last_match[:v_type]
249
+ {}.tap do |hash|
250
+ value.each do |k, v|
251
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
252
+ end
253
+ end
254
+ else # model
255
+ # models (e.g. Pet) or oneOf
256
+ klass = MxPlatformRuby.const_get(type)
257
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
258
+ end
259
+ end
260
+
261
+ # Returns the string representation of the object
262
+ # @return [String] String presentation of the object
263
+ def to_s
264
+ to_hash.to_s
265
+ end
266
+
267
+ # to_body is an alias to to_hash (backward compatibility)
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_body
270
+ to_hash
271
+ end
272
+
273
+ # Returns the object in the form of hash
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_hash
276
+ hash = {}
277
+ self.class.attribute_map.each_pair do |attr, param|
278
+ value = self.send(attr)
279
+ if value.nil?
280
+ is_nullable = self.class.openapi_nullable.include?(attr)
281
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
282
+ end
283
+
284
+ hash[param] = _to_hash(value)
285
+ end
286
+ hash
287
+ end
288
+
289
+ # Outputs non-array value in the form of hash
290
+ # For object, use to_hash. Otherwise, just return the value
291
+ # @param [Object] value Any valid value
292
+ # @return [Hash] Returns the value in the form of hash
293
+ def _to_hash(value)
294
+ if value.is_a?(Array)
295
+ value.compact.map { |v| _to_hash(v) }
296
+ elsif value.is_a?(Hash)
297
+ {}.tap do |hash|
298
+ value.each { |k, v| hash[k] = _to_hash(v) }
299
+ end
300
+ elsif value.respond_to? :to_hash
301
+ value.to_hash
302
+ else
303
+ value
304
+ end
305
+ end
306
+
307
+ end
308
+
309
+ end