class Deliveries::Couriers::CorreosExpress::Pickups::CutoffTime::FormatParams

Attributes

country[RW]
postcode[RW]

Public Class Methods

new(country:, postcode:) click to toggle source
# File lib/deliveries/couriers/correos_express/pickups/cutoff_time/format_params.rb, line 9
def initialize(country:, postcode:)
  self.country = country
  self.postcode = postcode
end

Public Instance Methods

execute() click to toggle source
# File lib/deliveries/couriers/correos_express/pickups/cutoff_time/format_params.rb, line 14
def execute
  params = {
    strCP: postcode,
    strPais: country_code_to_id(country)
  }

  params.to_json
end

Private Instance Methods

country_code_to_id(country_code) click to toggle source
# File lib/deliveries/couriers/correos_express/pickups/cutoff_time/format_params.rb, line 25
def country_code_to_id(country_code)
  case country_code.to_sym.downcase
  when :es
    '34'
  when :pt
    '35'
  else
    raise Deliveries::Error, "Invalid country #{country_code}"
  end
end