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,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
class Collection
|
|
5
|
+
include Enumerable
|
|
6
|
+
|
|
7
|
+
def initialize(source, model:, key:)
|
|
8
|
+
@model = model
|
|
9
|
+
@key = key
|
|
10
|
+
@error = Speedy::Models::Error.build_from(source)
|
|
11
|
+
@items = build_items(source)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_reader :error
|
|
15
|
+
|
|
16
|
+
def error?
|
|
17
|
+
!error.nil?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def each(&)
|
|
21
|
+
@items.each(&)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_a
|
|
25
|
+
@items
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def size
|
|
29
|
+
@items.size
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def empty?
|
|
33
|
+
@items.empty?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
alias length size
|
|
37
|
+
alias count size
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def build_items(source)
|
|
42
|
+
extract_raw_items(source).map do |item|
|
|
43
|
+
item.is_a?(@model) ? item : @model.new(item)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def extract_raw_items(source)
|
|
48
|
+
case source
|
|
49
|
+
when Hash
|
|
50
|
+
source[@key] || source[@key.to_s] || []
|
|
51
|
+
when Array
|
|
52
|
+
source
|
|
53
|
+
else
|
|
54
|
+
[]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/speedy/error.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
class Error < StandardError
|
|
5
|
+
attr_reader :error, :status
|
|
6
|
+
|
|
7
|
+
def initialize(message = nil, error: nil, status: nil)
|
|
8
|
+
@error = error
|
|
9
|
+
@status = status
|
|
10
|
+
|
|
11
|
+
super(message || error_message || status_message || self.class.name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def error_message
|
|
17
|
+
return unless error.respond_to?(:full_message)
|
|
18
|
+
|
|
19
|
+
message = error.full_message
|
|
20
|
+
message unless message.to_s.strip.empty?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def status_message
|
|
24
|
+
return if status.nil?
|
|
25
|
+
|
|
26
|
+
"Speedy API request failed with status #{status}."
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/speedy/model.rb
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
class Model
|
|
5
|
+
include Speedy::ResourceAttributes
|
|
6
|
+
include Speedy::Util
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def collection_key(value = nil)
|
|
10
|
+
return @collection_key || Speedy::Util.pluralize(name).to_sym unless value
|
|
11
|
+
|
|
12
|
+
@collection_key = value
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def collection(source)
|
|
16
|
+
Speedy::Collection.new(source, model: self, key: collection_key)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def build(source, key: nil)
|
|
20
|
+
data = extract_source(source, key)
|
|
21
|
+
new(data.is_a?(Hash) ? data : {})
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def extract_source(source, key)
|
|
27
|
+
return source unless source.is_a?(Hash)
|
|
28
|
+
return source unless key && (source.key?(key) || source.key?(key.to_s))
|
|
29
|
+
|
|
30
|
+
source[key] || source[key.to_s]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def initialize(attributes = {})
|
|
35
|
+
@attributes = {}
|
|
36
|
+
@error = Speedy::Models::Error.build_from(attributes) unless is_a?(Speedy::Models::Error)
|
|
37
|
+
apply_attributes(attributes)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
attr_reader :error
|
|
41
|
+
|
|
42
|
+
def error?
|
|
43
|
+
!error.nil?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def method_missing(method_name, *args, &)
|
|
47
|
+
if @attributes.key?(method_name)
|
|
48
|
+
@attributes[method_name]
|
|
49
|
+
else
|
|
50
|
+
super
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
55
|
+
@attributes.key?(method_name) || super
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def to_h
|
|
59
|
+
deep_to_h(@attributes)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def to_json(*)
|
|
63
|
+
camelize_keys(to_h).to_json(*)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def apply_attributes(new_attributes)
|
|
67
|
+
underscore_keys(new_attributes).each do |key, value|
|
|
68
|
+
setter = "#{key}="
|
|
69
|
+
if respond_to?(setter)
|
|
70
|
+
send(setter, value)
|
|
71
|
+
else
|
|
72
|
+
@attributes[key.to_sym] = value
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
def deep_to_h(value)
|
|
80
|
+
case value
|
|
81
|
+
when Speedy::Model
|
|
82
|
+
value.to_h
|
|
83
|
+
when Hash
|
|
84
|
+
value.transform_values { |item| deep_to_h(item) }
|
|
85
|
+
when Array
|
|
86
|
+
value.map { |item| deep_to_h(item) }
|
|
87
|
+
else
|
|
88
|
+
value
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Calculation
|
|
6
|
+
class AddressLocation < Speedy::Model
|
|
7
|
+
field :country_id, type: :integer
|
|
8
|
+
field :state_id, type: :string
|
|
9
|
+
field :site_id, type: :integer
|
|
10
|
+
field :site_type, type: :string
|
|
11
|
+
field :site_name, type: :string
|
|
12
|
+
field :post_code, type: :string
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Calculation
|
|
6
|
+
class CalculationContent < Speedy::Model
|
|
7
|
+
field :parcels_count, type: :integer
|
|
8
|
+
field :total_weight, type: :float
|
|
9
|
+
field :documents, type: :boolean
|
|
10
|
+
field :palletized, type: :boolean
|
|
11
|
+
field :parcels, type: :array, of: Speedy::Models::Shipments::ShipmentParcel
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Calculation
|
|
6
|
+
class CalculationRecipient < Speedy::Model
|
|
7
|
+
field :client_id, type: :integer
|
|
8
|
+
field :private_person, type: :boolean
|
|
9
|
+
field :address_location, type: Speedy::Models::Calculation::AddressLocation
|
|
10
|
+
field :pickup_office_id, type: :integer
|
|
11
|
+
field :pickup_geo_pudo_id, type: :string
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Calculation
|
|
6
|
+
class CalculationResult < Speedy::Model
|
|
7
|
+
collection_key :calculations
|
|
8
|
+
|
|
9
|
+
field :service_id, type: :integer
|
|
10
|
+
field :price, type: Speedy::Models::Shipments::ShipmentPrice
|
|
11
|
+
field :pickup_date, type: :string
|
|
12
|
+
field :delivery_deadline, type: :string
|
|
13
|
+
field :delivery_deadline_work_day_type, type: :string
|
|
14
|
+
field :additional_services, type: Speedy::Models::Shipments::ShipmentAdditionalServices
|
|
15
|
+
field :error, type: Speedy::Models::Error
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Calculation
|
|
6
|
+
class CalculationSender < Speedy::Model
|
|
7
|
+
field :client_id, type: :integer
|
|
8
|
+
field :private_person, type: :boolean
|
|
9
|
+
field :address_location, type: Speedy::Models::Calculation::AddressLocation
|
|
10
|
+
field :dropoff, type: :boolean
|
|
11
|
+
field :dropoff_office_id, type: :integer
|
|
12
|
+
field :dropoff_geo_pudo_id, type: :string
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Calculation
|
|
6
|
+
class CalculationService < Speedy::Model
|
|
7
|
+
field :pickup_date, type: :string
|
|
8
|
+
field :auto_adjust_pickup_date, type: :boolean
|
|
9
|
+
field :service_ids, type: :array
|
|
10
|
+
field :additional_services
|
|
11
|
+
field :deferred_days, type: :integer
|
|
12
|
+
field :saturday_delivery, type: :boolean
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Clients
|
|
6
|
+
class Client < Speedy::Model
|
|
7
|
+
collection_key :clients
|
|
8
|
+
|
|
9
|
+
field :client_id, type: :integer
|
|
10
|
+
field :client_name, type: :string
|
|
11
|
+
field :object_name, type: :string
|
|
12
|
+
field :contact_name, type: :string
|
|
13
|
+
field :address, type: Speedy::Models::Common::Address
|
|
14
|
+
field :email, type: :string
|
|
15
|
+
field :private_person, type: :boolean
|
|
16
|
+
field :phones, type: :array, of: Speedy::Models::Shipments::ShipmentPhoneNumber
|
|
17
|
+
field :external_contact_id, type: :string
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Clients
|
|
6
|
+
class CODContractInfo < Speedy::Model
|
|
7
|
+
field :money_transfer_allowed, type: :boolean
|
|
8
|
+
field :cod_fiscal_receipt_allowed, type: :boolean
|
|
9
|
+
field :has_cod_annex, type: :boolean
|
|
10
|
+
field :international_cod_annexes,
|
|
11
|
+
type: :array,
|
|
12
|
+
of: Speedy::Models::Clients::CODInternationalAnnex
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Clients
|
|
6
|
+
class ContractInfo < Speedy::Model
|
|
7
|
+
field :error, type: Speedy::Models::Error
|
|
8
|
+
field :id, type: :integer
|
|
9
|
+
field :special_delivery_requirements,
|
|
10
|
+
type: Speedy::Models::Clients::SpecialDeliveryRequirements
|
|
11
|
+
field :cod, type: Speedy::Models::Clients::CODContractInfo
|
|
12
|
+
field :administrative_fee_allowed, type: :boolean
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Clients
|
|
6
|
+
class SpecialDeliveryRequirements < Speedy::Model
|
|
7
|
+
field :required_for_all_shipments, type: :boolean
|
|
8
|
+
field :requirements, type: :array, of: Speedy::Models::Clients::Requirement
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Common
|
|
6
|
+
class Address < Speedy::Model
|
|
7
|
+
field :country_id, type: :integer
|
|
8
|
+
field :state_id, type: :string
|
|
9
|
+
field :site_id, type: :integer
|
|
10
|
+
field :site_type, type: :string
|
|
11
|
+
field :site_name, type: :string
|
|
12
|
+
field :post_code, type: :string
|
|
13
|
+
field :street_id, type: :integer
|
|
14
|
+
field :street_type, type: :string
|
|
15
|
+
field :street_name, type: :string
|
|
16
|
+
field :street_no, type: :string
|
|
17
|
+
field :complex_id, type: :integer
|
|
18
|
+
field :complex_type, type: :string
|
|
19
|
+
field :complex_name, type: :string
|
|
20
|
+
field :block_no, type: :string
|
|
21
|
+
field :entrance_no, type: :string
|
|
22
|
+
field :floor_no, type: :string
|
|
23
|
+
field :apartment_no, type: :string
|
|
24
|
+
field :poi_id, type: :integer
|
|
25
|
+
field :address_note, type: :string
|
|
26
|
+
field :address_line1, type: :string
|
|
27
|
+
field :address_line2, type: :string
|
|
28
|
+
field :x, type: :float
|
|
29
|
+
field :y, type: :float
|
|
30
|
+
field :full_address_string, type: :string
|
|
31
|
+
field :site_address_string, type: :string
|
|
32
|
+
field :local_address_string, type: :string
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
class Error < Speedy::Model
|
|
6
|
+
field :context, type: :string
|
|
7
|
+
field :message, type: :string
|
|
8
|
+
field :id, type: :string
|
|
9
|
+
field :code, type: :integer
|
|
10
|
+
field :component, type: :string
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def build_from(source)
|
|
14
|
+
error_source = error_source_from(source)
|
|
15
|
+
return unless error_source
|
|
16
|
+
|
|
17
|
+
new(error_source)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def error_source_from(source)
|
|
23
|
+
return unless source.is_a?(Hash)
|
|
24
|
+
|
|
25
|
+
root_error = source[:error] || source['error']
|
|
26
|
+
return root_error if root_error.is_a?(Hash)
|
|
27
|
+
|
|
28
|
+
source if source.key?(:message) || source.key?('message')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def full_message
|
|
33
|
+
[message, context].reject { |value| value.to_s.strip.empty? }.join(' ')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class Block < Speedy::Model
|
|
7
|
+
collection_key :blocks
|
|
8
|
+
|
|
9
|
+
field :site_id, type: :integer
|
|
10
|
+
field :name, type: :string
|
|
11
|
+
field :name_en, type: :string
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class Complex < Speedy::Model
|
|
7
|
+
collection_key :complexes
|
|
8
|
+
|
|
9
|
+
field :id, type: :integer
|
|
10
|
+
field :site_id, type: :integer
|
|
11
|
+
field :actual_id, type: :integer
|
|
12
|
+
field :type, type: :string
|
|
13
|
+
field :type_en, type: :string
|
|
14
|
+
field :name, type: :string
|
|
15
|
+
field :name_en, type: :string
|
|
16
|
+
field :actual_type, type: :string
|
|
17
|
+
field :actual_type_en, type: :string
|
|
18
|
+
field :actual_name, type: :string
|
|
19
|
+
field :actual_name_en, type: :string
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class Country < Speedy::Model
|
|
7
|
+
collection_key :countries
|
|
8
|
+
|
|
9
|
+
field :id, type: :integer
|
|
10
|
+
field :name, type: :string
|
|
11
|
+
field :name_en, type: :string
|
|
12
|
+
field :iso_alpha2, type: :string
|
|
13
|
+
field :iso_alpha3, type: :string
|
|
14
|
+
field :currency_code, type: :string
|
|
15
|
+
field :require_state, type: :boolean
|
|
16
|
+
field :address_type, type: :integer
|
|
17
|
+
field :default_office_id, type: :integer
|
|
18
|
+
field :site_nomen, type: :integer
|
|
19
|
+
field :street_types, type: :array, of: Speedy::Models::Location::AddressNomenclatureType
|
|
20
|
+
field :complex_types, type: :array, of: Speedy::Models::Location::AddressNomenclatureType
|
|
21
|
+
field :post_code_formats, type: :array
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class FindOfficeResponse < Speedy::Model
|
|
7
|
+
field :offices, type: :array, of: Speedy::Models::Location::Office
|
|
8
|
+
field :error, type: Speedy::Models::Error
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class FindSiteResponse < Speedy::Model
|
|
7
|
+
field :sites, type: :array, of: Speedy::Models::Location::Site
|
|
8
|
+
field :error, type: Speedy::Models::Error
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class Office < Speedy::Model
|
|
7
|
+
collection_key :offices
|
|
8
|
+
|
|
9
|
+
field :id, type: :integer
|
|
10
|
+
field :name, type: :string
|
|
11
|
+
field :name_en, type: :string
|
|
12
|
+
field :site_id, type: :integer
|
|
13
|
+
field :address, type: Speedy::Models::Common::Address
|
|
14
|
+
field :working_time_from, type: :string
|
|
15
|
+
field :working_time_to, type: :string
|
|
16
|
+
field :working_time_half_from, type: :string
|
|
17
|
+
field :working_time_half_to, type: :string
|
|
18
|
+
field :working_time_day_off_from, type: :string
|
|
19
|
+
field :working_time_day_off_to, type: :string
|
|
20
|
+
field :same_day_departure_cutoff, type: :string
|
|
21
|
+
field :same_day_departure_cutoff_half, type: :string
|
|
22
|
+
field :same_day_departure_cutoff_day_off, type: :string
|
|
23
|
+
field :max_parcel_dimensions, type: Speedy::Models::Shipments::ShipmentParcelSize
|
|
24
|
+
field :max_parcel_weight, type: :float
|
|
25
|
+
field :type, type: :string
|
|
26
|
+
field :vendor, type: :integer
|
|
27
|
+
field :nearby_office_id, type: :integer
|
|
28
|
+
field :working_time_schedule, type: :array, of: Speedy::Models::Location::OfficeWorkingTimeSchedule
|
|
29
|
+
field :valid_from, type: :string
|
|
30
|
+
field :valid_to, type: :string
|
|
31
|
+
field :cargo_types_allowed, type: :array
|
|
32
|
+
field :pick_up_allowed, type: :boolean
|
|
33
|
+
field :drop_off_allowed, type: :boolean
|
|
34
|
+
field :routing_information, type: Speedy::Models::Location::RoutingInformation
|
|
35
|
+
field :pallet_office, type: :boolean
|
|
36
|
+
field :cash_payment_allowed, type: :boolean
|
|
37
|
+
field :card_payment_allowed, type: :boolean
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Speedy
|
|
4
|
+
module Models
|
|
5
|
+
module Location
|
|
6
|
+
class OfficeWorkingTimeSchedule < Speedy::Model
|
|
7
|
+
field :date, type: :string
|
|
8
|
+
field :working_time_from, type: :string
|
|
9
|
+
field :working_time_to, type: :string
|
|
10
|
+
field :same_day_departure_cutoff, type: :string
|
|
11
|
+
field :standard_schedule, type: :boolean
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|