Skip to content

Commit

Permalink
Rely on constants for Carrier.tracking_url_template
Browse files Browse the repository at this point in the history
  • Loading branch information
brodyhoskins committed Feb 2, 2024
1 parent 0357e24 commit 4a7dca3
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions lib/freight_kit/carrier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ def pickup_number_is_tracking_number?
false
end

# Returns the keywords passed to `#initialize` that cannot be blank.
# @return [Array<Symbol>]
def requirements
[]
end

# Returns the `Credential` methods (passed to `#initialize`) that cannot respond with blank values.
# @return [Array<Symbol>]
def required_credential_types
%i[api]
end

# The template URL for tracking publicly. A template URL is a URL containing the token "%s" that can be replaced
# to generate a valid URL.
#
Expand All @@ -111,21 +123,17 @@ def tracking_url_template(key)
keys = %i[bol_number order_number pickup_number po_number tracking_number]

raise ArgumentError, "key must be one of: #{keys.join(", ")}" if keys.exclude?(key)
end

# Returns the keywords passed to `#initialize` that cannot be blank.
# @return [Array<Symbol>]
def requirements
[]
end

# Returns the `Credential` methods (passed to `#initialize`) that cannot respond with blank values.
# @return [Array<Symbol>]
def required_credential_types
%i[api]

"#{self}::#{key.to_s.upcase}_TRACKING_URL_TEMPLATE".constantize
end
end

BOL_NUMBER_TRACKING_URL_TEMPLATE = nil
ORDER_NUMBER_TRACKING_URL_TEMPLATE = nil
PICKUP_NUMBER_TRACKING_URL_TEMPLATE = nil
PO_NUMBER_TRACKING_URL_TEMPLATE = nil
TRACKING_NUMBER_TRACKING_URL_TEMPLATE = nil

attr_accessor :conf, :rates_with_excessive_length_fees, :tmpdir
attr_reader :credentials, :customer_location, :last_request, :tariff

Expand Down

0 comments on commit 4a7dca3

Please sign in to comment.