apimatic-pnl-sdk 1.0.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 +7 -0
- data/LICENSE +28 -0
- data/README.md +164 -0
- data/bin/console +15 -0
- data/lib/postnl_ecommerce/api_helper.rb +10 -0
- data/lib/postnl_ecommerce/client.rb +126 -0
- data/lib/postnl_ecommerce/configuration.rb +195 -0
- data/lib/postnl_ecommerce/controllers/barcode_controller.rb +71 -0
- data/lib/postnl_ecommerce/controllers/base_controller.rb +60 -0
- data/lib/postnl_ecommerce/controllers/checkout_controller.rb +45 -0
- data/lib/postnl_ecommerce/controllers/confirming_controller.rb +45 -0
- data/lib/postnl_ecommerce/controllers/deliverydate_controller.rb +233 -0
- data/lib/postnl_ecommerce/controllers/labelling_controller.rb +52 -0
- data/lib/postnl_ecommerce/controllers/locations_controller.rb +271 -0
- data/lib/postnl_ecommerce/controllers/postalcode_check_controller.rb +60 -0
- data/lib/postnl_ecommerce/controllers/shipment_controller.rb +52 -0
- data/lib/postnl_ecommerce/controllers/shipping_status_controller.rb +222 -0
- data/lib/postnl_ecommerce/controllers/timeframes_controller.rb +90 -0
- data/lib/postnl_ecommerce/exceptions/api_exception.rb +21 -0
- data/lib/postnl_ecommerce/exceptions/barcode_response_invalid_exception.rb +57 -0
- data/lib/postnl_ecommerce/exceptions/confirming_response_error_exception.rb +55 -0
- data/lib/postnl_ecommerce/exceptions/internal_server_error_exception.rb +46 -0
- data/lib/postnl_ecommerce/exceptions/invalid_request_exception.rb +62 -0
- data/lib/postnl_ecommerce/exceptions/labelling_response_invalid_exception.rb +57 -0
- data/lib/postnl_ecommerce/exceptions/method_not_allowed_only_get_exception.rb +53 -0
- data/lib/postnl_ecommerce/exceptions/method_not_allowed_only_get_post_exception.rb +53 -0
- data/lib/postnl_ecommerce/exceptions/method_not_allowed_only_post_exception.rb +53 -0
- data/lib/postnl_ecommerce/exceptions/postalcode_check_response_invalid_exception.rb +55 -0
- data/lib/postnl_ecommerce/exceptions/too_many_requests_exception.rb +53 -0
- data/lib/postnl_ecommerce/exceptions/unauthorized_exception.rb +53 -0
- data/lib/postnl_ecommerce/http/api_response.rb +19 -0
- data/lib/postnl_ecommerce/http/auth/custom_header_authentication.rb +52 -0
- data/lib/postnl_ecommerce/http/http_call_back.rb +10 -0
- data/lib/postnl_ecommerce/http/http_method_enum.rb +10 -0
- data/lib/postnl_ecommerce/http/http_request.rb +10 -0
- data/lib/postnl_ecommerce/http/http_response.rb +10 -0
- data/lib/postnl_ecommerce/http/proxy_settings.rb +22 -0
- data/lib/postnl_ecommerce/models/address.rb +240 -0
- data/lib/postnl_ecommerce/models/address_type_enum.rb +36 -0
- data/lib/postnl_ecommerce/models/amount.rb +138 -0
- data/lib/postnl_ecommerce/models/barcode_error.rb +71 -0
- data/lib/postnl_ecommerce/models/barcode_response.rb +62 -0
- data/lib/postnl_ecommerce/models/base_model.rb +110 -0
- data/lib/postnl_ecommerce/models/checkout_address.rb +120 -0
- data/lib/postnl_ecommerce/models/checkout_cut_off_day_enum.rb +61 -0
- data/lib/postnl_ecommerce/models/checkout_cut_off_time.rb +91 -0
- data/lib/postnl_ecommerce/models/checkout_cut_off_type_enum.rb +40 -0
- data/lib/postnl_ecommerce/models/checkout_delivery_option.rb +81 -0
- data/lib/postnl_ecommerce/models/checkout_location.rb +126 -0
- data/lib/postnl_ecommerce/models/checkout_option_enum.rb +64 -0
- data/lib/postnl_ecommerce/models/checkout_pickup_address.rb +112 -0
- data/lib/postnl_ecommerce/models/checkout_pickup_option.rb +103 -0
- data/lib/postnl_ecommerce/models/checkout_request.rb +152 -0
- data/lib/postnl_ecommerce/models/checkout_response.rb +110 -0
- data/lib/postnl_ecommerce/models/checkout_time_frame.rb +108 -0
- data/lib/postnl_ecommerce/models/checkout_warning.rb +95 -0
- data/lib/postnl_ecommerce/models/checkout_warning_option_enum.rb +68 -0
- data/lib/postnl_ecommerce/models/code_enum.rb +44 -0
- data/lib/postnl_ecommerce/models/complete_status.rb +62 -0
- data/lib/postnl_ecommerce/models/complete_status_shipment.rb +270 -0
- data/lib/postnl_ecommerce/models/confirming_custom.rb +239 -0
- data/lib/postnl_ecommerce/models/confirming_custom_content.rb +113 -0
- data/lib/postnl_ecommerce/models/confirming_error.rb +71 -0
- data/lib/postnl_ecommerce/models/confirming_message.rb +70 -0
- data/lib/postnl_ecommerce/models/confirming_request.rb +86 -0
- data/lib/postnl_ecommerce/models/confirming_response.rb +71 -0
- data/lib/postnl_ecommerce/models/confirming_response_shipment.rb +103 -0
- data/lib/postnl_ecommerce/models/confirming_shipment.rb +472 -0
- data/lib/postnl_ecommerce/models/contact.rb +101 -0
- data/lib/postnl_ecommerce/models/countrycode_enum.rb +36 -0
- data/lib/postnl_ecommerce/models/currency_enum.rb +44 -0
- data/lib/postnl_ecommerce/models/currency_labelling_api_enum.rb +36 -0
- data/lib/postnl_ecommerce/models/current_status.rb +62 -0
- data/lib/postnl_ecommerce/models/current_status_shipment.rb +207 -0
- data/lib/postnl_ecommerce/models/customer.rb +123 -0
- data/lib/postnl_ecommerce/models/customer_address.rb +237 -0
- data/lib/postnl_ecommerce/models/customs.rb +238 -0
- data/lib/postnl_ecommerce/models/customs_labelling_api.rb +238 -0
- data/lib/postnl_ecommerce/models/delivery_options.rb +64 -0
- data/lib/postnl_ecommerce/models/deliverydate_delivery_response.rb +87 -0
- data/lib/postnl_ecommerce/models/deliverydate_option_enum.rb +56 -0
- data/lib/postnl_ecommerce/models/deliverydate_options.rb +65 -0
- data/lib/postnl_ecommerce/models/deliverydate_shipping_response.rb +62 -0
- data/lib/postnl_ecommerce/models/detail.rb +62 -0
- data/lib/postnl_ecommerce/models/dimension.rb +106 -0
- data/lib/postnl_ecommerce/models/error.rb +73 -0
- data/lib/postnl_ecommerce/models/event.rb +127 -0
- data/lib/postnl_ecommerce/models/expectation.rb +71 -0
- data/lib/postnl_ecommerce/models/extra_field.rb +71 -0
- data/lib/postnl_ecommerce/models/fault.rb +71 -0
- data/lib/postnl_ecommerce/models/fault_shipping_status_api.rb +71 -0
- data/lib/postnl_ecommerce/models/friday.rb +62 -0
- data/lib/postnl_ecommerce/models/get_locations_result_multiple.rb +71 -0
- data/lib/postnl_ecommerce/models/get_locations_result_single.rb +62 -0
- data/lib/postnl_ecommerce/models/group.rb +97 -0
- data/lib/postnl_ecommerce/models/hazardous_material.rb +178 -0
- data/lib/postnl_ecommerce/models/labelling_customer.rb +123 -0
- data/lib/postnl_ecommerce/models/labelling_customer_labelling_api.rb +123 -0
- data/lib/postnl_ecommerce/models/labelling_customer_message.rb +83 -0
- data/lib/postnl_ecommerce/models/labelling_customer_shipment.rb +484 -0
- data/lib/postnl_ecommerce/models/labelling_customer_shipment_labelling_api.rb +484 -0
- data/lib/postnl_ecommerce/models/labelling_customs_content.rb +111 -0
- data/lib/postnl_ecommerce/models/labelling_error.rb +81 -0
- data/lib/postnl_ecommerce/models/labelling_label.rb +84 -0
- data/lib/postnl_ecommerce/models/labelling_merged_label.rb +80 -0
- data/lib/postnl_ecommerce/models/labelling_request.rb +112 -0
- data/lib/postnl_ecommerce/models/labelling_response.rb +95 -0
- data/lib/postnl_ecommerce/models/labelling_response_shipment.rb +123 -0
- data/lib/postnl_ecommerce/models/language_enum.rb +48 -0
- data/lib/postnl_ecommerce/models/location.rb +174 -0
- data/lib/postnl_ecommerce/models/location_response_single.rb +63 -0
- data/lib/postnl_ecommerce/models/locations_address.rb +122 -0
- data/lib/postnl_ecommerce/models/locations_delivery_option_enum.rb +40 -0
- data/lib/postnl_ecommerce/models/locations_opening_hours.rb +121 -0
- data/lib/postnl_ecommerce/models/locations_response_multiple.rb +63 -0
- data/lib/postnl_ecommerce/models/monday.rb +62 -0
- data/lib/postnl_ecommerce/models/no_timeframes_options.rb +62 -0
- data/lib/postnl_ecommerce/models/old_status.rb +106 -0
- data/lib/postnl_ecommerce/models/opening_hours.rb +121 -0
- data/lib/postnl_ecommerce/models/opening_hours_per_day.rb +71 -0
- data/lib/postnl_ecommerce/models/options.rb +64 -0
- data/lib/postnl_ecommerce/models/origin_country_code_enum.rb +36 -0
- data/lib/postnl_ecommerce/models/postalcode_check_address.rb +116 -0
- data/lib/postnl_ecommerce/models/postalcode_check_error.rb +81 -0
- data/lib/postnl_ecommerce/models/product_option.rb +74 -0
- data/lib/postnl_ecommerce/models/reason_no_timeframe.rb +104 -0
- data/lib/postnl_ecommerce/models/reason_no_timeframes.rb +71 -0
- data/lib/postnl_ecommerce/models/saturday.rb +62 -0
- data/lib/postnl_ecommerce/models/shipment_type_enum.rb +50 -0
- data/lib/postnl_ecommerce/models/shippingstatus_address.rb +204 -0
- data/lib/postnl_ecommerce/models/shippingstatus_amount.rb +75 -0
- data/lib/postnl_ecommerce/models/shippingstatus_customer.rb +83 -0
- data/lib/postnl_ecommerce/models/shippingstatus_dimension.rb +101 -0
- data/lib/postnl_ecommerce/models/shippingstatus_product_option.rb +74 -0
- data/lib/postnl_ecommerce/models/shippingstatus_product_options.rb +63 -0
- data/lib/postnl_ecommerce/models/shippingstatus_response.rb +94 -0
- data/lib/postnl_ecommerce/models/shippingstatus_response_signature.rb +71 -0
- data/lib/postnl_ecommerce/models/shippingstatus_response_updated_shipment.rb +105 -0
- data/lib/postnl_ecommerce/models/shippingstatus_warning.rb +71 -0
- data/lib/postnl_ecommerce/models/signature.rb +84 -0
- data/lib/postnl_ecommerce/models/status.rb +108 -0
- data/lib/postnl_ecommerce/models/sunday.rb +62 -0
- data/lib/postnl_ecommerce/models/sustainability.rb +73 -0
- data/lib/postnl_ecommerce/models/thursday.rb +62 -0
- data/lib/postnl_ecommerce/models/timeframe.rb +71 -0
- data/lib/postnl_ecommerce/models/timeframe_options_enum.rb +60 -0
- data/lib/postnl_ecommerce/models/timeframe_response.rb +74 -0
- data/lib/postnl_ecommerce/models/timeframe_timeframe.rb +96 -0
- data/lib/postnl_ecommerce/models/timeframes.rb +71 -0
- data/lib/postnl_ecommerce/models/timeframes_response_object.rb +71 -0
- data/lib/postnl_ecommerce/models/tuesday.rb +62 -0
- data/lib/postnl_ecommerce/models/type_enum.rb +64 -0
- data/lib/postnl_ecommerce/models/updated_shipment_status.rb +108 -0
- data/lib/postnl_ecommerce/models/warning.rb +71 -0
- data/lib/postnl_ecommerce/models/warnings.rb +62 -0
- data/lib/postnl_ecommerce/models/wednesday.rb +62 -0
- data/lib/postnl_ecommerce/utilities/date_time_helper.rb +11 -0
- data/lib/postnl_ecommerce/utilities/file_wrapper.rb +28 -0
- data/lib/postnl_ecommerce.rb +188 -0
- data/test/controllers/controller_test_base.rb +23 -0
- data/test/controllers/test_barcode_controller.rb +52 -0
- data/test/controllers/test_checkout_controller.rb +63 -0
- data/test/controllers/test_confirming_controller.rb +54 -0
- data/test/controllers/test_deliverydate_controller.rb +60 -0
- data/test/controllers/test_labelling_controller.rb +57 -0
- data/test/controllers/test_locations_controller.rb +185 -0
- data/test/controllers/test_postalcode_check_controller.rb +55 -0
- data/test/controllers/test_shipment_controller.rb +57 -0
- data/test/controllers/test_shipping_status_controller.rb +209 -0
- data/test/controllers/test_timeframes_controller.rb +67 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +283 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# PostalcodeCheckController
|
|
8
|
+
class PostalcodeCheckController < BaseController
|
|
9
|
+
# Please note that this API is not available on the sandbox environment.
|
|
10
|
+
# Request example:
|
|
11
|
+
# ```
|
|
12
|
+
# curl -X GET
|
|
13
|
+
# "https://api.postnl.nl/shipment/checkout/v1/postalcodecheck?postalcode=357
|
|
14
|
+
# 1ZZ&housenumber=74&housenumberaddition=bis" \
|
|
15
|
+
# -H "Accept: application/json" \
|
|
16
|
+
# -H "apikey: APIKEY-HERE"
|
|
17
|
+
# ```
|
|
18
|
+
# @param [String] postalcode Required parameter: TODO: type description
|
|
19
|
+
# here
|
|
20
|
+
# @param [String] housenumber Required parameter: TODO: type description
|
|
21
|
+
# here
|
|
22
|
+
# @param [String] housenumberaddition Optional parameter: TODO: type
|
|
23
|
+
# description here
|
|
24
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
25
|
+
def checkout_postalcode_check(postalcode,
|
|
26
|
+
housenumber,
|
|
27
|
+
housenumberaddition: nil)
|
|
28
|
+
@api_call
|
|
29
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
30
|
+
'/shipment/checkout/v1/postalcodecheck',
|
|
31
|
+
Server::POSTNL)
|
|
32
|
+
.query_param(new_parameter(postalcode, key: 'postalcode'))
|
|
33
|
+
.query_param(new_parameter(housenumber, key: 'housenumber'))
|
|
34
|
+
.query_param(new_parameter(housenumberaddition, key: 'housenumberaddition'))
|
|
35
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
36
|
+
.auth(Single.new('APIKeyHeader')))
|
|
37
|
+
.response(new_response_handler
|
|
38
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
39
|
+
.deserialize_into(PostalcodeCheckAddress.method(:from_hash))
|
|
40
|
+
.is_api_response(true)
|
|
41
|
+
.is_response_array(true)
|
|
42
|
+
.local_error('400',
|
|
43
|
+
'Bad request',
|
|
44
|
+
PostalcodeCheckResponseInvalidException)
|
|
45
|
+
.local_error('401',
|
|
46
|
+
'Invalid apikey',
|
|
47
|
+
UnauthorizedException)
|
|
48
|
+
.local_error('405',
|
|
49
|
+
'Method not allowed',
|
|
50
|
+
MethodNotAllowedOnlyGetException)
|
|
51
|
+
.local_error('429',
|
|
52
|
+
'Too many requests',
|
|
53
|
+
TooManyRequestsException)
|
|
54
|
+
.local_error('500',
|
|
55
|
+
'Internal server error',
|
|
56
|
+
InternalServerErrorException))
|
|
57
|
+
.execute
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# ShipmentController
|
|
8
|
+
class ShipmentController < BaseController
|
|
9
|
+
# TODO: type endpoint description here
|
|
10
|
+
# @param [LabellingRequest] body Required parameter: TODO: type description
|
|
11
|
+
# here
|
|
12
|
+
# @param [TrueClass | FalseClass] confirm Optional parameter: With the
|
|
13
|
+
# Confirm boolean in the request, you can determine if you want to confirm
|
|
14
|
+
# the shipment in the same call or not. If the Boolean variable is true the
|
|
15
|
+
# shipment will be preannounced. If this is set to false, then an additional
|
|
16
|
+
# Confirming API request needs to be made.
|
|
17
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
18
|
+
def generate_shipment_label(body,
|
|
19
|
+
confirm: true)
|
|
20
|
+
@api_call
|
|
21
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
22
|
+
'/shipment/v2_2/label',
|
|
23
|
+
Server::POSTNL)
|
|
24
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
25
|
+
.body_param(new_parameter(body))
|
|
26
|
+
.query_param(new_parameter(confirm, key: 'confirm'))
|
|
27
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
28
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
29
|
+
.auth(Single.new('APIKeyHeader')))
|
|
30
|
+
.response(new_response_handler
|
|
31
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
32
|
+
.deserialize_into(LabellingResponse.method(:from_hash))
|
|
33
|
+
.is_api_response(true)
|
|
34
|
+
.local_error('400',
|
|
35
|
+
'Error payload',
|
|
36
|
+
LabellingResponseInvalidException)
|
|
37
|
+
.local_error('401',
|
|
38
|
+
'Invalid apikey',
|
|
39
|
+
UnauthorizedException)
|
|
40
|
+
.local_error('405',
|
|
41
|
+
'Method not allowed',
|
|
42
|
+
MethodNotAllowedOnlyPostException)
|
|
43
|
+
.local_error('429',
|
|
44
|
+
'Too many requests',
|
|
45
|
+
TooManyRequestsException)
|
|
46
|
+
.local_error('500',
|
|
47
|
+
'Internal server error',
|
|
48
|
+
InternalServerErrorException))
|
|
49
|
+
.execute
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# ShippingStatusController
|
|
8
|
+
class ShippingStatusController < BaseController
|
|
9
|
+
# Request example:
|
|
10
|
+
# ```
|
|
11
|
+
# curl -X GET
|
|
12
|
+
# "https://api-sandbox.postnl.nl/shipment/v2/status/barcode/3SDEVC172649258"
|
|
13
|
+
# \
|
|
14
|
+
# -H "Accept: application/json" \
|
|
15
|
+
# -H "apikey: APIKEY-HERE" \
|
|
16
|
+
# ```
|
|
17
|
+
# @param [String] barcode Required parameter: Barcode of the shipment. This
|
|
18
|
+
# is a unique value.
|
|
19
|
+
# @param [TrueClass | FalseClass] detail Optional parameter: Option to
|
|
20
|
+
# include old statuses in the response
|
|
21
|
+
# @param [LanguageEnum] language Optional parameter: Language of the
|
|
22
|
+
# returned shipment and status descriptions (default is Dutch).
|
|
23
|
+
# @param [String] max_days Optional parameter: Limit the number of days that
|
|
24
|
+
# will be searched (decrease this amount for better performance).
|
|
25
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
26
|
+
def get_status_by_barcode(barcode,
|
|
27
|
+
detail: false,
|
|
28
|
+
language: nil,
|
|
29
|
+
max_days: nil)
|
|
30
|
+
@api_call
|
|
31
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
32
|
+
'/shipment/v2/status/barcode/{barcode}',
|
|
33
|
+
Server::POSTNL)
|
|
34
|
+
.template_param(new_parameter(barcode, key: 'barcode')
|
|
35
|
+
.should_encode(true))
|
|
36
|
+
.query_param(new_parameter(detail, key: 'detail'))
|
|
37
|
+
.query_param(new_parameter(language, key: 'language'))
|
|
38
|
+
.query_param(new_parameter(max_days, key: 'maxDays'))
|
|
39
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
40
|
+
.auth(Single.new('APIKeyHeader')))
|
|
41
|
+
.response(new_response_handler
|
|
42
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
43
|
+
.deserialize_into(ShippingstatusResponse.method(:from_hash))
|
|
44
|
+
.is_api_response(true)
|
|
45
|
+
.local_error('400',
|
|
46
|
+
'Invalid request',
|
|
47
|
+
InternalServerErrorException)
|
|
48
|
+
.local_error('401',
|
|
49
|
+
'Invalid apikey',
|
|
50
|
+
UnauthorizedException)
|
|
51
|
+
.local_error('405',
|
|
52
|
+
'Method not allowed',
|
|
53
|
+
MethodNotAllowedOnlyGetException)
|
|
54
|
+
.local_error('429',
|
|
55
|
+
'Too many requests',
|
|
56
|
+
TooManyRequestsException)
|
|
57
|
+
.local_error('500',
|
|
58
|
+
'Internal server error',
|
|
59
|
+
InternalServerErrorException))
|
|
60
|
+
.execute
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Request example:
|
|
64
|
+
# ```
|
|
65
|
+
# curl -X GET
|
|
66
|
+
# "https://api-sandbox.postnl.nl/shipment/v2/status/reference?detail=true&la
|
|
67
|
+
# nguage=NL&customerCode={{CustomerCode}}&customerNumber={{CustomerNumber}}&
|
|
68
|
+
# reference=REF98173245876329" \
|
|
69
|
+
# -H "Accept: application/json" \
|
|
70
|
+
# -H "apikey: APIKEY-HERE"
|
|
71
|
+
# ```
|
|
72
|
+
# @param [String] customer_code Required parameter: Customer code as known
|
|
73
|
+
# at PostNL Pakketten
|
|
74
|
+
# @param [String] customer_number Required parameter: Customer number as
|
|
75
|
+
# known at PostNL Pakketten
|
|
76
|
+
# @param [String] reference_id Required parameter: The customer reference
|
|
77
|
+
# belonging to the shipment
|
|
78
|
+
# @param [TrueClass | FalseClass] detail Optional parameter: Option to
|
|
79
|
+
# include old statuses in the response
|
|
80
|
+
# @param [LanguageEnum] language Optional parameter: Language of the
|
|
81
|
+
# returned shipment and status descriptions (default is Dutch).
|
|
82
|
+
# @param [String] max_days Optional parameter: Limit the number of days that
|
|
83
|
+
# will be searched (decrease this amount for better performance). By default
|
|
84
|
+
# this is 90 days in the past.
|
|
85
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
86
|
+
def get_status_by_reference(customer_code,
|
|
87
|
+
customer_number,
|
|
88
|
+
reference_id,
|
|
89
|
+
detail: false,
|
|
90
|
+
language: nil,
|
|
91
|
+
max_days: nil)
|
|
92
|
+
@api_call
|
|
93
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
94
|
+
'/shipment/v2/status/reference/{referenceId}',
|
|
95
|
+
Server::POSTNL)
|
|
96
|
+
.query_param(new_parameter(customer_code, key: 'customerCode'))
|
|
97
|
+
.query_param(new_parameter(customer_number, key: 'customerNumber'))
|
|
98
|
+
.template_param(new_parameter(reference_id, key: 'referenceId')
|
|
99
|
+
.should_encode(true))
|
|
100
|
+
.query_param(new_parameter(detail, key: 'detail'))
|
|
101
|
+
.query_param(new_parameter(language, key: 'language'))
|
|
102
|
+
.query_param(new_parameter(max_days, key: 'maxDays'))
|
|
103
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
104
|
+
.auth(Single.new('APIKeyHeader')))
|
|
105
|
+
.response(new_response_handler
|
|
106
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
107
|
+
.deserialize_into(ShippingstatusResponse.method(:from_hash))
|
|
108
|
+
.is_api_response(true)
|
|
109
|
+
.local_error('400',
|
|
110
|
+
'Invalid request',
|
|
111
|
+
InternalServerErrorException)
|
|
112
|
+
.local_error('401',
|
|
113
|
+
'Invalid apikey',
|
|
114
|
+
UnauthorizedException)
|
|
115
|
+
.local_error('405',
|
|
116
|
+
'Method not allowed',
|
|
117
|
+
MethodNotAllowedOnlyGetException)
|
|
118
|
+
.local_error('429',
|
|
119
|
+
'Too many requests',
|
|
120
|
+
TooManyRequestsException)
|
|
121
|
+
.local_error('500',
|
|
122
|
+
'Internal server error',
|
|
123
|
+
InternalServerErrorException))
|
|
124
|
+
.execute
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Request example:
|
|
128
|
+
# ```
|
|
129
|
+
# curl -X GET
|
|
130
|
+
# "https://api-sandbox.postnl.nl/shipment/v2/status/signature/3SDEVC17264925
|
|
131
|
+
# 8" \
|
|
132
|
+
# -H "Accept: application/json" \
|
|
133
|
+
# -H "apikey: APIKEY-HERE"
|
|
134
|
+
# ```
|
|
135
|
+
# @param [String] barcode Required parameter: Barcode of the shipment
|
|
136
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
137
|
+
def get_shipment_signature(barcode)
|
|
138
|
+
@api_call
|
|
139
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
140
|
+
'/shipment/v2/status/signature/{barcode}',
|
|
141
|
+
Server::POSTNL)
|
|
142
|
+
.template_param(new_parameter(barcode, key: 'barcode')
|
|
143
|
+
.should_encode(true))
|
|
144
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
145
|
+
.auth(Single.new('APIKeyHeader')))
|
|
146
|
+
.response(new_response_handler
|
|
147
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
148
|
+
.deserialize_into(ShippingstatusResponseSignature.method(:from_hash))
|
|
149
|
+
.is_api_response(true)
|
|
150
|
+
.local_error('400',
|
|
151
|
+
'Invalid request',
|
|
152
|
+
InternalServerErrorException)
|
|
153
|
+
.local_error('401',
|
|
154
|
+
'Invalid apikey',
|
|
155
|
+
UnauthorizedException)
|
|
156
|
+
.local_error('405',
|
|
157
|
+
'Method not allowed',
|
|
158
|
+
MethodNotAllowedOnlyGetException)
|
|
159
|
+
.local_error('429',
|
|
160
|
+
'Too many requests',
|
|
161
|
+
TooManyRequestsException)
|
|
162
|
+
.local_error('500',
|
|
163
|
+
'Internal server error',
|
|
164
|
+
InternalServerErrorException))
|
|
165
|
+
.execute
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Request example:
|
|
169
|
+
# ```
|
|
170
|
+
# curl -X GET
|
|
171
|
+
# "https://api-sandbox.postnl.nl/shipment/v2/status/11223344/updatedshipment
|
|
172
|
+
# s?period=2022-12-25T10:00:00&period=2022-12-25T10:12:00" \
|
|
173
|
+
# -H "Accept: application/json" \
|
|
174
|
+
# -H "apikey: APIKEY-HERE" \
|
|
175
|
+
# ```
|
|
176
|
+
# @param [String] customernumber Required parameter: Your customer number
|
|
177
|
+
# @param [Array[String]] period Optional parameter: Optional array which
|
|
178
|
+
# defines a specific period in which to return updated shipments. For
|
|
179
|
+
# optimal results, schedule calls at a frequency between 5-15 minutes and
|
|
180
|
+
# align the requested period accordingly to ensure complete coverage of past
|
|
181
|
+
# updates. Shorter periods yield improved response times. The API
|
|
182
|
+
# accommodates a maximum requested period of 2 hours, granting access to
|
|
183
|
+
# shipment data up to 48 hours in the past. Please use the following format:
|
|
184
|
+
# YYYY-MM-DDTHH:MM:SS and repeat this variable to define the period (e.g.
|
|
185
|
+
# /updatedshipments?period=2022-11-07T12:00:00.000&period=2022-11-07T12:05:0
|
|
186
|
+
# 0.000).
|
|
187
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
188
|
+
def get_updated_status_by_customer_number(customernumber,
|
|
189
|
+
period: nil)
|
|
190
|
+
@api_call
|
|
191
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
192
|
+
'/shipment/v2/status/{customernumber}/updatedshipments',
|
|
193
|
+
Server::POSTNL)
|
|
194
|
+
.template_param(new_parameter(customernumber, key: 'customernumber')
|
|
195
|
+
.should_encode(true))
|
|
196
|
+
.query_param(new_parameter(period, key: 'period'))
|
|
197
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
198
|
+
.auth(Single.new('APIKeyHeader')))
|
|
199
|
+
.response(new_response_handler
|
|
200
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
201
|
+
.deserialize_into(ShippingstatusResponseUpdatedShipment.method(:from_hash))
|
|
202
|
+
.is_api_response(true)
|
|
203
|
+
.is_response_array(true)
|
|
204
|
+
.local_error('400',
|
|
205
|
+
'Invalid request',
|
|
206
|
+
InternalServerErrorException)
|
|
207
|
+
.local_error('401',
|
|
208
|
+
'Invalid apikey',
|
|
209
|
+
UnauthorizedException)
|
|
210
|
+
.local_error('405',
|
|
211
|
+
'Method not allowed',
|
|
212
|
+
MethodNotAllowedOnlyGetException)
|
|
213
|
+
.local_error('429',
|
|
214
|
+
'Too many requests',
|
|
215
|
+
TooManyRequestsException)
|
|
216
|
+
.local_error('500',
|
|
217
|
+
'Internal server error',
|
|
218
|
+
InternalServerErrorException))
|
|
219
|
+
.execute
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# TimeframesController
|
|
8
|
+
class TimeframesController < BaseController
|
|
9
|
+
# Request example:
|
|
10
|
+
# ```
|
|
11
|
+
# curl -X GET
|
|
12
|
+
# "https://api-sandbox.postnl.nl/shipment/v2_1/calculate/timeframes?AllowSun
|
|
13
|
+
# daySorting=false&StartDate=30-06-2022&EndDate=02-07-2022&CountryCode=NL&Po
|
|
14
|
+
# stalCode=2132WT&HouseNumber=42&HouseNrExt=A&City=Hoofddorp&Street=Siriusdr
|
|
15
|
+
# eef&Options=Daytime%2CEvening" \
|
|
16
|
+
# -H "Accept: application/json" \
|
|
17
|
+
# -H "apikey: APIKEY-HERE" \
|
|
18
|
+
# ```
|
|
19
|
+
# @param [TrueClass | FalseClass] allow_sunday_sorting Required parameter:
|
|
20
|
+
# Whether or not the requesting party allows for Sunday sorting (which leads
|
|
21
|
+
# to delivery on Monday).
|
|
22
|
+
# @param [String] start_date Required parameter: Date of the beginning of
|
|
23
|
+
# the timeframe. Format: dd-MM-yyyy
|
|
24
|
+
# @param [String] end_date Required parameter: Date of the enddate of the
|
|
25
|
+
# timeframe. Format:dd-MM-yyyy. Enddate may not be before StartDate.
|
|
26
|
+
# @param [CountrycodeEnum] country_code Required parameter: The ISO2 country
|
|
27
|
+
# code of the delivery address
|
|
28
|
+
# @param [String] postal_code Required parameter: Zipcode of the delivery
|
|
29
|
+
# address
|
|
30
|
+
# @param [Integer] house_number Required parameter: The house number of the
|
|
31
|
+
# delivery address
|
|
32
|
+
# @param [Array[TimeframeOptionsEnum]] options Required parameter: The
|
|
33
|
+
# delivery options for which expected timeframes should be calculated. At
|
|
34
|
+
# least one delivery option must be specified. Multiple values should be
|
|
35
|
+
# comma-separated.
|
|
36
|
+
# @param [String] house_nr_ext Optional parameter: House number extension of
|
|
37
|
+
# the delivery address
|
|
38
|
+
# @param [String] city Optional parameter: City of the delivery address
|
|
39
|
+
# @param [String] street Optional parameter: The street name of the delivery
|
|
40
|
+
# address
|
|
41
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
42
|
+
def retrieve_delivery_timeframes(allow_sunday_sorting,
|
|
43
|
+
start_date,
|
|
44
|
+
end_date,
|
|
45
|
+
country_code,
|
|
46
|
+
postal_code,
|
|
47
|
+
house_number,
|
|
48
|
+
options,
|
|
49
|
+
house_nr_ext: nil,
|
|
50
|
+
city: nil,
|
|
51
|
+
street: nil)
|
|
52
|
+
@api_call
|
|
53
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
54
|
+
'/shipment/v2_1/calculate/timeframes',
|
|
55
|
+
Server::POSTNL)
|
|
56
|
+
.query_param(new_parameter(allow_sunday_sorting, key: 'AllowSundaySorting'))
|
|
57
|
+
.query_param(new_parameter(start_date, key: 'StartDate'))
|
|
58
|
+
.query_param(new_parameter(end_date, key: 'EndDate'))
|
|
59
|
+
.query_param(new_parameter(country_code, key: 'CountryCode'))
|
|
60
|
+
.query_param(new_parameter(postal_code, key: 'PostalCode'))
|
|
61
|
+
.query_param(new_parameter(house_number, key: 'HouseNumber'))
|
|
62
|
+
.query_param(new_parameter(options, key: 'Options'))
|
|
63
|
+
.query_param(new_parameter(house_nr_ext, key: 'HouseNrExt'))
|
|
64
|
+
.query_param(new_parameter(city, key: 'City'))
|
|
65
|
+
.query_param(new_parameter(street, key: 'Street'))
|
|
66
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
67
|
+
.auth(Single.new('APIKeyHeader')))
|
|
68
|
+
.response(new_response_handler
|
|
69
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
70
|
+
.deserialize_into(TimeframeResponse.method(:from_hash))
|
|
71
|
+
.is_api_response(true)
|
|
72
|
+
.local_error('400',
|
|
73
|
+
'Invalid request',
|
|
74
|
+
InvalidRequestException)
|
|
75
|
+
.local_error('401',
|
|
76
|
+
'Invalid apikey',
|
|
77
|
+
UnauthorizedException)
|
|
78
|
+
.local_error('405',
|
|
79
|
+
'Method not allowed',
|
|
80
|
+
MethodNotAllowedOnlyGetPostException)
|
|
81
|
+
.local_error('429',
|
|
82
|
+
'Too many requests',
|
|
83
|
+
TooManyRequestsException)
|
|
84
|
+
.local_error('500',
|
|
85
|
+
'Internal server error',
|
|
86
|
+
InternalServerErrorException))
|
|
87
|
+
.execute
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# barcodeResponseInvalid class.
|
|
8
|
+
class BarcodeResponseInvalidException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# A list of errors. See [Error
|
|
13
|
+
# codes](https://developer.postnl.nl/docs/#/http/reference-data/error-codes)
|
|
14
|
+
# for possible values.
|
|
15
|
+
# @return [Array[BarcodeError]]
|
|
16
|
+
attr_accessor :errors
|
|
17
|
+
|
|
18
|
+
# The constructor.
|
|
19
|
+
# @param [String] reason The reason for raising an exception.
|
|
20
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
21
|
+
def initialize(reason, response)
|
|
22
|
+
super(reason, response)
|
|
23
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
24
|
+
unbox(hash)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Populates this object by extracting properties from a hash.
|
|
28
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
29
|
+
# response body.
|
|
30
|
+
def unbox(hash)
|
|
31
|
+
return nil unless hash
|
|
32
|
+
|
|
33
|
+
# Parameter is an array, so we need to iterate through it
|
|
34
|
+
@errors = nil
|
|
35
|
+
unless hash['errors'].nil?
|
|
36
|
+
@errors = []
|
|
37
|
+
hash['errors'].each do |structure|
|
|
38
|
+
@errors << (BarcodeError.from_hash(structure) if structure)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@errors = SKIP unless hash.key?('errors')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Provides a human-readable string representation of the object.
|
|
46
|
+
def to_s
|
|
47
|
+
class_name = self.class.name.split('::').last
|
|
48
|
+
"<#{class_name} errors: #{@errors}>"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
52
|
+
def inspect
|
|
53
|
+
class_name = self.class.name.split('::').last
|
|
54
|
+
"<#{class_name} errors: #{@errors.inspect}>"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# confirmingResponse_Error class.
|
|
8
|
+
class ConfirmingResponseErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [Array[ConfirmingResponseShipment]]
|
|
14
|
+
attr_accessor :response_shipments
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
# Parameter is an array, so we need to iterate through it
|
|
32
|
+
@response_shipments = nil
|
|
33
|
+
unless hash['ResponseShipments'].nil?
|
|
34
|
+
@response_shipments = []
|
|
35
|
+
hash['ResponseShipments'].each do |structure|
|
|
36
|
+
@response_shipments << (ConfirmingResponseShipment.from_hash(structure) if structure)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@response_shipments = SKIP unless hash.key?('ResponseShipments')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Provides a human-readable string representation of the object.
|
|
44
|
+
def to_s
|
|
45
|
+
class_name = self.class.name.split('::').last
|
|
46
|
+
"<#{class_name} response_shipments: #{@response_shipments}>"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
50
|
+
def inspect
|
|
51
|
+
class_name = self.class.name.split('::').last
|
|
52
|
+
"<#{class_name} response_shipments: #{@response_shipments.inspect}>"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module PostnlEcommerce
|
|
7
|
+
# InternalServerError class.
|
|
8
|
+
class InternalServerErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [Fault]
|
|
14
|
+
attr_accessor :fault
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@fault = Fault.from_hash(hash['fault']) if hash['fault']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} fault: #{@fault}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} fault: #{@fault.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# postnl_ecommerce
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated for PostNL by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
module PostnlEcommerce
|
|
8
|
+
# InvalidRequest class.
|
|
9
|
+
class InvalidRequestException < APIException
|
|
10
|
+
SKIP = Object.new
|
|
11
|
+
private_constant :SKIP
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for this method
|
|
14
|
+
# @return [DateTime]
|
|
15
|
+
attr_accessor :date
|
|
16
|
+
|
|
17
|
+
# TODO: Write general description for this method
|
|
18
|
+
# @return [Error]
|
|
19
|
+
attr_accessor :error
|
|
20
|
+
|
|
21
|
+
# TODO: Write general description for this method
|
|
22
|
+
# @return [String]
|
|
23
|
+
attr_accessor :request_id
|
|
24
|
+
|
|
25
|
+
# The constructor.
|
|
26
|
+
# @param [String] reason The reason for raising an exception.
|
|
27
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
28
|
+
def initialize(reason, response)
|
|
29
|
+
super(reason, response)
|
|
30
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
31
|
+
unbox(hash)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Populates this object by extracting properties from a hash.
|
|
35
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
36
|
+
# response body.
|
|
37
|
+
def unbox(hash)
|
|
38
|
+
return nil unless hash
|
|
39
|
+
|
|
40
|
+
@date = if hash.key?('Date')
|
|
41
|
+
(DateTimeHelper.from_rfc3339(hash['Date']) if hash['Date'])
|
|
42
|
+
else
|
|
43
|
+
SKIP
|
|
44
|
+
end
|
|
45
|
+
@error = Error.from_hash(hash['Error']) if hash['Error']
|
|
46
|
+
@request_id = hash.key?('RequestId') ? hash['RequestId'] : SKIP
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Provides a human-readable string representation of the object.
|
|
50
|
+
def to_s
|
|
51
|
+
class_name = self.class.name.split('::').last
|
|
52
|
+
"<#{class_name} date: #{@date}, error: #{@error}, request_id: #{@request_id}>"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
56
|
+
def inspect
|
|
57
|
+
class_name = self.class.name.split('::').last
|
|
58
|
+
"<#{class_name} date: #{@date.inspect}, error: #{@error.inspect}, request_id:"\
|
|
59
|
+
" #{@request_id.inspect}>"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|