Class: FreightKit::Platform
- Defined in:
- lib/freight_kit/platform.rb
Instance Attribute Summary
Attributes inherited from Carrier
#conf, #credentials, #customer_location, #last_request, #rates_with_excessive_length_fees, #tariff, #tmpdir
Instance Method Summary collapse
-
#initialize(credentials, customer_location: nil, tariff: nil) ⇒ Platform
constructor
Credentials should be a
CredentialorArrayofCredential.
Methods inherited from Carrier
#available_services, available_services_implemented?, #bol, bol_requires_tracking_number?, #cancel_shipment, cancel_shipment_implemented?, #create_pickup, create_pickup_implemented?, default_location, #fetch_credential, #find_estimate, find_estimate_implemented?, #find_locations, #find_rates, find_rates_implemented?, find_rates_with_declared_value?, #find_tracking_info, find_tracking_info_implemented?, #find_tracking_number_from_pickup_number, find_tracking_number_from_pickup_number_implemented?, maximum_address_field_length, maximum_height, maximum_weight, minimum_length_for_overlength_fees, #overlength_fee, overlength_fees_require_tariff?, pickup_number_is_tracking_number?, #pod, pod_implemented?, required_credential_types, requirements, #scanned_bol, scanned_bol_implemented?, #serviceable_accessorials?, #valid_credentials?, #valid_tracking_number?, #validate_packages
Constructor Details
#initialize(credentials, customer_location: nil, tariff: nil) ⇒ Platform
Credentials should be a Credential or Array of Credential
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/freight_kit/platform.rb', line 6 def initialize(credentials, customer_location: nil, tariff: nil) super # Use #superclass instead of using #ancestors to fetch the parent class which the carrier class is inheriting from # (#ancestors returns an array including the parent class and all the modules that were included) parent_class_name = self.class.superclass.name.demodulize.underscore conf_path = File .join( File.( '../../../../configuration/platforms', self.class.const_source_location(:REACTIVE_FREIGHT_PLATFORM).first, ), "#{parent_class_name}.yml", ) @conf = YAML.safe_load(File.read(conf_path), permitted_classes: [Symbol]) conf_path = File .join( File.( '../../../../configuration/carriers', self.class.const_source_location(:REACTIVE_FREIGHT_CARRIER).first, ), "#{self.class.to_s.demodulize.underscore}.yml", ) @conf = @conf.deep_merge(YAML.safe_load(File.read(conf_path), permitted_classes: [Symbol])) @rates_with_excessive_length_fees = @conf.dig(:attributes, :rates, :with_excessive_length_fees) end |