Sha256: ce1b119ff223a94031e9070253ff6d9359e3935f3d8eb15deee902a9b3a2a8b1

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require "hashie"

module ShipEngine
  module Domain
    class Rates
      def initialize
        @client = ShipEngine::Client.new
      end

      def shipping_rates(params: {})
        response = @client.post(
          path: ShipEngine::Constants::PATHS.v1.rates.root,
          options: params
        )

        Hashie::Mash.new(response.body)
      end

      def bulk_rates(params: {})
        response = @client.post(
          path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/bulk",
          options: params
        )

        response.body.map { |rate| Hashie::Mash.new(rate) }
      end

      def estimate_rates(params: {})
        response = @client.post(
          path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/estimate",
          options: params
        )

        response.body.map { |rate| Hashie::Mash.new(rate) }
      end

      def rate_by_id(rate_id:, params: {})
        response = @client.get(
          path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/#{rate_id}",
          options: params
        )

        Hashie::Mash.new(response.body)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shipengine_ruby-0.0.7 lib/shipengine/domains/rates.rb
shipengine_ruby-0.0.6 lib/shipengine/domains/rates.rb
shipengine_ruby-0.0.5 lib/shipengine/domains/rates.rb
shipengine_ruby-0.0.4 lib/shipengine/domains/rates.rb
shipengine_ruby-0.0.3 lib/shipengine/domains/rates.rb
shipengine_ruby-0.0.2 lib/shipengine/domains/rates.rb
shipengine_ruby-0.0.1 lib/shipengine/domains/rates.rb