speedy-bg 0.1.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/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +134 -0
- data/CONTRIBUTING.md +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +150 -0
- data/SECURITY.md +29 -0
- data/docs/API.md +740 -0
- data/docs/RESPONSE_CONTRACTS.md +55 -0
- data/docs/VCR.md +161 -0
- data/docs/schema-notes.md +38 -0
- data/lib/speedy/camel_case_middleware.rb +71 -0
- data/lib/speedy/client.rb +100 -0
- data/lib/speedy/client_resources.rb +776 -0
- data/lib/speedy/collection.rb +58 -0
- data/lib/speedy/error.rb +29 -0
- data/lib/speedy/model.rb +92 -0
- data/lib/speedy/models/calculation/address_location.rb +16 -0
- data/lib/speedy/models/calculation/calculation_content.rb +15 -0
- data/lib/speedy/models/calculation/calculation_recipient.rb +15 -0
- data/lib/speedy/models/calculation/calculation_result.rb +19 -0
- data/lib/speedy/models/calculation/calculation_sender.rb +16 -0
- data/lib/speedy/models/calculation/calculation_service.rb +16 -0
- data/lib/speedy/models/clients/client.rb +21 -0
- data/lib/speedy/models/clients/cod_contract_info.rb +16 -0
- data/lib/speedy/models/clients/cod_international_annex.rb +12 -0
- data/lib/speedy/models/clients/contract_info.rb +16 -0
- data/lib/speedy/models/clients/requirement.rb +12 -0
- data/lib/speedy/models/clients/special_delivery_requirements.rb +12 -0
- data/lib/speedy/models/common/address.rb +36 -0
- data/lib/speedy/models/error.rb +37 -0
- data/lib/speedy/models/location/address_nomenclature_type.rb +12 -0
- data/lib/speedy/models/location/block.rb +15 -0
- data/lib/speedy/models/location/complex.rb +23 -0
- data/lib/speedy/models/location/country.rb +25 -0
- data/lib/speedy/models/location/find_office_response.rb +12 -0
- data/lib/speedy/models/location/find_site_response.rb +12 -0
- data/lib/speedy/models/location/get_office_response.rb +12 -0
- data/lib/speedy/models/location/get_site_response.rb +12 -0
- data/lib/speedy/models/location/office.rb +41 -0
- data/lib/speedy/models/location/office_result.rb +13 -0
- data/lib/speedy/models/location/office_working_time_schedule.rb +15 -0
- data/lib/speedy/models/location/point_of_interest.rb +22 -0
- data/lib/speedy/models/location/postcode.rb +12 -0
- data/lib/speedy/models/location/routing_information.rb +14 -0
- data/lib/speedy/models/location/site.rb +30 -0
- data/lib/speedy/models/location/state.rb +17 -0
- data/lib/speedy/models/location/street.rb +23 -0
- data/lib/speedy/models/location/tour.rb +14 -0
- data/lib/speedy/models/payments/payout.rb +20 -0
- data/lib/speedy/models/payments/payout_details.rb +23 -0
- data/lib/speedy/models/pickup/pickup_order.rb +16 -0
- data/lib/speedy/models/pickup/terms_response.rb +12 -0
- data/lib/speedy/models/print/extended_print_response.rb +13 -0
- data/lib/speedy/models/print/label_info.rb +19 -0
- data/lib/speedy/models/print/label_info_response.rb +12 -0
- data/lib/speedy/models/print/parcel_to_print_additional_barcode.rb +14 -0
- data/lib/speedy/models/print/print_response.rb +12 -0
- data/lib/speedy/models/response.rb +13 -0
- data/lib/speedy/models/services/additional_courier_service.rb +11 -0
- data/lib/speedy/models/services/additional_courier_services.rb +21 -0
- data/lib/speedy/models/services/courier_service.rb +19 -0
- data/lib/speedy/models/services/extended_courier_service.rb +13 -0
- data/lib/speedy/models/shipments/bank_account.rb +12 -0
- data/lib/speedy/models/shipments/barcode_information.rb +20 -0
- data/lib/speedy/models/shipments/cod_payment.rb +12 -0
- data/lib/speedy/models/shipments/content.rb +20 -0
- data/lib/speedy/models/shipments/create_shipment_response.rb +16 -0
- data/lib/speedy/models/shipments/created_shipment_parcel.rb +14 -0
- data/lib/speedy/models/shipments/external_carrier_parcel_number.rb +12 -0
- data/lib/speedy/models/shipments/goods_item.rb +16 -0
- data/lib/speedy/models/shipments/money_transfer_premium.rb +13 -0
- data/lib/speedy/models/shipments/parcel.rb +22 -0
- data/lib/speedy/models/shipments/payment.rb +16 -0
- data/lib/speedy/models/shipments/primary_shipment.rb +12 -0
- data/lib/speedy/models/shipments/recipient.rb +21 -0
- data/lib/speedy/models/shipments/return_amounts.rb +11 -0
- data/lib/speedy/models/shipments/secondary_shipment.rb +18 -0
- data/lib/speedy/models/shipments/sender.rb +21 -0
- data/lib/speedy/models/shipments/shipment.rb +28 -0
- data/lib/speedy/models/shipments/shipment_additional_services.rb +17 -0
- data/lib/speedy/models/shipments/shipment_address.rb +10 -0
- data/lib/speedy/models/shipments/shipment_cod_additional_service.rb +20 -0
- data/lib/speedy/models/shipments/shipment_cod_fiscal_receipt_item.rb +14 -0
- data/lib/speedy/models/shipments/shipment_content.rb +24 -0
- data/lib/speedy/models/shipments/shipment_declared_value_additional_service.rb +13 -0
- data/lib/speedy/models/shipments/shipment_delivery.rb +14 -0
- data/lib/speedy/models/shipments/shipment_discount_card_id.rb +12 -0
- data/lib/speedy/models/shipments/shipment_electronic_return_receipt_additional_service.rb +14 -0
- data/lib/speedy/models/shipments/shipment_obpd.rb +13 -0
- data/lib/speedy/models/shipments/shipment_parcel.rb +23 -0
- data/lib/speedy/models/shipments/shipment_parcel_number.rb +12 -0
- data/lib/speedy/models/shipments/shipment_parcel_ref.rb +13 -0
- data/lib/speedy/models/shipments/shipment_parcel_size.rb +13 -0
- data/lib/speedy/models/shipments/shipment_payment.rb +17 -0
- data/lib/speedy/models/shipments/shipment_phone_number.rb +12 -0
- data/lib/speedy/models/shipments/shipment_price.rb +23 -0
- data/lib/speedy/models/shipments/shipment_price_amount.rb +13 -0
- data/lib/speedy/models/shipments/shipment_recipient.rb +14 -0
- data/lib/speedy/models/shipments/shipment_return_additional_services.rb +20 -0
- data/lib/speedy/models/shipments/shipment_return_receipt_additional_service.rb +14 -0
- data/lib/speedy/models/shipments/shipment_return_voucher_additional_service.rb +14 -0
- data/lib/speedy/models/shipments/shipment_rod_additional_service.rb +15 -0
- data/lib/speedy/models/shipments/shipment_rop_additional_service.rb +12 -0
- data/lib/speedy/models/shipments/shipment_rop_additional_service_line.rb +12 -0
- data/lib/speedy/models/shipments/shipment_sender.rb +23 -0
- data/lib/speedy/models/shipments/shipment_service.rb +17 -0
- data/lib/speedy/models/shipments/shipment_swap_additional_service.rb +17 -0
- data/lib/speedy/models/shipments/update_shipment_response.rb +10 -0
- data/lib/speedy/models/tracking/bulk_tracking_data_file.rb +14 -0
- data/lib/speedy/models/tracking/external_carrier_parcel_number_details.rb +13 -0
- data/lib/speedy/models/tracking/tracked_parcel.rb +21 -0
- data/lib/speedy/models/tracking/tracked_parcel_operation.rb +22 -0
- data/lib/speedy/models/tracking/tracked_parcel_operation_additional_info.rb +17 -0
- data/lib/speedy/models/tracking/tracked_parcel_operation_additional_info_predict.rb +14 -0
- data/lib/speedy/models/tracking/tracked_parcel_operation_additional_info_recipient.rb +14 -0
- data/lib/speedy/models/validation/validation_response.rb +14 -0
- data/lib/speedy/resource_attributes.rb +87 -0
- data/lib/speedy/service_resource.rb +94 -0
- data/lib/speedy/services/calculation.rb +22 -0
- data/lib/speedy/services/clients.rb +40 -0
- data/lib/speedy/services/courier_services.rb +25 -0
- data/lib/speedy/services/location/block.rb +32 -0
- data/lib/speedy/services/location/complex.rb +39 -0
- data/lib/speedy/services/location/country.rb +70 -0
- data/lib/speedy/services/location/office.rb +50 -0
- data/lib/speedy/services/location/point_of_interest.rb +39 -0
- data/lib/speedy/services/location/postcode.rb +25 -0
- data/lib/speedy/services/location/site.rb +77 -0
- data/lib/speedy/services/location/state.rb +46 -0
- data/lib/speedy/services/location/street.rb +39 -0
- data/lib/speedy/services/location.rb +11 -0
- data/lib/speedy/services/payments.rb +19 -0
- data/lib/speedy/services/pickup.rb +38 -0
- data/lib/speedy/services/print.rb +58 -0
- data/lib/speedy/services/shipments/shipment.rb +120 -0
- data/lib/speedy/services/shipments.rb +11 -0
- data/lib/speedy/services/tracking.rb +26 -0
- data/lib/speedy/services/validation/address.rb +26 -0
- data/lib/speedy/services/validation/general.rb +37 -0
- data/lib/speedy/services/validation.rb +11 -0
- data/lib/speedy/transport_error.rb +17 -0
- data/lib/speedy/util.rb +67 -0
- data/lib/speedy/version.rb +5 -0
- data/lib/speedy-bg.rb +6 -0
- data/lib/speedy.rb +203 -0
- data/sig/speedy.rbs +374 -0
- metadata +227 -0
|
@@ -0,0 +1,776 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
# The public client facade intentionally keeps endpoint shortcuts in one place.
|
|
5
|
+
# rubocop:disable-next Metrics/ModuleLength
|
|
6
|
+
module ClientResources
|
|
7
|
+
# Calculate available delivery prices without creating a shipment.
|
|
8
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
9
|
+
# @option args [Hash, Speedy::Model] recipient Required. Recipient shipment party.
|
|
10
|
+
# @option args [Hash, Speedy::Model] service Required. Service settings: service_ids for calculation,
|
|
11
|
+
# service_id for creation.
|
|
12
|
+
# @option args [Hash, Speedy::Model] content Required. Parcel count, contents and weight.
|
|
13
|
+
# @option args [Hash, Speedy::Model] payment Required. Payer and payment settings.
|
|
14
|
+
# @option args [Hash, Speedy::Model, nil] sender (nil) Sender party; nil uses account defaults when permitted.
|
|
15
|
+
# @return [Speedy::Collection<Speedy::Models::Calculation::CalculationResult>] Endpoint result.
|
|
16
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
17
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
18
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
19
|
+
# client.calculate_delivery(**quote_attributes)
|
|
20
|
+
def calculate_delivery(**args)
|
|
21
|
+
Speedy::Services::Calculation.new(client: self).calculate(**args)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
alias calculate_delivery_fee calculate_delivery
|
|
25
|
+
|
|
26
|
+
# Create a shipment; retain its identifier for subsequent reads and cleanup.
|
|
27
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
28
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
29
|
+
# @option args [Hash, Speedy::Model] service Required. Service settings: service_ids for calculation,
|
|
30
|
+
# service_id for creation.
|
|
31
|
+
# @option args [Hash, Speedy::Model] content Required. Parcel count, contents and weight.
|
|
32
|
+
# @option args [Hash, Speedy::Model] payment Required. Payer and payment settings.
|
|
33
|
+
# @option args [Hash, Speedy::Model] recipient Required. Recipient shipment party.
|
|
34
|
+
# @option args [Hash, Speedy::Model, nil] sender (nil) Sender party; nil uses account defaults when permitted.
|
|
35
|
+
# @return [Speedy::Models::Shipments::CreateShipmentResponse] Endpoint result.
|
|
36
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
37
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
38
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
39
|
+
# client.create_shipment(**shipment_attributes)
|
|
40
|
+
def create_shipment(**args)
|
|
41
|
+
shipment_service.create(**args)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Retrieve shipment details; accepts individual IDs or an array.
|
|
45
|
+
# @param shipment_ids [Array<String>] Existing shipment IDs; an array may also be passed.
|
|
46
|
+
# @return [Speedy::Collection<Speedy::Models::Shipments::Shipment>] Endpoint result.
|
|
47
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
48
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
49
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
50
|
+
# client.shipment_info(shipment_id)
|
|
51
|
+
def shipment_info(*shipment_ids)
|
|
52
|
+
shipment_service.info(shipment_ids.flatten)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Replace/update full shipment data using fields accepted by the shipment update endpoint.
|
|
56
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
57
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
58
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
59
|
+
# @return [Speedy::Models::Shipments::UpdateShipmentResponse] Endpoint result.
|
|
60
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
61
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
62
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
63
|
+
# client.update_shipment(id: shipment_id, **shipment_attributes)
|
|
64
|
+
def update_shipment(id:, **args)
|
|
65
|
+
shipment_service.update(id: id, **args)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Update selected shipment properties; keywords are nested inside properties automatically.
|
|
69
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
70
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
71
|
+
# @param properties [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
72
|
+
# @return [Speedy::Models::Shipments::UpdateShipmentResponse] Endpoint result.
|
|
73
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
74
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
75
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
76
|
+
# client.update_shipment_properties(id: shipment_id, contents: "Artwork")
|
|
77
|
+
def update_shipment_properties(id:, **properties)
|
|
78
|
+
shipment_service.update_properties(id: id, **properties)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Cancel an eligible shipment; inspect success? and error before treating cleanup as complete.
|
|
82
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
83
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
84
|
+
# @param comment [String, nil] Cancellation comment.
|
|
85
|
+
# @return [Speedy::Models::Response] Endpoint result.
|
|
86
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
87
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
88
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
89
|
+
# client.cancel_shipment(id: shipment_id, comment: "Synthetic test cleanup")
|
|
90
|
+
def cancel_shipment(id:, comment: nil)
|
|
91
|
+
shipment_service.cancel(id: id, comment: comment)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Finalize a shipment that is awaiting parcel completion; requires applicable account permissions.
|
|
95
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
96
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
97
|
+
# @return [Speedy::Models::Shipments::CreateShipmentResponse] Endpoint result.
|
|
98
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
99
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
100
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
101
|
+
# client.finalize_shipment(id: shipment_id)
|
|
102
|
+
def finalize_shipment(id:)
|
|
103
|
+
shipment_service.finalize(id: id)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Add a parcel to an eligible pending shipment; standard demo accounts may lack permission.
|
|
107
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
108
|
+
# @param shipment_id [String] Existing shipment identifier.
|
|
109
|
+
# @param parcel [Hash] Parcel reference or attributes appropriate to this endpoint.
|
|
110
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
111
|
+
# @option args [Object] declared_value_amount (nil) API declared value amount option.
|
|
112
|
+
# @option args [Object] cod_amount (nil) API cod amount option.
|
|
113
|
+
# @option args [Object] cod_fiscal_receipt_items (nil) API cod fiscal receipt items option.
|
|
114
|
+
# @return [Speedy::Models::Shipments::CreatedShipmentParcel] Endpoint result.
|
|
115
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
116
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
117
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
118
|
+
# client.add_shipment_parcel(shipment_id: shipment_id, parcel: { weight: 0.1 })
|
|
119
|
+
def add_shipment_parcel(shipment_id:, parcel:, **args)
|
|
120
|
+
shipment_service.add_parcel(shipment_id: shipment_id, parcel: parcel, **args)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# List secondary shipments associated with a shipment.
|
|
124
|
+
# @param shipment_id [String] Existing shipment identifier.
|
|
125
|
+
# @param types [Array<String>, nil] Secondary shipment type filters.
|
|
126
|
+
# @return [Speedy::Collection<Speedy::Models::Shipments::SecondaryShipment>] Endpoint result.
|
|
127
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
128
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
129
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
130
|
+
# client.secondary_shipments(shipment_id: shipment_id)
|
|
131
|
+
def secondary_shipments(shipment_id:, types: nil)
|
|
132
|
+
shipment_service.secondary(shipment_id: shipment_id, types: types)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Find barcode strings by a shipment reference; search_in_ref selects reference fields.
|
|
136
|
+
# @param ref [String] Reference search value.
|
|
137
|
+
# @param search_in_ref [Integer] API reference-field selector.
|
|
138
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
139
|
+
# @option args [Object] shipments_only (nil) API shipments only option.
|
|
140
|
+
# @option args [Object] include_returns (nil) API include returns option.
|
|
141
|
+
# @option args [Object] from_date_time (nil) API from date time option.
|
|
142
|
+
# @option args [Object] to_date_time (nil) API to date time option.
|
|
143
|
+
# @return [Array<String>] Endpoint result.
|
|
144
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
145
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
146
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
147
|
+
# client.find_parcels_by_reference(ref: "order-123", search_in_ref: 1)
|
|
148
|
+
def find_parcels_by_reference(ref:, search_in_ref:, **args)
|
|
149
|
+
shipment_service.find_by_reference(ref: ref, search_in_ref: search_in_ref, **args)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Register parcel handover to a courier; not a dry-run operation.
|
|
153
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
154
|
+
# @param parcels [Array<Hash>] Parcel references in the endpoint-specific shape.
|
|
155
|
+
# @return [Speedy::Models::Response] Endpoint result.
|
|
156
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
157
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
158
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
159
|
+
# client.hand_over_to_courier(parcels: [{ id: parcel_id }])
|
|
160
|
+
def hand_over_to_courier(parcels:)
|
|
161
|
+
shipment_service.hand_over_to_courier(parcels: parcels)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Register parcel handover to a midway carrier.
|
|
165
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
166
|
+
# @param parcels [Array<Hash>] Parcel references in the endpoint-specific shape.
|
|
167
|
+
# @return [Speedy::Models::Response] Endpoint result.
|
|
168
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
169
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
170
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
171
|
+
# client.hand_over_to_midway_carrier(parcels: [{ id: parcel_id }])
|
|
172
|
+
def hand_over_to_midway_carrier(parcels:)
|
|
173
|
+
shipment_service.hand_over_to_midway_carrier(parcels: parcels)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Retrieve barcode information for a parcel reference.
|
|
177
|
+
# @param parcel [Hash] Parcel reference or attributes appropriate to this endpoint.
|
|
178
|
+
# @return [Speedy::Models::Shipments::BarcodeInformation] Endpoint result.
|
|
179
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
180
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
181
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
182
|
+
# client.barcode_information(parcel: { id: parcel_id })
|
|
183
|
+
def barcode_information(parcel:)
|
|
184
|
+
shipment_service.barcode_information(parcel: parcel)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Retrieve parcel tracking operations; true requests only the latest operation.
|
|
188
|
+
# @param parcels [Array<Hash>] Parcel references in the endpoint-specific shape.
|
|
189
|
+
# @param last_operation_only [Boolean, nil] True requests only the latest operation.
|
|
190
|
+
# @return [Speedy::Collection<Speedy::Models::Tracking::TrackedParcel>] Endpoint result.
|
|
191
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
192
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
193
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
194
|
+
# client.track_shipments(parcels: [{ id: parcel_id }], last_operation_only: true)
|
|
195
|
+
def track_shipments(parcels:, last_operation_only: nil)
|
|
196
|
+
Speedy::Services::Tracking.new(client: self).track(
|
|
197
|
+
parcels: parcels, last_operation_only: last_operation_only
|
|
198
|
+
)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# List available tracking files after a cursor; URLs are returned, not downloaded.
|
|
202
|
+
# @param last_processed_file_id [Integer] Tracking-file cursor.
|
|
203
|
+
# @return [Speedy::Collection<Speedy::Models::Tracking::BulkTrackingDataFile>] Endpoint result.
|
|
204
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
205
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
206
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
207
|
+
# client.bulk_tracking_files(last_processed_file_id: 0)
|
|
208
|
+
def bulk_tracking_files(last_processed_file_id:)
|
|
209
|
+
Speedy::Services::Tracking.new(client: self).bulk_files(
|
|
210
|
+
last_processed_file_id: last_processed_file_id
|
|
211
|
+
)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# List courier services, optionally for an ISO date.
|
|
215
|
+
# @param date [String, nil] ISO calendar date; nil uses the server default.
|
|
216
|
+
# @return [Speedy::Collection<Speedy::Models::Services::CourierService>] Endpoint result.
|
|
217
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
218
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
219
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
220
|
+
# client.courier_services
|
|
221
|
+
def courier_services(date: nil)
|
|
222
|
+
Speedy::Services::CourierServices.new(client: self).all(date: date)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# List services available for the supplied shipment parties.
|
|
226
|
+
# @param sender [Hash, Speedy::Model, nil] Sender party; nil uses account defaults when permitted.
|
|
227
|
+
# @param recipient [Hash, Speedy::Model] Recipient shipment party.
|
|
228
|
+
# @param date [String, nil] ISO calendar date; nil uses the server default.
|
|
229
|
+
# @return [Speedy::Collection<Speedy::Models::Services::ExtendedCourierService>] Endpoint result.
|
|
230
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
231
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
232
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
233
|
+
# client.destination_services(sender: sender, recipient: recipient)
|
|
234
|
+
def destination_services(sender:, recipient:, date: nil)
|
|
235
|
+
Speedy::Services::CourierServices.new(client: self).for_destination(
|
|
236
|
+
sender: sender, recipient: recipient, date: date
|
|
237
|
+
)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Request a courier visit; auto_adjust_pickup_date allows server adjustment when supported.
|
|
241
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
242
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
243
|
+
# @option args [String] pickup_date_time Required. Desired pickup datetime.
|
|
244
|
+
# @option args [Object] pickup_scope (nil) API pickup scope option.
|
|
245
|
+
# @option args [Array<String>, nil] explicit_shipment_id_list (nil) Shipment IDs included in the pickup.
|
|
246
|
+
# @option args [Object] visit_end_time (nil) API visit end time option.
|
|
247
|
+
# @option args [Object] contact_name (nil) API contact name option.
|
|
248
|
+
# @option args [Object] phone_number (nil) API phone number option.
|
|
249
|
+
# @option args [Boolean, nil] auto_adjust_pickup_date (nil) Allow server adjustment of the pickup day.
|
|
250
|
+
# @return [Speedy::Collection<Speedy::Models::Pickup::PickupOrder>] Endpoint result.
|
|
251
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
252
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
253
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
254
|
+
# client.request_pickup(pickup_date_time: pickup_date_time, explicit_shipment_id_list: [shipment_id])
|
|
255
|
+
def request_pickup(**args)
|
|
256
|
+
Speedy::Services::Pickup.new(client: self).create(**args)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Retrieve available pickup terms for a service and sender.
|
|
260
|
+
# @param service_id [Integer] Courier service identifier.
|
|
261
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
262
|
+
# @option args [Object] starting_date (nil) API starting date option.
|
|
263
|
+
# @option args [Hash, Speedy::Model, nil] sender (nil) Sender party; nil uses account defaults when permitted.
|
|
264
|
+
# @option args [Object] sender_has_payment (nil) API sender has payment option.
|
|
265
|
+
# @return [Speedy::Models::Pickup::TermsResponse] Endpoint result.
|
|
266
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
267
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
268
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
269
|
+
# client.pickup_terms(service_id: 505)
|
|
270
|
+
def pickup_terms(service_id:, **args)
|
|
271
|
+
Speedy::Services::Pickup.new(client: self).terms(service_id: service_id, **args)
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Get extended labels with encoded document data and label metadata.
|
|
275
|
+
# @note printer_name may trigger physical printing; omit it to download only.
|
|
276
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
277
|
+
# @option args [Array<Hash>] parcels Required. Parcel references in the endpoint-specific shape.
|
|
278
|
+
# @option args [String, nil] format (nil) Document format, e.g. pdf or zpl.
|
|
279
|
+
# @option args [String, nil] paper_size (nil) Paper format, e.g. A4 or A6.
|
|
280
|
+
# @option args [String, nil] printer_name (nil) Optional physical printer; omit for download-only use.
|
|
281
|
+
# @option args [Integer, nil] dpi (nil) Print resolution.
|
|
282
|
+
# @option args [Object] additional_waybill_sender_copy (nil) API additional waybill sender copy option.
|
|
283
|
+
# @return [Speedy::Models::Print::ExtendedPrintResponse] Endpoint result.
|
|
284
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
285
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
286
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
287
|
+
# client.print_labels(parcels: [{ parcel: { id: parcel_id } }], format: "pdf")
|
|
288
|
+
def print_labels(**args)
|
|
289
|
+
Speedy::Services::Print.new(client: self).create_pdf_extended(**args)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Get raw label document bytes; despite its name, format may request ZPL.
|
|
293
|
+
# @note printer_name may trigger physical printing; omit it to download only.
|
|
294
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
295
|
+
# @option args [Array<Hash>] parcels Required. Parcel references in the endpoint-specific shape.
|
|
296
|
+
# @option args [String, nil] format (nil) Document format, e.g. pdf or zpl.
|
|
297
|
+
# @option args [String, nil] paper_size (nil) Paper format, e.g. A4 or A6.
|
|
298
|
+
# @option args [String, nil] printer_name (nil) Optional physical printer; omit for download-only use.
|
|
299
|
+
# @option args [Integer, nil] dpi (nil) Print resolution.
|
|
300
|
+
# @option args [Object] additional_waybill_sender_copy (nil) API additional waybill sender copy option.
|
|
301
|
+
# @return [String] Endpoint result.
|
|
302
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
303
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
304
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
305
|
+
# client.print_labels_pdf(parcels: [{ parcel: { id: parcel_id } }], format: "pdf")
|
|
306
|
+
def print_labels_pdf(**args)
|
|
307
|
+
Speedy::Services::Print.new(client: self).create_pdf(**args).body
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Retrieve label metadata; prefer an explicit parcels array.
|
|
311
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
312
|
+
# @option args [Hash, Array<Hash>, nil] parcel (nil) Single parcel reference or an array of references.
|
|
313
|
+
# @option args [Array<Hash>] parcels (nil) Parcel references in the endpoint-specific shape.
|
|
314
|
+
# @return [Speedy::Models::Print::LabelInfoResponse] Endpoint result.
|
|
315
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
316
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
317
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
318
|
+
# client.label_info(parcels: [{ id: parcel_id }])
|
|
319
|
+
def label_info(**args)
|
|
320
|
+
Speedy::Services::Print.new(client: self).label_info(**args)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Get raw voucher PDF/ZPL bytes for shipment IDs.
|
|
324
|
+
# @note printer_name may trigger physical printing; omit it to download only.
|
|
325
|
+
# @param shipment_ids [Array<String>] Existing shipment IDs; an array may also be passed.
|
|
326
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
327
|
+
# @option args [String, nil] printer_name (nil) Optional physical printer; omit for download-only use.
|
|
328
|
+
# @option args [String, nil] format (nil) Document format, e.g. pdf or zpl.
|
|
329
|
+
# @option args [Integer, nil] dpi (nil) Print resolution.
|
|
330
|
+
# @return [String] Endpoint result.
|
|
331
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
332
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
333
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
334
|
+
# client.print_voucher(shipment_ids: [shipment_id], format: "pdf")
|
|
335
|
+
def print_voucher(shipment_ids:, **args)
|
|
336
|
+
Speedy::Services::Print.new(client: self).voucher(shipment_ids: shipment_ids, **args)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# Retrieve the authenticated client identifier.
|
|
340
|
+
# @return [Integer, nil] Endpoint result.
|
|
341
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
342
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
343
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
344
|
+
# client.own_client_id
|
|
345
|
+
def own_client_id
|
|
346
|
+
Speedy::Services::Clients.new(client: self).own_id
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# Retrieve a client by identifier.
|
|
350
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
351
|
+
# @return [Speedy::Models::Clients::Client] Endpoint result.
|
|
352
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
353
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
354
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
355
|
+
# client.get_client(client_id)
|
|
356
|
+
def get_client(id)
|
|
357
|
+
Speedy::Services::Clients.new(client: self).get(id)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# List clients available under the authenticated contract.
|
|
361
|
+
# @return [Speedy::Collection<Speedy::Models::Clients::Client>] Endpoint result.
|
|
362
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
363
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
364
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
365
|
+
# client.contract_clients
|
|
366
|
+
def contract_clients
|
|
367
|
+
Speedy::Services::Clients.new(client: self).contract_clients
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# Create a contact; forwards compacted contact attributes accepted by the API.
|
|
371
|
+
# @note Mutates remote state. See docs/VCR.md for cleanup limitations.
|
|
372
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
373
|
+
# @return [Integer, nil] Endpoint result.
|
|
374
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
375
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
376
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
377
|
+
# client.create_contact(client_name: "Synthetic Contact", private_person: true, phone1: { number:
|
|
378
|
+
# "+359888000000" }, address: address)
|
|
379
|
+
def create_contact(**args)
|
|
380
|
+
Speedy::Services::Clients.new(client: self).create_contact(**args)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
# Retrieve a contact using its external ID and secret; do not log the secret.
|
|
384
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
385
|
+
# @param secret_key [String] External contact secret; do not log it.
|
|
386
|
+
# @return [Speedy::Models::Clients::Client] Endpoint result.
|
|
387
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
388
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
389
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
390
|
+
# client.contact_by_external_id(id: external_contact_id, secret_key: external_contact_secret)
|
|
391
|
+
def contact_by_external_id(id:, secret_key:)
|
|
392
|
+
Speedy::Services::Clients.new(client: self).contact_by_external_id(id: id, secret_key: secret_key)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Retrieve contract information for the authenticated account.
|
|
396
|
+
# @return [Speedy::Models::Clients::ContractInfo] Endpoint result.
|
|
397
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
398
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
399
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
400
|
+
# client.contract_info
|
|
401
|
+
def contract_info
|
|
402
|
+
Speedy::Services::Clients.new(client: self).contract_info
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# Retrieve payouts within an ISO-date interval; dates are cast to Ruby Date values where supported.
|
|
406
|
+
# @param from_date [String] ISO starting date.
|
|
407
|
+
# @param to_date [String] ISO ending date.
|
|
408
|
+
# @param include_details [Boolean, nil] Include individual payout details.
|
|
409
|
+
# @return [Speedy::Collection<Speedy::Models::Payments::Payout>] Endpoint result.
|
|
410
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
411
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
412
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
413
|
+
# client.payouts(from_date: "2026-10-01", to_date: "2026-10-10", include_details: true)
|
|
414
|
+
def payouts(from_date:, to_date:, include_details: nil)
|
|
415
|
+
Speedy::Services::Payments.new(client: self).payouts(
|
|
416
|
+
from_date: from_date, to_date: to_date, include_details: include_details
|
|
417
|
+
)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Search cities/localities with optional filters.
|
|
421
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
422
|
+
# @option args [Integer, nil] country_id (nil) Country nomenclature identifier.
|
|
423
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
424
|
+
# @option args [String, nil] post_code (nil) Postal code.
|
|
425
|
+
# @option args [Object] type (nil) API type option.
|
|
426
|
+
# @option args [Object] municipality (nil) API municipality option.
|
|
427
|
+
# @option args [Object] region (nil) API region option.
|
|
428
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Site>] Endpoint result.
|
|
429
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
430
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
431
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
432
|
+
# client.find_sites(country_id: 100, name: "София")
|
|
433
|
+
def find_sites(**args)
|
|
434
|
+
Speedy::Services::Location::Site.new(client: self).find(**args)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
# Get a site response envelope; the site is available through result.site.
|
|
438
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
439
|
+
# @return [Speedy::Models::Location::GetSiteResponse] Endpoint result.
|
|
440
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
441
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
442
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
443
|
+
# client.get_site(site_id)
|
|
444
|
+
def get_site(id)
|
|
445
|
+
Speedy::Services::Location::Site.new(client: self).get(id)
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
# Retrieve a state by its identifier.
|
|
449
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
450
|
+
# @return [Speedy::Models::Location::State] Endpoint result.
|
|
451
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
452
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
453
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
454
|
+
# client.get_state(state_id)
|
|
455
|
+
def get_state(id)
|
|
456
|
+
Speedy::Services::Location::State.new(client: self).get(id)
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
# Search states with optional country and name filters.
|
|
460
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
461
|
+
# @option args [Integer, nil] country_id (nil) Country nomenclature identifier.
|
|
462
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
463
|
+
# @return [Speedy::Collection<Speedy::Models::Location::State>] Endpoint result.
|
|
464
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
465
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
466
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
467
|
+
# client.find_states(country_id: country_id)
|
|
468
|
+
def find_states(**args)
|
|
469
|
+
Speedy::Services::Location::State.new(client: self).find(**args)
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
# Download and parse the state CSV dataset for a country.
|
|
473
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
474
|
+
# @option args [Integer, nil] country_id Required. Country nomenclature identifier.
|
|
475
|
+
# @return [Speedy::Collection<Speedy::Models::Location::State>] Endpoint result.
|
|
476
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
477
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
478
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
479
|
+
# client.all_states(country_id: country_id)
|
|
480
|
+
def all_states(**args)
|
|
481
|
+
Speedy::Services::Location::State.new(client: self).all(**args)
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
# Download and parse the country CSV dataset.
|
|
485
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Country>] Endpoint result.
|
|
486
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
487
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
488
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
489
|
+
# client.all_countries
|
|
490
|
+
def all_countries
|
|
491
|
+
Speedy::Services::Location::Country.new(client: self).all
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
# Download and parse the sites CSV dataset for a country.
|
|
495
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
496
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Site>] Endpoint result.
|
|
497
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
498
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
499
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
500
|
+
# client.all_sites(country_id: 100)
|
|
501
|
+
def all_sites(country_id:)
|
|
502
|
+
Speedy::Services::Location::Site.new(client: self).all(country_id: country_id)
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
# Download and parse the streets CSV dataset for a country.
|
|
506
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
507
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Street>] Endpoint result.
|
|
508
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
509
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
510
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
511
|
+
# client.all_streets(country_id: 100)
|
|
512
|
+
def all_streets(country_id:)
|
|
513
|
+
Speedy::Services::Location::Street.new(client: self).all(country_id: country_id)
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
# Download and parse the complexes CSV dataset for a country.
|
|
517
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
518
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Complex>] Endpoint result.
|
|
519
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
520
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
521
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
522
|
+
# client.all_complexes(country_id: 100)
|
|
523
|
+
def all_complexes(country_id:)
|
|
524
|
+
Speedy::Services::Location::Complex.new(client: self).all(country_id: country_id)
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
# Download and parse the blocks CSV dataset for a country.
|
|
528
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
529
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Block>] Endpoint result.
|
|
530
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
531
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
532
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
533
|
+
# client.all_blocks(country_id: 100)
|
|
534
|
+
def all_blocks(country_id:)
|
|
535
|
+
Speedy::Services::Location::Block.new(client: self).all(country_id: country_id)
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
# Download and parse the points of interest CSV dataset for a country.
|
|
539
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
540
|
+
# @return [Speedy::Collection<Speedy::Models::Location::PointOfInterest>] Endpoint result.
|
|
541
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
542
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
543
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
544
|
+
# client.all_points_of_interest(country_id: 100)
|
|
545
|
+
def all_points_of_interest(country_id:)
|
|
546
|
+
Speedy::Services::Location::PointOfInterest.new(client: self).all(country_id: country_id)
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
# Download and parse the postcodes CSV dataset for a country.
|
|
550
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
551
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Postcode>] Endpoint result.
|
|
552
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
553
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
554
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
555
|
+
# client.all_postcodes(country_id: 100)
|
|
556
|
+
def all_postcodes(country_id:)
|
|
557
|
+
Speedy::Services::Location::Postcode.new(client: self).all(country_id: country_id)
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
# Search countries by name or ISO code.
|
|
561
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
562
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
563
|
+
# @option args [Object] iso_alpha2 (nil) API iso alpha2 option.
|
|
564
|
+
# @option args [Object] iso_alpha3 (nil) API iso alpha3 option.
|
|
565
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Country>] Endpoint result.
|
|
566
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
567
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
568
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
569
|
+
# client.find_countries(iso_alpha2: "BG")
|
|
570
|
+
def find_countries(**args)
|
|
571
|
+
Speedy::Services::Location::Country.new(client: self).find(**args)
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
# Retrieve a country by identifier.
|
|
575
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
576
|
+
# @return [Speedy::Models::Location::Country] Endpoint result.
|
|
577
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
578
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
579
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
580
|
+
# client.get_country(100)
|
|
581
|
+
def get_country(id)
|
|
582
|
+
Speedy::Services::Location::Country.new(client: self).get(id)
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
# Search streets within a site.
|
|
586
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
587
|
+
# @option args [Integer, nil] site_id Required. Locality nomenclature identifier.
|
|
588
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
589
|
+
# @option args [Object] type (nil) API type option.
|
|
590
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Street>] Endpoint result.
|
|
591
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
592
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
593
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
594
|
+
# client.find_streets(site_id: site_id, name: "Витоша")
|
|
595
|
+
def find_streets(**args)
|
|
596
|
+
Speedy::Services::Location::Street.new(client: self).find(**args)
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
# Retrieve a street by identifier.
|
|
600
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
601
|
+
# @return [Speedy::Models::Location::Street] Endpoint result.
|
|
602
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
603
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
604
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
605
|
+
# client.get_street(street_id)
|
|
606
|
+
def get_street(id)
|
|
607
|
+
Speedy::Services::Location::Street.new(client: self).get(id)
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
# Search complexes within a site.
|
|
611
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
612
|
+
# @option args [Integer, nil] site_id Required. Locality nomenclature identifier.
|
|
613
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
614
|
+
# @option args [Object] type (nil) API type option.
|
|
615
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Complex>] Endpoint result.
|
|
616
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
617
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
618
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
619
|
+
# client.find_complexes(site_id: site_id, name: "Витоша")
|
|
620
|
+
def find_complexes(**args)
|
|
621
|
+
Speedy::Services::Location::Complex.new(client: self).find(**args)
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
# Retrieve a complex by identifier.
|
|
625
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
626
|
+
# @return [Speedy::Models::Location::Complex] Endpoint result.
|
|
627
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
628
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
629
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
630
|
+
# client.get_complex(complex_id)
|
|
631
|
+
def get_complex(id)
|
|
632
|
+
Speedy::Services::Location::Complex.new(client: self).get(id)
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
# Search block/building numbers within a site.
|
|
636
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
637
|
+
# @option args [Integer, nil] site_id Required. Locality nomenclature identifier.
|
|
638
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
639
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Block>] Endpoint result.
|
|
640
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
641
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
642
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
643
|
+
# client.find_blocks(site_id: site_id, name: "1")
|
|
644
|
+
def find_blocks(**args)
|
|
645
|
+
Speedy::Services::Location::Block.new(client: self).find(**args)
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
# Search points of interest within a site.
|
|
649
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
650
|
+
# @option args [Integer, nil] site_id Required. Locality nomenclature identifier.
|
|
651
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
652
|
+
# @return [Speedy::Collection<Speedy::Models::Location::PointOfInterest>] Endpoint result.
|
|
653
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
654
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
655
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
656
|
+
# client.find_points_of_interest(site_id: site_id)
|
|
657
|
+
def find_points_of_interest(**args)
|
|
658
|
+
Speedy::Services::Location::PointOfInterest.new(client: self).find(**args)
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
# Retrieve a point of interest by identifier.
|
|
662
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
663
|
+
# @return [Speedy::Models::Location::PointOfInterest] Endpoint result.
|
|
664
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
665
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
666
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
667
|
+
# client.get_point_of_interest(point_of_interest_id)
|
|
668
|
+
def get_point_of_interest(id)
|
|
669
|
+
Speedy::Services::Location::PointOfInterest.new(client: self).get(id)
|
|
670
|
+
end
|
|
671
|
+
|
|
672
|
+
# Search offices and lockers with optional locality/name filters.
|
|
673
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
674
|
+
# @option args [Integer, nil] country_id (nil) Country nomenclature identifier.
|
|
675
|
+
# @option args [Integer, nil] site_id (nil) Locality nomenclature identifier.
|
|
676
|
+
# @option args [Object] site_name (nil) API site name option.
|
|
677
|
+
# @option args [String, nil] name (nil) Name filter.
|
|
678
|
+
# @option args [Integer, nil] limit (nil) Maximum result count.
|
|
679
|
+
# @return [Speedy::Collection<Speedy::Models::Location::Office>] Endpoint result.
|
|
680
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
681
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
682
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
683
|
+
# client.find_offices(site_id: site_id, limit: 10)
|
|
684
|
+
def find_offices(**args)
|
|
685
|
+
Speedy::Services::Location::Office.new(client: self).find(**args)
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
# Retrieve an office response envelope; the office is available through result.office.
|
|
689
|
+
# @param id [Integer, String] Existing resource identifier.
|
|
690
|
+
# @return [Speedy::Models::Location::GetOfficeResponse] Endpoint result.
|
|
691
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
692
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
693
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
694
|
+
# client.get_office(office_id)
|
|
695
|
+
def get_office(id)
|
|
696
|
+
Speedy::Services::Location::Office.new(client: self).get(id)
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
# Find offices near an address; items contain office and distance metadata.
|
|
700
|
+
# @param address [Hash, Speedy::Models::Shipments::ShipmentAddress] Shipment address.
|
|
701
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
702
|
+
# @option args [Numeric, nil] distance (nil) Search distance in API-defined units.
|
|
703
|
+
# @option args [Integer, nil] limit (nil) Maximum result count.
|
|
704
|
+
# @option args [Object] office_type (nil) API office type option.
|
|
705
|
+
# @option args [Object] office_features (nil) API office features option.
|
|
706
|
+
# @return [Speedy::Collection<Speedy::Models::Location::OfficeResult>] Endpoint result.
|
|
707
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
708
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
709
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
710
|
+
# client.nearest_offices(address: address, limit: 5)
|
|
711
|
+
def nearest_offices(address:, **args)
|
|
712
|
+
Speedy::Services::Location::Office.new(client: self).nearest(address: address, **args)
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
# Validate a shipment address supplied as a hash or ShipmentAddress model.
|
|
716
|
+
# @param address [Hash, Speedy::Models::Shipments::ShipmentAddress] Shipment address.
|
|
717
|
+
# @return [Speedy::Models::Validation::ValidationResponse] Endpoint result.
|
|
718
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
719
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
720
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
721
|
+
# client.validate_address(address)
|
|
722
|
+
def validate_address(address)
|
|
723
|
+
Speedy::Services::Validation::Address.new(client: self).validate_address(address)
|
|
724
|
+
end
|
|
725
|
+
|
|
726
|
+
# Validate a phone number, optionally including an extension.
|
|
727
|
+
# @param number [String] Phone number.
|
|
728
|
+
# @param extension [String, nil] Phone extension.
|
|
729
|
+
# @return [Speedy::Models::Validation::ValidationResponse] Endpoint result.
|
|
730
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
731
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
732
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
733
|
+
# client.validate_phone(number: "+359888000000")
|
|
734
|
+
def validate_phone(number:, extension: nil)
|
|
735
|
+
Speedy::Services::Validation::General.new(client: self).phone(number: number, extension: extension)
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
# Validate a postcode against a country and optional site.
|
|
739
|
+
# @param country_id [Integer, nil] Country nomenclature identifier.
|
|
740
|
+
# @param post_code [String, nil] Postal code.
|
|
741
|
+
# @param site_id [Integer, nil] Locality nomenclature identifier.
|
|
742
|
+
# @return [Speedy::Models::Validation::ValidationResponse] Endpoint result.
|
|
743
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
744
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
745
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
746
|
+
# client.validate_post_code(country_id: 100, post_code: "1000")
|
|
747
|
+
def validate_post_code(country_id:, post_code:, site_id: nil)
|
|
748
|
+
Speedy::Services::Validation::General.new(client: self).post_code(
|
|
749
|
+
country_id: country_id, post_code: post_code, site_id: site_id
|
|
750
|
+
)
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
# Validate shipment attributes without creating a shipment.
|
|
754
|
+
# @param args [Hash] Endpoint keywords in snake_case; see docs/API.md for the expanded signature.
|
|
755
|
+
# @option args [Hash, Speedy::Model] service Required. Service settings: service_ids for calculation,
|
|
756
|
+
# service_id for creation.
|
|
757
|
+
# @option args [Hash, Speedy::Model] content Required. Parcel count, contents and weight.
|
|
758
|
+
# @option args [Hash, Speedy::Model] payment Required. Payer and payment settings.
|
|
759
|
+
# @option args [Hash, Speedy::Model] recipient Required. Recipient shipment party.
|
|
760
|
+
# @option args [Hash, Speedy::Model, nil] sender (nil) Sender party; nil uses account defaults when permitted.
|
|
761
|
+
# @return [Speedy::Models::Validation::ValidationResponse] Endpoint result.
|
|
762
|
+
# @raise [Speedy::Error] Unsuccessful HTTP response.
|
|
763
|
+
# @raise [Speedy::TransportError] Connection, timeout or TLS failure; preserves the original cause.
|
|
764
|
+
# @example After configuring the client and supplying account-specific fixtures
|
|
765
|
+
# client.validate_shipment(**shipment_attributes)
|
|
766
|
+
def validate_shipment(**args)
|
|
767
|
+
Speedy::Services::Validation::General.new(client: self).shipment(**args)
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
private
|
|
771
|
+
|
|
772
|
+
def shipment_service
|
|
773
|
+
Speedy::Services::Shipments::Shipment.new(client: self)
|
|
774
|
+
end
|
|
775
|
+
end
|
|
776
|
+
end
|