Class: FdxV660Api::TaxFormsController

Inherits:
BaseController show all
Defined in:
lib/fdx_v660_api/controllers/tax_forms_controller.rb

Overview

TaxFormsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from FdxV660Api::BaseController

Instance Method Details

#get_tax_form(tax_form_id, authorization, x_fapi_interaction_id, accept, fdx_api_actor_type: nil, fdx_api_data_provider_id: nil, fdx_api_data_recipient_id: nil, tax_data_type: nil) ⇒ ApiResponse

Get the form image or TaxStatement as json for a single tax document for the customer. Use HTTP Accept request-header to specify desired content types. See AcceptHeader definition for typical values form or tax statement request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authoriz ation) provides credentials to allow access to a protected resources identifier for this interaction, as defined by [FAPI 2.0 Implementation Advice, 2.2.1 x-fapi-interaction-id](https://openid.bitbucket.io/fapi/fapi-2_0-implement ation_advice.html#name-x-fapi-interaction-id) header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) to indicate one or more content types to request for the search result response. Use application/json to request data, application/pdf, application/zip or image/* MIME-types to request images. In comma-separated array format using values typically from './fdxapi.components.yaml#/components/schemas/ContentTypes' enumeration. Use in combination with TaxDataTypeQuery parameter to request application/json responses in 'JSON' or 'BASE64_PDF' format for tax form data whether the customer is present (USER) or it is a BATCH operation financial institution responding to the request for the data recipient(s) on whose behalf the request is being made request application/json tax form data response in 'JSON' or 'BASE64_PDF' format. Omit if either format is acceptable. Used in combination with AcceptHeader requesting application/json response

Parameters:

  • tax_form_id (String)

    Required parameter: The unique ID for this tax

  • authorization (String)

    Required parameter: The [Authorization HTTP

  • x_fapi_interaction_id (UUID | String)

    Required parameter: Unique

  • accept (String)

    Required parameter: Use the [Accept HTTP request

  • fdx_api_actor_type (FdxApiActorType) (defaults to: nil)

    Optional parameter: Identifies

  • fdx_api_data_provider_id (String) (defaults to: nil)

    Optional parameter: ID for the

  • fdx_api_data_recipient_id (Array[String]) (defaults to: nil)

    Optional parameter: ID(s)

  • tax_data_type (TypeDataType) (defaults to: nil)

    Optional parameter: Use taxDataType to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/fdx_v660_api/controllers/tax_forms_controller.rb', line 153

def get_tax_form(tax_form_id,
                 authorization,
                 x_fapi_interaction_id,
                 accept,
                 fdx_api_actor_type: nil,
                 fdx_api_data_provider_id: nil,
                 fdx_api_data_recipient_id: nil,
                 tax_data_type: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/tax-forms/{taxFormId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(tax_form_id, key: 'taxFormId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(authorization, key: 'Authorization')
                              .is_required(true))
               .header_param(new_parameter(x_fapi_interaction_id, key: 'x-fapi-interaction-id')
                              .is_required(true))
               .header_param(new_parameter(accept, key: 'Accept')
                              .is_required(true))
               .header_param(new_parameter(fdx_api_actor_type, key: 'FDX-API-Actor-Type'))
               .header_param(new_parameter(fdx_api_data_provider_id, key: 'FDX-API-Data-Provider-Id'))
               .header_param(new_parameter(fdx_api_data_recipient_id, key: 'FDX-API-Data-Recipient-Id'))
               .query_param(new_parameter(tax_data_type, key: 'taxDataType'))
               .auth(Or.new('TaxBasicAuth', 'OAuthFapi1Advanced')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TaxStatement4.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Account ID is required for searching or validating'\
                              ' authorization',
                             ErrorException)
                .local_error('404',
                             'Tax Form for provided Tax Form ID was not found',
                             ErrorException)
                .local_error('406',
                             'Content Type not Supported',
                             ErrorException)
                .local_error('409',
                             'Tax forms are not currently available for this account or this'\
                              ' year',
                             ErrorException)
                .local_error('500',
                             'Catch-all exception where request was not processed due to an'\
                              ' internal outage/issue. Consider other more specific errors'\
                              ' before using this error',
                             ErrorException)
                .local_error('501',
                             'Error when FdxVersion in Header is not one of those'\
                              ' implemented at backend',
                             ErrorException)
                .local_error('503',
                             'System is down for maintenance',
                             ErrorException))
    .execute
end

#search_for_tax_forms(authorization, x_fapi_interaction_id, accept, fdx_api_actor_type: nil, fdx_api_data_provider_id: nil, fdx_api_data_recipient_id: nil, account_id: nil, tax_year: nil, tax_forms: nil, tax_data_type: nil, result_type: ResultType::LIGHTWEIGHT) ⇒ ApiResponse

Get the full lists of tax document data and tax form images available for a specific year for the current authorized customer request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authoriz ation) provides credentials to allow access to a protected resources identifier for this interaction, as defined by [FAPI 2.0 Implementation Advice, 2.2.1 x-fapi-interaction-id](https://openid.bitbucket.io/fapi/fapi-2_0-implement ation_advice.html#name-x-fapi-interaction-id) header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) to indicate one or more content types to request for the search result response. Use application/json to request data, application/pdf, application/zip or image/* MIME-types to request images. In comma-separated array format using values typically from './fdxapi.components.yaml#/components/schemas/ContentTypes' enumeration. Use in combination with TaxDataTypeQuery parameter to request application/json responses in 'JSON' or 'BASE64_PDF' format for tax form data whether the customer is present (USER) or it is a BATCH operation financial institution responding to the request for the data recipient(s) on whose behalf the request is being made in searching or authorization. Optional for tax forms. Optional form type enums for the specific documents being requested. Comma separated request application/json tax form data response in 'JSON' or 'BASE64_PDF' format. Omit if either format is acceptable. Used in combination with AcceptHeader requesting application/json response you want a lightweight array of metadata (AccountDescriptor or Tax or Operations) or full item details (Account or a Tax subclass or Availability details). If set to 'lightweight', should only return the fields associated with the metadata entity. This field is not required, defaults to lightweight

Parameters:

  • authorization (String)

    Required parameter: The [Authorization HTTP

  • x_fapi_interaction_id (UUID | String)

    Required parameter: Unique

  • accept (String)

    Required parameter: Use the [Accept HTTP request

  • fdx_api_actor_type (FdxApiActorType) (defaults to: nil)

    Optional parameter: Identifies

  • fdx_api_data_provider_id (String) (defaults to: nil)

    Optional parameter: ID for the

  • fdx_api_data_recipient_id (Array[String]) (defaults to: nil)

    Optional parameter: ID(s)

  • account_id (String) (defaults to: nil)

    Optional parameter: Account Identifier for use

  • tax_year (Integer) (defaults to: nil)

    Optional parameter: Tax year in which to search

  • tax_forms (Array[TypeFormType]) (defaults to: nil)

    Optional parameter: One or more tax

  • tax_data_type (TypeDataType) (defaults to: nil)

    Optional parameter: Use taxDataType to

  • result_type (ResultType) (defaults to: ResultType::LIGHTWEIGHT)

    Optional parameter: Flag to indicate if

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/fdx_v660_api/controllers/tax_forms_controller.rb', line 54

def search_for_tax_forms(authorization,
                         x_fapi_interaction_id,
                         accept,
                         fdx_api_actor_type: nil,
                         fdx_api_data_provider_id: nil,
                         fdx_api_data_recipient_id: nil,
                         account_id: nil,
                         tax_year: nil,
                         tax_forms: nil,
                         tax_data_type: nil,
                         result_type: ResultType::LIGHTWEIGHT)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/tax-forms',
                                 Server::DEFAULT)
               .header_param(new_parameter(authorization, key: 'Authorization')
                              .is_required(true))
               .header_param(new_parameter(x_fapi_interaction_id, key: 'x-fapi-interaction-id')
                              .is_required(true))
               .header_param(new_parameter(accept, key: 'Accept')
                              .is_required(true))
               .header_param(new_parameter(fdx_api_actor_type, key: 'FDX-API-Actor-Type'))
               .header_param(new_parameter(fdx_api_data_provider_id, key: 'FDX-API-Data-Provider-Id'))
               .header_param(new_parameter(fdx_api_data_recipient_id, key: 'FDX-API-Data-Recipient-Id'))
               .query_param(new_parameter(, key: 'accountId'))
               .query_param(new_parameter(tax_year, key: 'taxYear'))
               .query_param(new_parameter(tax_forms, key: 'taxForms'))
               .query_param(new_parameter(tax_data_type, key: 'taxDataType'))
               .query_param(new_parameter(result_type, key: 'resultType'))
               .auth(Or.new('TaxBasicAuth', 'OAuthFapi1Advanced')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TaxStatementList.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Request is invalid or parameter values are not supported',
                             ErrorException)
                .local_error('404',
                             'Tax Form not Found',
                             ErrorException)
                .local_error('406',
                             'Content Type not Supported',
                             ErrorException)
                .local_error('409',
                             'Tax forms are not currently available for this account or this'\
                              ' year',
                             ErrorException)
                .local_error('500',
                             'Catch-all exception where request was not processed due to an'\
                              ' internal outage/issue. Consider other more specific errors'\
                              ' before using this error',
                             ErrorException)
                .local_error('501',
                             'Error when FdxVersion in Header is not one of those'\
                              ' implemented at backend',
                             ErrorException)
                .local_error('503',
                             'System is down for maintenance',
                             ErrorException))
    .execute
end